Skip to content

Commit a633539

Browse files
committed
repo fork: simplify printing the name of an existing forked repo
1 parent bc3f964 commit a633539

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

command/repo.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,6 @@ func repoFork(cmd *cobra.Command, args []string) error {
301301
s.FinalMSG = utils.Gray(fmt.Sprintf("- %s\n", loading))
302302
s.Start()
303303

304-
authLogin, err := ctx.AuthLogin()
305-
if err != nil {
306-
s.Stop()
307-
return fmt.Errorf("could not determine current username: %w", err)
308-
}
309-
310-
possibleFork := ghrepo.New(authLogin, toFork.RepoName())
311-
312304
forkedRepo, err := api.ForkRepo(apiClient, toFork)
313305
if err != nil {
314306
s.Stop()
@@ -325,7 +317,7 @@ func repoFork(cmd *cobra.Command, args []string) error {
325317
if created_ago > time.Minute {
326318
fmt.Fprintf(out, "%s %s %s\n",
327319
utils.Yellow("!"),
328-
utils.Bold(ghrepo.FullName(possibleFork)),
320+
utils.Bold(ghrepo.FullName(forkedRepo)),
329321
"already exists")
330322
} else {
331323
fmt.Fprintf(out, "%s Created fork %s\n", greenCheck, utils.Bold(ghrepo.FullName(forkedRepo)))

command/repo_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ import (
1818
func TestRepoFork_already_forked(t *testing.T) {
1919
initContext = func() context.Context {
2020
ctx := context.NewBlank()
21-
ctx.SetBaseRepo("REPO")
21+
ctx.SetBaseRepo("OWNER/REPO")
2222
ctx.SetBranch("master")
23-
ctx.SetAuthLogin("someone")
2423
ctx.SetRemotes(map[string]string{
2524
"origin": "OWNER/REPO",
2625
})

0 commit comments

Comments
 (0)