sourcegraph/cmd
Geoffrey Gilmore e19c22d0a9
gitserver: grpc: port GetBehindAhead from client to gitcli backend (#62212)
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
2024-05-02 11:25:54 -07:00
..
appliance appliance: add appliance skeleton (#62172) 2024-04-29 16:04:56 -04:00
batcheshelper Build images end-to-end using Bazel v2 (#61845) 2024-04-12 16:18:43 +01:00
blobstore chore: Break dependency of internal/trace on conf (#62177) 2024-04-30 21:12:39 +02:00
bundled-executor Build images end-to-end using Bazel v2 (#61845) 2024-04-12 16:18:43 +01:00
cody-gateway Cody Gateway: adding mixtral8x7b finetuned model for code completions (#62300) 2024-05-01 00:09:54 +05:30
embeddings chore: Break dependency of internal/trace on conf (#62177) 2024-04-30 21:12:39 +02:00
executor chore: Remove dead code (#61899) 2024-04-16 10:17:47 +02:00
executor-kubernetes Build images end-to-end using Bazel v2 (#61845) 2024-04-12 16:18:43 +01:00
frontend httpcli: Move init function from conf package into httpcli (#62318) 2024-05-02 18:30:44 +02:00
gitserver gitserver: grpc: port GetBehindAhead from client to gitcli backend (#62212) 2024-05-02 11:25:54 -07:00
loadtest Publish sourcegraph-base image (#62002) 2024-04-19 14:44:06 +01:00
migrator Publish sourcegraph-base image (#62002) 2024-04-19 14:44:06 +01:00
msp-example cmd/msp-example: remove gorm (#62110) 2024-04-23 20:00:10 +00:00
pings cmd/pings: set up msp_delivery (#62109) 2024-04-23 14:03:18 -07:00
precise-code-intel-worker Publish sourcegraph-base image (#62002) 2024-04-19 14:44:06 +01:00
repo-updater Don't log when repo-updater shuts down (#62121) 2024-04-25 02:04:20 +02:00
searcher Search: expect trailing newlines in chunk matches (#61247) 2024-04-23 15:03:52 -06:00
server gitserver: Simplify invocation of p4-fusion (#62070) 2024-05-02 01:44:53 +02:00
symbols rockskip: Switch from long-running process to pagination (#62259) 2024-05-02 02:17:48 +02:00
syntactic-code-intel-worker Publish sourcegraph-base image (#62002) 2024-04-19 14:44:06 +01:00
telemetry-gateway telemetry/resolvers, internal/telemetry, telemetry-gateway: validate feature/action (#62214) 2024-04-29 19:34:50 +00:00
worker Fix OOB migrations progress updates (#61770) 2024-04-30 17:23:17 -07:00
README.md Reminder to keep architecture diagram in-sync (#36869) 2022-06-08 19:40:36 -07:00

This directory contains Sourcegraph services and binaries.

When a services is added, removed, or when a service's dependencies change, update our architecture diagram.