Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.

Commit

Permalink
Preserve permissions when copying
Browse files Browse the repository at this point in the history
Set the file perimissions based on the permissions of the source file.
Particularly useful for copying the x bit

Fixes #404
  • Loading branch information
Edward Muller committed May 24, 2016
1 parent 56b9657 commit 51740bb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#v71 (2016/05/24)

* Preserve permissions on copied files.

#v70 (2016/05/20)

* Fix the May changelog dates
Expand Down
8 changes: 8 additions & 0 deletions save.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
)

const version = 70
const version = 71

var cmdVersion = &Command{
Name: "version",
Expand Down

0 comments on commit 51740bb

Please sign in to comment.