diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-01-14 10:19:11 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-01-14 10:19:11 +0300 |
commit | a4968a4410912fa547bc15276e43180353ebfd35 (patch) | |
tree | c3f073efcf55d58d54f8507a48f887e8df718524 | |
parent | d830c5ecb219b27b51113b95e8725e0348b7ebf7 (diff) |
internalrefs: Convert lookup table to return ReferenceNames
Instead of returning an untyped slice of strings which represent
references, this commit refactors the `buildLookupTable()` function to
return ReferenceNames instead.
-rw-r--r-- | internal/gitaly/service/cleanup/internalrefs/cleaner.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/internal/gitaly/service/cleanup/internalrefs/cleaner.go b/internal/gitaly/service/cleanup/internalrefs/cleaner.go index 6c11e5ad4..5ee728709 100644 --- a/internal/gitaly/service/cleanup/internalrefs/cleaner.go +++ b/internal/gitaly/service/cleanup/internalrefs/cleaner.go @@ -36,7 +36,7 @@ type Cleaner struct { forEach ForEachFunc // Map of SHA -> reference names - table map[string][]string + table map[string][]git.ReferenceName updater *updateref.Updater } @@ -117,7 +117,7 @@ func (c *Cleaner) processEntry(ctx context.Context, oldSHA, newSHA string) error // Remove the internal refs pointing to oldSHA for _, ref := range refs { - if err := c.updater.Delete(ref); err != nil { + if err := c.updater.Delete(ref.String()); err != nil { return err } } @@ -132,7 +132,7 @@ func (c *Cleaner) processEntry(ctx context.Context, oldSHA, newSHA string) error // an object that has been rewritten by the filter-repo or BFG (and so require // action). It is consulted once per line in the object map. Git is optimized // for ref -> SHA lookups, but we want the opposite! -func buildLookupTable(ctx context.Context, repo *gitalypb.Repository) (map[string][]string, error) { +func buildLookupTable(ctx context.Context, repo *gitalypb.Repository) (map[string][]git.ReferenceName, error) { cmd, err := git.NewCommand(ctx, repo, nil, git.SubCmd{ Name: "for-each-ref", Flags: []git.Option{git.ValueFlag{Name: "--format", Value: "%(objectname) %(refname)"}}, @@ -143,7 +143,7 @@ func buildLookupTable(ctx context.Context, repo *gitalypb.Repository) (map[strin } logger := ctxlogrus.Extract(ctx) - out := make(map[string][]string) + out := make(map[string][]git.ReferenceName) scanner := bufio.NewScanner(cmd) for scanner.Scan() { @@ -154,7 +154,7 @@ func buildLookupTable(ctx context.Context, repo *gitalypb.Repository) (map[strin return nil, fmt.Errorf("failed to parse git refs") } - out[parts[0]] = append(out[parts[0]], parts[1]) + out[parts[0]] = append(out[parts[0]], git.ReferenceName(parts[1])) } if err := cmd.Wait(); err != nil { |