From 51740bb401a41b9986217595c468986af20ba58a Mon Sep 17 00:00:00 2001 From: Edward Muller Date: Fri, 20 May 2016 17:20:13 -0700 Subject: [PATCH] Preserve permissions when copying Set the file perimissions based on the permissions of the source file. Particularly useful for copying the x bit Fixes #404 --- Changelog.md | 4 ++++ save.go | 8 ++++++++ version.go | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 8b2e205..d5b309e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +#v71 (2016/05/24) + +* Preserve permissions on copied files. + #v70 (2016/05/20) * Fix the May changelog dates diff --git a/save.go b/save.go index 23ed6a4..1ceff8d 100644 --- a/save.go +++ b/save.go @@ -479,6 +479,11 @@ func copyFile(dst, src string) error { return os.Symlink(linkDst, dst) } + si, err := stat(src) + if err != nil { + return err + } + r, err := os.Open(src) if err != nil { return err @@ -489,6 +494,9 @@ func copyFile(dst, src string) error { if err != nil { return err } + if err := w.Chmod(si.Mode()); err != nil { + return err + } if strings.HasSuffix(dst, ".go") { debugln("Copy Without Import Comment", w, r) diff --git a/version.go b/version.go index 492e9f8..d197a03 100644 --- a/version.go +++ b/version.go @@ -8,7 +8,7 @@ import ( "strings" ) -const version = 70 +const version = 71 var cmdVersion = &Command{ Name: "version",