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:
authorJohn Cai <jcai@gitlab.com>2022-05-13 18:33:00 +0300
committerJohn Cai <jcai@gitlab.com>2022-05-16 15:39:07 +0300
commitdb39afe369d908482b567bd9d27d7e69f9823fd6 (patch)
tree2cd3c59ebcc2bedc05c966dee51f6d402610b65f
parentc4d7176839a7cc46c3631b59cf53052ebf987367 (diff)
localrepo: Rename Excludes to ExcludeRefs
Now that we have an ExcludeAlternates, Excludes feels too general of a variable. Rename this to ExcludeRefs to make it clear that it's a slice of ref globs that are going to be excluded from the repo size calculation.
-rw-r--r--internal/git/localrepo/repo.go14
-rw-r--r--internal/git/localrepo/repo_test.go4
-rw-r--r--internal/gitaly/service/repository/size.go2
3 files changed, 10 insertions, 10 deletions
diff --git a/internal/git/localrepo/repo.go b/internal/git/localrepo/repo.go
index 3fef482e8..6e37ca8c7 100644
--- a/internal/git/localrepo/repo.go
+++ b/internal/git/localrepo/repo.go
@@ -97,9 +97,9 @@ func errorWithStderr(err error, stderr []byte) error {
// repoSizeConfig can be used to pass in different options to
// git rev-list in determining the size of a repository.
type repoSizeConfig struct {
- // Excludes is a list of ref glob patterns to exclude from the size
+ // ExcludeRefs is a list of ref glob patterns to exclude from the size
// calculation.
- Excludes []string
+ ExcludeRefs []string
// ExcludeAlternates will exclude objects in the alternates directory
// from being counted towards the total size of the repository.
ExcludeAlternates bool
@@ -108,12 +108,12 @@ type repoSizeConfig struct {
// RepoSizeOption is an option which can be passed to Size
type RepoSizeOption func(*repoSizeConfig)
-// WithExcludes is an option for Size that excludes certain refs from the size
+// WithExcludeRefs is an option for Size that excludes certain refs from the size
// calculation. The format must be a glob pattern.
// see https://git-scm.com/docs/git-rev-list#Documentation/git-rev-list.txt---excludeltglob-patterngt
-func WithExcludes(excludes ...string) RepoSizeOption {
+func WithExcludeRefs(excludeRefs ...string) RepoSizeOption {
return func(cfg *repoSizeConfig) {
- cfg.Excludes = excludes
+ cfg.ExcludeRefs = excludeRefs
}
}
@@ -135,10 +135,10 @@ func (repo *Repo) Size(ctx context.Context, opts ...RepoSizeOption) (int64, erro
}
var options []git.Option
- for _, exclude := range cfg.Excludes {
+ for _, refToExclude := range cfg.ExcludeRefs {
options = append(
options,
- git.Flag{Name: fmt.Sprintf("--exclude=%s", exclude)},
+ git.Flag{Name: fmt.Sprintf("--exclude=%s", refToExclude)},
)
}
diff --git a/internal/git/localrepo/repo_test.go b/internal/git/localrepo/repo_test.go
index 10f87514c..ce84670b5 100644
--- a/internal/git/localrepo/repo_test.go
+++ b/internal/git/localrepo/repo_test.go
@@ -172,7 +172,7 @@ func TestSize(t *testing.T) {
}
}
-func TestSize_excludes(t *testing.T) {
+func TestSize_excludeRefs(t *testing.T) {
cfg := testcfg.Build(t)
gitCmdFactory := gittest.NewCommandFactory(t, cfg)
catfileCache := catfile.NewCache(cfg)
@@ -202,7 +202,7 @@ func TestSize_excludes(t *testing.T) {
require.NoError(t, err)
assert.Less(t, sizeBeforeKeepAround, sizeWithKeepAround)
- sizeWithoutKeepAround, err := repo.Size(ctx, WithExcludes("refs/keep-around/*"))
+ sizeWithoutKeepAround, err := repo.Size(ctx, WithExcludeRefs("refs/keep-around/*"))
require.NoError(t, err)
assert.Equal(t, sizeBeforeKeepAround, sizeWithoutKeepAround)
diff --git a/internal/gitaly/service/repository/size.go b/internal/gitaly/service/repository/size.go
index a6bb0d33e..c73429418 100644
--- a/internal/gitaly/service/repository/size.go
+++ b/internal/gitaly/service/repository/size.go
@@ -29,7 +29,7 @@ func (s *server) RepositorySize(ctx context.Context, in *gitalypb.RepositorySize
if featureflag.RevlistForRepoSize.IsEnabled(ctx) {
size, err = repo.Size(
ctx,
- localrepo.WithExcludes(excludes...),
+ localrepo.WithExcludeRefs(excludes...),
)
if err != nil {
return nil, err