Skip to content

Commit a675f6b

Browse files
committed
fixup! feat: add fork remote command
Inline addRemoteAndRefresh and selectRemoteAndCheckout into addAndCheckoutRemote. It's not worth having them as separate helper functions since they are only called from within addAndCheckoutRemote, and that function is not overly long. This fixes two issues: - selectRemoteAndCheckout had an unused parameter remoteUrl - the error return value from addRemoteAndRefresh was not checked
1 parent cdaea54 commit a675f6b

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

pkg/gui/controllers/remotes_controller.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ func (self *RemotesController) enter(remote *models.Remote) error {
143143
return nil
144144
}
145145

146-
// Adds a new remote and refreshes the list of remotes.
147-
func (self *RemotesController) addRemoteAndRefresh(remoteName string, remoteUrl string) error {
146+
// Adds a new remote, refreshes and selects it, then fetches and checks out the specified branch if provided.
147+
func (self *RemotesController) addAndCheckoutRemote(remoteName string, remoteUrl string, branchToCheckout string) error {
148148
self.c.LogAction(self.c.Tr.Actions.AddRemote)
149149
err := self.c.Git().Remote.AddRemote(remoteName, remoteUrl)
150150
if err != nil {
@@ -158,11 +158,7 @@ func (self *RemotesController) addRemoteAndRefresh(remoteName string, remoteUrl
158158
Scope: []types.RefreshableView{types.REMOTES},
159159
Mode: types.SYNC,
160160
})
161-
return nil
162-
}
163161

164-
// Selects the given remote in the UI, fetches it, and checks out the specified branch if profided.
165-
func (self *RemotesController) selectRemoteAndCheckout(remoteName string, remoteUrl string, branchToCheckout string) error {
166162
// Select the remote
167163
for idx, remote := range self.c.Model().Remotes {
168164
if remote.Name == remoteName {
@@ -175,13 +171,6 @@ func (self *RemotesController) selectRemoteAndCheckout(remoteName string, remote
175171
return self.fetchAndCheckout(self.c.Contexts().Remotes.GetSelected(), branchToCheckout)
176172
}
177173

178-
// Adds a new remote, refreshes and selects it, then fetches and checks out the specified branch if provided.
179-
func (self *RemotesController) addAndCheckoutRemote(remoteName string, remoteUrl string, branchToCheckout string) error {
180-
self.addRemoteAndRefresh(remoteName, remoteUrl)
181-
182-
return self.selectRemoteAndCheckout(remoteName, remoteUrl, branchToCheckout)
183-
}
184-
185174
// Ensures the fork remote exists (matching the given URL).
186175
// If it exists and matches, it’s selected and fetched; otherwise, it’s created and then fetched and checked out.
187176
// If it does exist but with a different URL, an error is returned.

0 commit comments

Comments
 (0)