Skip to content

Commit 9c4afca

Browse files
committed
Merge remote-tracking branch 'origin' into artifact-download
2 parents b41681c + 216cfb6 commit 9c4afca

File tree

19 files changed

+826
-754
lines changed

19 files changed

+826
-754
lines changed

cmd/gh/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/cli/cli/internal/build"
1919
"github.com/cli/cli/internal/config"
2020
"github.com/cli/cli/internal/ghinstance"
21+
"github.com/cli/cli/internal/ghrepo"
2122
"github.com/cli/cli/internal/run"
2223
"github.com/cli/cli/internal/update"
2324
"github.com/cli/cli/pkg/cmd/alias/expand"
@@ -100,6 +101,11 @@ func mainRun() exitCode {
100101
cmdFactory.IOStreams.SetPager(pager)
101102
}
102103

104+
// TODO: remove after FromFullName has been revisited
105+
if host, err := cfg.DefaultHost(); err == nil {
106+
ghrepo.SetDefaultHost(host)
107+
}
108+
103109
expandedArgs := []string{}
104110
if len(os.Args) > 0 {
105111
expandedArgs = os.Args[1:]

internal/ghrepo/repo.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ func FullName(r Interface) string {
3535
return fmt.Sprintf("%s/%s", r.RepoOwner(), r.RepoName())
3636
}
3737

38+
var defaultHostOverride string
39+
40+
func defaultHost() string {
41+
if defaultHostOverride != "" {
42+
return defaultHostOverride
43+
}
44+
return ghinstance.Default()
45+
}
46+
47+
// SetDefaultHost overrides the default GitHub hostname for FromFullName.
48+
// TODO: remove after FromFullName approach is revisited
49+
func SetDefaultHost(host string) {
50+
defaultHostOverride = host
51+
}
52+
3853
// FromFullName extracts the GitHub repository information from the following
3954
// formats: "OWNER/REPO", "HOST/OWNER/REPO", and a full URL.
4055
func FromFullName(nwo string) (Interface, error) {
@@ -54,9 +69,9 @@ func FromFullName(nwo string) (Interface, error) {
5469
}
5570
switch len(parts) {
5671
case 3:
57-
return NewWithHost(parts[1], parts[2], normalizeHostname(parts[0])), nil
72+
return NewWithHost(parts[1], parts[2], parts[0]), nil
5873
case 2:
59-
return New(parts[0], parts[1]), nil
74+
return NewWithHost(parts[0], parts[1], defaultHost()), nil
6075
default:
6176
return nil, fmt.Errorf(`expected the "[HOST/]OWNER/REPO" format, got %q`, nwo)
6277
}

internal/ghrepo/repo_test.go

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,13 @@ func Test_repoFromURL(t *testing.T) {
117117

118118
func TestFromFullName(t *testing.T) {
119119
tests := []struct {
120-
name string
121-
input string
122-
wantOwner string
123-
wantName string
124-
wantHost string
125-
wantErr error
120+
name string
121+
input string
122+
hostOverride string
123+
wantOwner string
124+
wantName string
125+
wantHost string
126+
wantErr error
126127
}{
127128
{
128129
name: "OWNER/REPO combo",
@@ -171,9 +172,30 @@ func TestFromFullName(t *testing.T) {
171172
wantName: "REPO",
172173
wantErr: nil,
173174
},
175+
{
176+
name: "OWNER/REPO with default host override",
177+
input: "OWNER/REPO",
178+
hostOverride: "override.com",
179+
wantHost: "override.com",
180+
wantOwner: "OWNER",
181+
wantName: "REPO",
182+
wantErr: nil,
183+
},
184+
{
185+
name: "HOST/OWNER/REPO with default host override",
186+
input: "example.com/OWNER/REPO",
187+
hostOverride: "override.com",
188+
wantHost: "example.com",
189+
wantOwner: "OWNER",
190+
wantName: "REPO",
191+
wantErr: nil,
192+
},
174193
}
175194
for _, tt := range tests {
176195
t.Run(tt.name, func(t *testing.T) {
196+
if tt.hostOverride != "" {
197+
SetDefaultHost(tt.hostOverride)
198+
}
177199
r, err := FromFullName(tt.input)
178200
if tt.wantErr != nil {
179201
if err == nil {

pkg/cmd/actions/actions.go

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ func NewCmdActions(f *cmdutil.Factory) *cobra.Command {
2626
Run: func(cmd *cobra.Command, args []string) {
2727
actionsRun(opts)
2828
},
29+
Annotations: map[string]string{
30+
"IsActions": "true",
31+
},
2932
}
3033

3134
return cmd
@@ -43,34 +46,16 @@ func actionsRun(opts ActionsOptions) {
4346
4447
%s
4548
gh run list: List recent workflow runs
46-
gh run view: View details for a given workflow run
47-
48-
%s
49-
gh job view: View details for a given job
50-
`,
51-
cs.Bold("Working with runs"),
52-
cs.Bold("Working with jobs within runs")))
53-
/*
54-
fmt.Fprint(opts.IO.Out, heredoc.Docf(`
55-
Welcome to GitHub Actions on the command line.
56-
57-
%s
58-
gh workflow list: List workflows in the current repository
59-
gh workflow run: Kick off a workflow run
60-
gh workflow init: Create a new workflow
61-
gh workflow check: Check a workflow file for correctness
62-
63-
%s
64-
gh run list: List recent workflow runs
65-
gh run view: View details for a given workflow run
66-
gh run watch: Watch a streaming log for a workflow run
49+
gh run view: View details for a workflow run or one of its jobs
50+
gh run watch: Watch a workflow run while it executes
51+
gh run rerun: Rerun a failed workflow run
6752
6853
%s
69-
gh job view: View details for a given job
70-
gh job run: Run a given job within a workflow
54+
gh workflow list: List all the workflow files in your repository
55+
gh workflow enable: Enable a workflow file
56+
gh workflow disable: Disable a workflow file
57+
gh workflow run: Trigger a workflow_dispatch run for a workflow file
7158
`,
72-
cs.Bold("Working with workflows"),
73-
cs.Bold("Working with runs"),
74-
cs.Bold("Working with jobs within runs")))
75-
*/
59+
cs.Bold("Interacting with workflow runs"),
60+
cs.Bold("Interacting with workflow files")))
7661
}

pkg/cmd/job/job.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

pkg/cmd/job/view/http.go

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)