Skip to content

Commit c9e8dec

Browse files
committed
rm fetch from link
1 parent f6b4a15 commit c9e8dec

2 files changed

Lines changed: 0 additions & 61 deletions

File tree

cmd/link.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,6 @@ func pushBranchArgs(cfg *config.Config, opts *linkOptions, args []string) error
161161
return ErrSilent
162162
}
163163

164-
// Best-effort fetch to update tracking refs (helps --force-with-lease
165-
// in shallow clones). Silently ignored if branches don't exist on the
166-
// remote yet.
167-
_ = git.FetchBranches(remote, branches)
168-
169164
cfg.Printf("Pushing %d %s to %s...", len(branches), plural(len(branches), "branch", "branches"), remote)
170165
if err := git.Push(remote, branches, false, true); err != nil {
171166
cfg.Errorf("failed to push branches: %s", err)

cmd/link_test.go

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,59 +1096,3 @@ func TestLink_SkipsBaseFix_ForNewlyCreatedPRs(t *testing.T) {
10961096

10971097
// Silence "imported and not used" for fmt in case test helpers use it.
10981098
var _ = fmt.Sprintf
1099-
1100-
func TestLink_FetchesBeforePush(t *testing.T) {
1101-
var callOrder []string
1102-
var fetchedBranches []string
1103-
1104-
mock := newLinkGitMock("feat-a", "feat-b")
1105-
mock.FetchBranchesFn = func(remote string, branches []string) error {
1106-
callOrder = append(callOrder, "fetch")
1107-
fetchedBranches = branches
1108-
assert.Equal(t, "origin", remote)
1109-
return nil
1110-
}
1111-
mock.PushFn = func(remote string, branches []string, force, atomic bool) error {
1112-
callOrder = append(callOrder, "push")
1113-
return nil
1114-
}
1115-
1116-
restore := git.SetOps(mock)
1117-
defer restore()
1118-
1119-
prNum := 0
1120-
cfg, _, errR := config.NewTestConfig()
1121-
cfg.GitHubClientOverride = &github.MockClient{
1122-
FindPRForBranchFn: func(branch string) (*github.PullRequest, error) {
1123-
prNum++
1124-
return &github.PullRequest{
1125-
Number: prNum,
1126-
URL: fmt.Sprintf("https://github.com/o/r/pull/%d", prNum),
1127-
BaseRefName: "main",
1128-
HeadRefName: branch,
1129-
State: "OPEN",
1130-
}, nil
1131-
},
1132-
ListStacksFn: func() ([]github.RemoteStack, error) {
1133-
return []github.RemoteStack{}, nil
1134-
},
1135-
CreateStackFn: func(prNumbers []int) (int, error) {
1136-
return 42, nil
1137-
},
1138-
}
1139-
1140-
cmd := LinkCmd(cfg)
1141-
cmd.SetArgs([]string{"feat-a", "feat-b"})
1142-
cmd.SetOut(io.Discard)
1143-
cmd.SetErr(io.Discard)
1144-
err := cmd.Execute()
1145-
1146-
cfg.Err.Close()
1147-
_, _ = io.ReadAll(errR)
1148-
1149-
assert.NoError(t, err)
1150-
assert.Equal(t, []string{"feat-a", "feat-b"}, fetchedBranches, "should fetch pushed branches")
1151-
require.Len(t, callOrder, 2)
1152-
assert.Equal(t, "fetch", callOrder[0], "fetch must happen before push")
1153-
assert.Equal(t, "push", callOrder[1])
1154-
}

0 commit comments

Comments
 (0)