Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Okstad <pokstad@gitlab.com>2019-09-05 20:52:16 +0300
committerPaul Okstad <pokstad@gitlab.com>2019-09-05 20:52:16 +0300
commit2d8544a02ff3dff5e2ee41de7517291759e804c5 (patch)
tree5f38dab3cf241b28423bbde32dd62a71f4cda33e
parent392b8f31facb00a66b842e2072189c150b838ee4 (diff)
parentd3243080b7ba7fc5dad048ec740e8d268bdf315c (diff)
Merge branch 'attribute-perm' into 'master'
Maintain permissions for attribute file while applying attribute Closes #1855 See merge request gitlab-org/gitaly!1466
-rw-r--r--changelogs/unreleased/attributes-perm.yml5
-rw-r--r--internal/service/repository/apply_gitattributes.go7
-rw-r--r--internal/service/repository/apply_gitattributes_test.go5
3 files changed, 17 insertions, 0 deletions
diff --git a/changelogs/unreleased/attributes-perm.yml b/changelogs/unreleased/attributes-perm.yml
new file mode 100644
index 000000000..03bf4e4c0
--- /dev/null
+++ b/changelogs/unreleased/attributes-perm.yml
@@ -0,0 +1,5 @@
+---
+title: Set permission of attributes file to `0644`
+merge_request: 1466
+author: @njkevlani
+type: added
diff --git a/internal/service/repository/apply_gitattributes.go b/internal/service/repository/apply_gitattributes.go
index 4f52a06be..c302ce170 100644
--- a/internal/service/repository/apply_gitattributes.go
+++ b/internal/service/repository/apply_gitattributes.go
@@ -16,6 +16,8 @@ import (
"google.golang.org/grpc/status"
)
+const attributesFileMode os.FileMode = 0644
+
func applyGitattributes(c *catfile.Batch, repoPath string, revision []byte) error {
infoPath := path.Join(repoPath, "info")
attributesPath := path.Join(infoPath, "attributes")
@@ -68,6 +70,11 @@ func applyGitattributes(c *catfile.Batch, repoPath string, revision []byte) erro
return err
}
+ // Change the permission of tempFile as the permission of file attributesPath
+ if err := os.Chmod(tempFile.Name(), attributesFileMode); err != nil {
+ return err
+ }
+
// Rename temp file and return the result
return os.Rename(tempFile.Name(), attributesPath)
}
diff --git a/internal/service/repository/apply_gitattributes_test.go b/internal/service/repository/apply_gitattributes_test.go
index e82968530..0dd242b92 100644
--- a/internal/service/repository/apply_gitattributes_test.go
+++ b/internal/service/repository/apply_gitattributes_test.go
@@ -149,6 +149,11 @@ func assertGitattributesApplied(t *testing.T, client gitalypb.RepositoryServiceC
t.Error(err)
}
+ if info, err := os.Stat(attributesPath); err == nil {
+ actualFileMode := info.Mode()
+ assert.Equal(t, attributesFileMode, actualFileMode)
+ }
+
assert.Equal(t, expectedContents, contents)
}
}