Skip to content

Commit aed8b60

Browse files
committed
refactor(conflict): Simplify the Tango changed-targets request
1 parent efed6ae commit aed8b60

3 files changed

Lines changed: 8 additions & 66 deletions

File tree

‎submitqueue/extension/conflict/tango/mock_request.go‎

Lines changed: 0 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎submitqueue/extension/conflict/tango/request.go‎

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@ import (
2222
"github.com/uber/submitqueue/platform/base/change"
2323
)
2424

25-
// ChangedTargetsRequest asks which targets change when Changes are applied on
26-
// top of a base revision.
25+
// ChangedTargetsRequest asks which targets change when ChangeURIs are applied
26+
// on top of a base revision.
2727
type ChangedTargetsRequest struct {
28-
// Remote is the repository remote that BaseRevision belongs to.
29-
Remote string
30-
31-
// BaseRevision is the commit SHA the changes are applied on top of.
28+
// BaseRevision is the full commit SHA the changes are applied on top of.
3229
BaseRevision string
3330

3431
// ChangeURIs lists every change to apply, in batch order.
@@ -44,25 +41,10 @@ type ChangedTargetsClient interface {
4441
ChangedTargets(ctx context.Context, request ChangedTargetsRequest) ([]LabelDistance, error)
4542
}
4643

47-
// Base is the newest revision of a queue's target branch.
48-
type Base struct {
49-
// Remote names the repository in the form the ChangedTargetsClient expects.
50-
Remote string
51-
52-
// Revision is the full commit SHA of the branch tip.
53-
Revision string
54-
}
55-
56-
// BaseResolver finds the base a queue's batches are analyzed against.
57-
type BaseResolver interface {
58-
// Base returns the current base of the named queue.
59-
Base(ctx context.Context, queue string) (Base, error)
60-
}
61-
62-
func changedTargetsRequestFor(base Base, changes []change.Change) ChangedTargetsRequest {
44+
func changedTargetsRequestFor(baseRevision string, changes []change.Change) ChangedTargetsRequest {
6345
var uris []string
6446
for _, c := range changes {
6547
uris = append(uris, c.URIs...)
6648
}
67-
return ChangedTargetsRequest{Remote: base.Remote, BaseRevision: base.Revision, ChangeURIs: uris}
49+
return ChangedTargetsRequest{BaseRevision: baseRevision, ChangeURIs: uris}
6850
}

‎submitqueue/extension/conflict/tango/request_test.go‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
)
2424

2525
func TestChangedTargetsRequestFor(t *testing.T) {
26-
base := Base{Remote: "git://host/repo", Revision: "9f2c1d0e3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d"}
26+
baseRevision := "9f2c1d0e3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d"
2727

2828
tests := []struct {
2929
name string
@@ -40,11 +40,10 @@ func TestChangedTargetsRequestFor(t *testing.T) {
4040
}
4141
for _, tt := range tests {
4242
t.Run(tt.name, func(t *testing.T) {
43-
got := changedTargetsRequestFor(base, tt.changes)
43+
got := changedTargetsRequestFor(baseRevision, tt.changes)
4444

4545
assert.Equal(t, ChangedTargetsRequest{
46-
Remote: base.Remote,
47-
BaseRevision: base.Revision,
46+
BaseRevision: baseRevision,
4847
ChangeURIs: tt.want,
4948
}, got)
5049
})

0 commit comments

Comments
 (0)