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:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-04-27 09:08:45 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-04-30 16:05:33 +0300
commitb85133f39c70e065ffeafa328d628085aa82de6c (patch)
tree4636618c4e2950d3efa463f4a1e90dd83fe4d11d
parent7defe82db92f29fdd574e3f881b6b6e3c30c1890 (diff)
git: Move list of internal ref namespaces to central location
We have a bunch of internal reference namespaces which we need to treat specially in some contexts. This list is currently defined in the cleanup service as it is the only current user. Given that we're about to introduce a second user, move this list into the `internal/git` package to make it available for reuse in a central location.
-rw-r--r--internal/git/reference.go9
-rw-r--r--internal/gitaly/service/cleanup/internalrefs/cleaner.go10
2 files changed, 10 insertions, 9 deletions
diff --git a/internal/git/reference.go b/internal/git/reference.go
index 494d20c77..96a32190d 100644
--- a/internal/git/reference.go
+++ b/internal/git/reference.go
@@ -6,6 +6,15 @@ import (
"strings"
)
+// InternalRefPrefixes is an array of all reference prefixes which are used internally by GitLab.
+// These need special treatment in some cases, e.g. to restrict writing to them.
+var InternalRefPrefixes = [...]string{
+ "refs/environments/",
+ "refs/keep-around/",
+ "refs/merge-requests/",
+ "refs/pipelines/",
+}
+
// Revision represents anything that resolves to either a commit, multiple
// commits or to an object different than a commit. This could be e.g.
// "master", "master^{commit}", an object hash or similar. See gitrevisions(1)
diff --git a/internal/gitaly/service/cleanup/internalrefs/cleaner.go b/internal/gitaly/service/cleanup/internalrefs/cleaner.go
index 69369299e..5d5a75d19 100644
--- a/internal/gitaly/service/cleanup/internalrefs/cleaner.go
+++ b/internal/gitaly/service/cleanup/internalrefs/cleaner.go
@@ -15,14 +15,6 @@ import (
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
)
-// Only references in these namespaces are cleaned up
-var internalRefs = []string{
- "refs/environments/",
- "refs/keep-around/",
- "refs/merge-requests/",
- "refs/pipelines/",
-}
-
// A ForEachFunc can be called for every entry in the filter-repo or BFG object
// map file that the cleaner is processing. Returning an error will stop the
// cleaner before it has processed the entry in question
@@ -137,7 +129,7 @@ func buildLookupTable(ctx context.Context, gitCmdFactory git.CommandFactory, rep
cmd, err := gitCmdFactory.New(ctx, repo, git.SubCmd{
Name: "for-each-ref",
Flags: []git.Option{git.ValueFlag{Name: "--format", Value: "%(objectname) %(refname)"}},
- Args: internalRefs,
+ Args: git.InternalRefPrefixes[:],
})
if err != nil {
return nil, err