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:
authorJames Ramsay <james@jramsay.com.au>2020-06-04 04:11:26 +0300
committerJames Ramsay <james@jramsay.com.au>2020-06-09 03:47:23 +0300
commit372cd4d229bf866354e39d1202f3d9296bafe0ab (patch)
treea099ad90cf644624f37d9466b1f94e264c0714b7
parent22dcda65372742bc9ae5ffdfdb32ff8ebfecc738 (diff)
Allow pipeline refs to be cleaned
Pipeline refs should be removed after the pipeline runs, but if they are not for some reason, this allows them to be cleaned. This is particularly important for reducing repo size, or removing sensitive information.
-rw-r--r--internal/service/cleanup/apply_bfg_object_map_stream_test.go6
-rw-r--r--internal/service/cleanup/internalrefs/cleaner.go1
2 files changed, 5 insertions, 2 deletions
diff --git a/internal/service/cleanup/apply_bfg_object_map_stream_test.go b/internal/service/cleanup/apply_bfg_object_map_stream_test.go
index 7146ee877..b109575b7 100644
--- a/internal/service/cleanup/apply_bfg_object_map_stream_test.go
+++ b/internal/service/cleanup/apply_bfg_object_map_stream_test.go
@@ -40,7 +40,7 @@ func TestApplyBfgObjectMapStreamSuccess(t *testing.T) {
// Create some refs pointing to HEAD
for _, ref := range []string{
- "refs/environments/1", "refs/keep-around/1", "refs/merge-requests/1",
+ "refs/environments/1", "refs/keep-around/1", "refs/merge-requests/1", "refs/pipelines/1",
"refs/heads/_keep", "refs/tags/_keep", "refs/notes/_keep",
} {
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "update-ref", ref, headCommit.Id)
@@ -49,7 +49,7 @@ func TestApplyBfgObjectMapStreamSuccess(t *testing.T) {
// Create some refs pointing to ref/tags/v1.0.0, simulating an unmodified
// commit that predates bad data being added to the repository.
for _, ref := range []string{
- "refs/environments/_keep", "refs/keep-around/_keep", "refs/merge-requests/_keep",
+ "refs/environments/_keep", "refs/keep-around/_keep", "refs/merge-requests/_keep", "refs/pipelines/_keep",
} {
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "update-ref", ref, tagID)
}
@@ -72,12 +72,14 @@ func TestApplyBfgObjectMapStreamSuccess(t *testing.T) {
assert.NotContains(t, refs, "refs/environments/1")
assert.NotContains(t, refs, "refs/keep-around/1")
assert.NotContains(t, refs, "refs/merge-requests/1")
+ assert.NotContains(t, refs, "refs/pipelines/1")
assert.Contains(t, refs, "refs/heads/_keep")
assert.Contains(t, refs, "refs/tags/_keep")
assert.Contains(t, refs, "refs/notes/_keep")
assert.Contains(t, refs, "refs/environments/_keep")
assert.Contains(t, refs, "refs/keep-around/_keep")
assert.Contains(t, refs, "refs/merge-requests/_keep")
+ assert.Contains(t, refs, "refs/pipelines/_keep")
// Ensure that the returned entry is correct
require.Len(t, entries, 4, "wrong number of entries returned")
diff --git a/internal/service/cleanup/internalrefs/cleaner.go b/internal/service/cleanup/internalrefs/cleaner.go
index d647bc3a4..dc1c3be0d 100644
--- a/internal/service/cleanup/internalrefs/cleaner.go
+++ b/internal/service/cleanup/internalrefs/cleaner.go
@@ -19,6 +19,7 @@ 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