Skip to content

Commit 1550662

Browse files
committed
fixup! feat: add fork remote command
Remove unnecessary error checks: - forkUsername needn't be checked because as of PR #5043, the result of a Prompt call can no longer be an empty string - if the originUrl is empty for some reason, this will be caught by the "unsupported or invalid remote URL" error check below, which is good enough for this very unlikely case.
1 parent c05c7d5 commit 1550662

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

pkg/gui/controllers/remotes_controller.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,6 @@ var urlRegex = regexp.MustCompile(`^(git@[^:]+:|ssh://[^/]+/|https?://[^/]+/)([^
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.
223223
func replaceForkUsername(originUrl, forkUsername string) (string, error) {
224-
if forkUsername == "" {
225-
return "", errors.New("fork username cannot be empty")
226-
}
227-
if originUrl == "" {
228-
return "", errors.New("remote URL cannot be empty")
229-
}
230-
231224
if urlRegex.MatchString(originUrl) {
232225
return urlRegex.ReplaceAllString(originUrl, "${1}"+forkUsername+"/$3$4"), nil
233226
}

pkg/gui/controllers/remotes_controller_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ func TestReplaceForkUsername_Errors(t *testing.T) {
108108
in string
109109
forkUser string
110110
}{
111-
{
112-
name: "empty fork user",
113-
in: "git@github.com:old/repo.git",
114-
forkUser: "",
115-
},
116111
{
117112
name: "https host only",
118113
in: "https://github.com",
@@ -143,6 +138,11 @@ func TestReplaceForkUsername_Errors(t *testing.T) {
143138
in: "ftp://github.com/old/repo.git",
144139
forkUser: "x",
145140
},
141+
{
142+
name: "empty url",
143+
in: "",
144+
forkUser: "x",
145+
},
146146
}
147147

148148
for _, c := range cases {

0 commit comments

Comments
 (0)