mirror of
https://github.com/golang/go
synced 2024-11-26 15:06:52 -07:00
misc/makerelease: use built in "del" to remove files
Git marks some of its files read only, so os.RemoveAll isn't sufficient to remove them from the ".git" directory. Change-Id: I3150596931d1c77e7cf9fb8da1a999d2c6730121 Reviewed-on: https://go-review.googlesource.com/2930 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
90ce1936e3
commit
1d890ac0b2
@ -775,7 +775,19 @@ func setupOAuthClient() error {
|
||||
|
||||
func (b *Build) clean(files []string) error {
|
||||
for _, name := range files {
|
||||
err := os.RemoveAll(filepath.Join(b.root, name))
|
||||
path := filepath.Join(b.root, name)
|
||||
var err error
|
||||
if b.OS == "windows" {
|
||||
// Git sets some of its packfiles as 'read only',
|
||||
// so os.RemoveAll will fail for the ".git" directory.
|
||||
// Instead, shell out to cmd's 'del' subcommand.
|
||||
cmd := exec.Command("cmd.exe", "/C", "del", "/Q", "/F", "/S", path)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
err = cmd.Run()
|
||||
} else {
|
||||
err = os.RemoveAll(path)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user