mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 19:21:50 +00:00
Part of https://github.com/sourcegraph/sourcegraph/issues/62101 This PR ports the GetBehindAhead implementation from the gitserver client to the new gitserver.Backend interface. Here is the original implementation from the client for reference: ```go // GetBehindAhead returns the behind/ahead commit counts information for right vs. left (both Git // revspecs). func (c *clientImplementor) GetBehindAhead(ctx context.Context, repo api.RepoName, left, right string) (_ *gitdomain.BehindAhead, err error) { ctx, _, endObservation := c.operations.getBehindAhead.With(ctx, &err, observation.Args{ MetricLabelValues: []string{c.scope}, Attrs: []attribute.KeyValue{ repo.Attr(), attribute.String("left", left), attribute.String("right", right), }, }) defer endObservation(1, observation.Args{}) if err := checkSpecArgSafety(left); err != nil { return nil, err } if err := checkSpecArgSafety(right); err != nil { return nil, err } cmd := c.gitCommand(repo, "rev-list", "--count", "--left-right", fmt.Sprintf("%s...%s", left, right)) out, err := cmd.Output(ctx) if err != nil { return nil, err } behindAhead := strings.Split(strings.TrimSuffix(string(out), "\n"), "\t") b, err := strconv.ParseUint(behindAhead[0], 10, 0) if err != nil { return nil, err } a, err := strconv.ParseUint(behindAhead[1], 10, 0) if err != nil { return nil, err } return &gitdomain.BehindAhead{Behind: uint32(b), Ahead: uint32(a)}, nil } ``` ## Test plan New unit tests |
||
|---|---|---|
| .. | ||
| archivereader_test.go | ||
| archivereader.go | ||
| blame_test.go | ||
| blame.go | ||
| BUILD.bazel | ||
| clibackend.go | ||
| command.go | ||
| config_test.go | ||
| config.go | ||
| contributors_test.go | ||
| contributors.go | ||
| diff_test.go | ||
| diff.go | ||
| exec_test.go | ||
| exec.go | ||
| head_test.go | ||
| head.go | ||
| mergebase_test.go | ||
| mergebase.go | ||
| metrics.go | ||
| object_test.go | ||
| object.go | ||
| odb_test.go | ||
| odb.go | ||
| refs_test.go | ||
| refs.go | ||
| resolverevision_test.go | ||
| resolverevision.go | ||
| revattime_test.go | ||
| revattime.go | ||
| util_test.go | ||
| util.go | ||