added URL for newly created repo (#8574)

This commit is contained in:
Victor Lee 2024-01-19 06:16:15 -05:00 committed by GitHub
parent 32ab65fd77
commit b8c4ea1e7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 11 deletions

View file

@ -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)
}
@ -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 {
@ -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)
}

View file

@ -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 {
@ -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 {
@ -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",
@ -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",
@ -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",