Skip to content

Commit a2fd43f

Browse files
committed
Correct remote sort order
According to the docs at https://golang.org/pkg/sort/#Interface > // Less reports whether the element with > // index i should sort before the element with index j. > Less(i, j int) bool A consistent comparison would then be i < j so, e.g., 1 is sorted before 2. In this case we need to ensure, `(origin = 1) < (upstream = 3)` Fixes cli#2657.
1 parent 230441e commit a2fd43f

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎context/remote.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func remoteNameSortScore(name string) int {
5151
func (r Remotes) Len() int { return len(r) }
5252
func (r Remotes) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
5353
func (r Remotes) Less(i, j int) bool {
54-
return remoteNameSortScore(r[i].Name) > remoteNameSortScore(r[j].Name)
54+
return remoteNameSortScore(r[i].Name) < remoteNameSortScore(r[j].Name)
5555
}
5656

5757
// Remote represents a git remote mapped to a GitHub repository

‎pkg/cmd/factory/remote_resolver_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ func Test_remoteResolver(t *testing.T) {
3737
require.NoError(t, err)
3838
require.Equal(t, 2, len(remotes))
3939

40-
assert.Equal(t, "upstream", remotes[0].Name)
41-
assert.Equal(t, "fork", remotes[1].Name)
40+
assert.Equal(t, "fork", remotes[0].Name)
41+
assert.Equal(t, "upstream", remotes[1].Name)
4242
}
4343

4444
func Test_remoteResolverOverride(t *testing.T) {

0 commit comments

Comments
 (0)