Skip to content

Commit

Permalink
added URL for newly created repo (cli#8574)
Browse files Browse the repository at this point in the history
  • Loading branch information
leevic31 committed Jan 19, 2024
1 parent 32ab65f commit b8c4ea1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
15 changes: 9 additions & 6 deletions pkg/cmd/repo/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,10 @@ func createFromScratch(opts *CreateOptions) error {
isTTY := opts.IO.IsStdoutTTY()
if isTTY {
fmt.Fprintf(opts.IO.Out,
"%s Created repository %s on GitHub\n",
"%s Created repository %s on GitHub\n %s\n",
cs.SuccessIconWithColor(cs.Green),
ghrepo.FullName(repo))
ghrepo.FullName(repo),
repo.URL)
} else {
fmt.Fprintln(opts.IO.Out, repo.URL)
}
Expand Down Expand Up @@ -482,9 +483,10 @@ func createFromTemplate(opts *CreateOptions) error {

cs := opts.IO.ColorScheme()
fmt.Fprintf(opts.IO.Out,
"%s Created repository %s on GitHub\n",
"%s Created repository %s on GitHub\n %s\n",
cs.SuccessIconWithColor(cs.Green),
ghrepo.FullName(repo))
ghrepo.FullName(repo),
repo.URL)

opts.Clone, err = opts.Prompter.Confirm("Clone the new repository locally?", true)
if err != nil {
Expand Down Expand Up @@ -607,9 +609,10 @@ func createFromLocal(opts *CreateOptions) error {

if isTTY {
fmt.Fprintf(stdout,
"%s Created repository %s on GitHub\n",
"%s Created repository %s on GitHub\n %s\n",
cs.SuccessIconWithColor(cs.Green),
ghrepo.FullName(repo))
ghrepo.FullName(repo),
repo.URL)
} else {
fmt.Fprintln(stdout, repo.URL)
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/cmd/repo/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func Test_createRun(t *testing.T) {
name: "interactive create from scratch with gitignore and license",
opts: &CreateOptions{Interactive: true},
tty: true,
wantStdout: "✓ Created repository OWNER/REPO on GitHub\n",
wantStdout: "✓ Created repository OWNER/REPO on GitHub\n https://github.com/OWNER/REPO\n",
promptStubs: func(p *prompter.PrompterMock) {
p.ConfirmFunc = func(message string, defaultValue bool) (bool, error) {
switch message {
Expand Down Expand Up @@ -266,7 +266,7 @@ func Test_createRun(t *testing.T) {
name: "interactive create from scratch but with prompted owner",
opts: &CreateOptions{Interactive: true},
tty: true,
wantStdout: "✓ Created repository org1/REPO on GitHub\n",
wantStdout: "✓ Created repository org1/REPO on GitHub\n https://github.com/org1/REPO\n",
promptStubs: func(p *prompter.PrompterMock) {
p.ConfirmFunc = func(message string, defaultValue bool) (bool, error) {
switch message {
Expand Down Expand Up @@ -440,7 +440,7 @@ func Test_createRun(t *testing.T) {
cs.Register(`git -C . rev-parse --git-dir`, 0, ".git")
cs.Register(`git -C . rev-parse HEAD`, 0, "commithash")
},
wantStdout: "✓ Created repository OWNER/REPO on GitHub\n",
wantStdout: "✓ Created repository OWNER/REPO on GitHub\n https://github.com/OWNER/REPO\n",
},
{
name: "interactive with existing repository public add remote and push",
Expand Down Expand Up @@ -508,7 +508,7 @@ func Test_createRun(t *testing.T) {
cs.Register(`git -C . remote add origin https://github.com/OWNER/REPO`, 0, "")
cs.Register(`git -C . push --set-upstream origin HEAD`, 0, "")
},
wantStdout: "✓ Created repository OWNER/REPO on GitHub\n✓ Added remote https://github.com/OWNER/REPO.git\n✓ Pushed commits to https://github.com/OWNER/REPO.git\n",
wantStdout: "✓ Created repository OWNER/REPO on GitHub\n https://github.com/OWNER/REPO\n✓ Added remote https://github.com/OWNER/REPO.git\n✓ Pushed commits to https://github.com/OWNER/REPO.git\n",
},
{
name: "interactive create from a template repository",
Expand Down Expand Up @@ -585,7 +585,7 @@ func Test_createRun(t *testing.T) {
execStubs: func(cs *run.CommandStubber) {
cs.Register(`git clone --branch main https://github.com/OWNER/REPO`, 0, "")
},
wantStdout: "✓ Created repository OWNER/REPO on GitHub\n",
wantStdout: "✓ Created repository OWNER/REPO on GitHub\n https://github.com/OWNER/REPO\n",
},
{
name: "interactive create from template repo but there are no template repos",
Expand Down

0 comments on commit b8c4ea1

Please sign in to comment.