aboutsummaryrefslogtreecommitdiff
path: root/apply.go
diff options
context:
space:
mode:
authorBen Burwell <ben@benburwell.com>2019-08-13 14:38:31 -0400
committerBen Burwell <ben@benburwell.com>2019-08-13 14:38:31 -0400
commit3fa3887c342393b25e2df48f4c096cbf31ce2d5f (patch)
tree5694d77f58c1e05fd369c9fd1b949fb2f204653c /apply.go
parente083b1b1558dc1e97da361c505653a38bd339cef (diff)
Preserve file mode on adopt/apply
Diffstat (limited to 'apply.go')
-rw-r--r--apply.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/apply.go b/apply.go
index eaa528a..89abf8d 100644
--- a/apply.go
+++ b/apply.go
@@ -42,7 +42,11 @@ func applyFile(name string) error {
if err = os.MkdirAll(filepath.Dir(d), 0700); err != nil {
return err
}
- out, err := os.OpenFile(d, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600)
+ srcInfo, err := os.Stat(src)
+ if err != nil {
+ return err
+ }
+ out, err := os.OpenFile(d, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, srcInfo.Mode())
if err != nil {
return err
}