set file perm if exists
@@ -170,18 +170,20 @@ func AddToGitIgnore(filename string, loader ReaderWriter) error {
}
gitIgnorePath := path.Join(currentWd, ".gitignore")
gitIgnoreFiles := ""
+ filePermissions := os.FileMode(0644)
- _, err = os.Stat(gitIgnorePath)
+ fileStat, err := os.Stat(gitIgnorePath)
if !os.IsNotExist(err) { // if gitignore exists
gitIgnoreFilesRaw, err := loader.ReadFile(gitIgnorePath)
if err != nil {
return err
}
gitIgnoreFiles = string(gitIgnoreFilesRaw)
+ filePermissions = fileStat.Mode().Perm()
}
return loader.WriteFile(
gitIgnorePath,
[]byte(fmt.Sprintf("%s\n%s", gitIgnoreFiles, filename)),
- 0644,
+ filePermissions,
)
}
