Skip to content

Commit a5fa422

Browse files
committed
consistently use 'origin' over 'base' or 'remote'
1 parent c3e56f7 commit a5fa422

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/gui/controllers/remotes_controller.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,19 @@ var urlRegex = regexp.MustCompile(`^(git@[^:]+:|ssh://[^/]+/|https?://[^/]+/)([^
220220

221221
// Rewrites a Git remote URL to use the given fork username,
222222
// keeping the repo name and host intact. Supports SCP-like SSH, SSH URL style, and HTTPS.
223-
func replaceForkUsername(remoteUrl, forkUsername string) (string, error) {
223+
func replaceForkUsername(originUrl, forkUsername string) (string, error) {
224224
if forkUsername == "" {
225225
return "", errors.New("fork username cannot be empty")
226226
}
227-
if remoteUrl == "" {
227+
if originUrl == "" {
228228
return "", errors.New("remote URL cannot be empty")
229229
}
230230

231-
if urlRegex.MatchString(remoteUrl) {
232-
return urlRegex.ReplaceAllString(remoteUrl, "${1}"+forkUsername+"/$3$4"), nil
231+
if urlRegex.MatchString(originUrl) {
232+
return urlRegex.ReplaceAllString(originUrl, "${1}"+forkUsername+"/$3$4"), nil
233233
}
234234

235-
return "", fmt.Errorf("unsupported or invalid remote URL: %s", remoteUrl)
235+
return "", fmt.Errorf("unsupported or invalid remote URL: %s", originUrl)
236236
}
237237

238238
func (self *RemotesController) getOrigin() *models.Remote {
@@ -255,7 +255,7 @@ func (self *RemotesController) hasOriginRemote() func() *types.DisabledReason {
255255
}
256256

257257
func (self *RemotesController) addFork() error {
258-
baseRemote := self.getOrigin()
258+
origin := self.getOrigin()
259259

260260
self.c.Prompt(types.PromptOpts{
261261
Title: self.c.Tr.AddForkRemoteUsername,
@@ -267,8 +267,8 @@ func (self *RemotesController) addFork() error {
267267
forkUsername = parts[0]
268268
branchToCheckout = parts[1]
269269
}
270-
baseUrl := baseRemote.Urls[0]
271-
remoteUrl, err := replaceForkUsername(baseUrl, forkUsername)
270+
originUrl := origin.Urls[0]
271+
remoteUrl, err := replaceForkUsername(originUrl, forkUsername)
272272
if err != nil {
273273
return err
274274
}

0 commit comments

Comments
 (0)