Merge remote-tracking branch 'origin' into json-format

This commit is contained in:
Mislav Marohnić 2021-04-14 18:52:34 +02:00
commit 7ec5b0f8cf
19 changed files with 128 additions and 50 deletions

View file

@ -19,10 +19,9 @@ func NewCmdActions(f *cmdutil.Factory) *cobra.Command {
}
cmd := &cobra.Command{
Use: "actions",
Short: "Learn about working with GitHub actions",
Long: actionsExplainer(nil),
Hidden: true,
Use: "actions",
Short: "Learn about working with GitHub actions",
Long: actionsExplainer(nil),
Run: func(cmd *cobra.Command, args []string) {
actionsRun(opts)
},
@ -47,7 +46,7 @@ func actionsExplainer(cs *iostreams.ColorScheme) string {
return heredoc.Docf(`
%s
gh integrates with Actions to help you manage runs and workflows.
GitHub CLI integrates with Actions to help you manage runs and workflows.
%s
gh run list: List recent workflow runs

View file

@ -7,6 +7,7 @@ import (
"sort"
"time"
"github.com/MakeNowJust/heredoc"
"github.com/cli/cli/api"
"github.com/cli/cli/context"
"github.com/cli/cli/internal/ghrepo"
@ -47,7 +48,13 @@ func NewCmdChecks(f *cmdutil.Factory, runF func(*ChecksOptions) error) *cobra.Co
cmd := &cobra.Command{
Use: "checks [<number> | <url> | <branch>]",
Short: "Show CI status for a single pull request",
Args: cobra.MaximumNArgs(1),
Long: heredoc.Doc(`
Show CI status for a single pull request.
Without an argument, the pull request that belongs to the current branch
is selected.
`),
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override
opts.BaseRepo = f.BaseRepo

View file

@ -28,6 +28,14 @@ func NewCmdComment(f *cmdutil.Factory, runF func(*shared.CommentableOptions) err
cmd := &cobra.Command{
Use: "comment [<number> | <url> | <branch>]",
Short: "Create a new pr comment",
Long: heredoc.Doc(`
Create a new pr comment.
Without an argument, the pull request that belongs to the current branch
is selected.
With '--web', comment on the pull request in a web browser instead.
`),
Example: heredoc.Doc(`
$ gh pr comment 22 --body "This looks great, lets get it deployed."
`),

View file

@ -9,6 +9,7 @@ import (
"strings"
"syscall"
"github.com/MakeNowJust/heredoc"
"github.com/cli/cli/api"
"github.com/cli/cli/context"
"github.com/cli/cli/internal/ghrepo"
@ -40,7 +41,13 @@ func NewCmdDiff(f *cmdutil.Factory, runF func(*DiffOptions) error) *cobra.Comman
cmd := &cobra.Command{
Use: "diff [<number> | <url> | <branch>]",
Short: "View changes in a pull request",
Args: cobra.MaximumNArgs(1),
Long: heredoc.Doc(`
View changes in a pull request.
Without an argument, the pull request that belongs to the current branch
is selected.
`),
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override
opts.BaseRepo = f.BaseRepo

View file

@ -50,6 +50,12 @@ func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Comman
cmd := &cobra.Command{
Use: "edit [<number> | <url> | <branch>]",
Short: "Edit a pull request",
Long: heredoc.Doc(`
Edit a pull request.
Without an argument, the pull request that belongs to the current branch
is selected.
`),
Example: heredoc.Doc(`
$ gh pr edit 23 --title "I found a bug" --body "Nothing works"
$ gh pr edit 23 --add-label "bug,help wanted" --remove-label "core"

View file

@ -70,6 +70,9 @@ func NewCmdMerge(f *cmdutil.Factory, runF func(*MergeOptions) error) *cobra.Comm
Short: "Merge a pull request",
Long: heredoc.Doc(`
Merge a pull request on GitHub.
Without an argument, the pull request that belongs to the current branch
is selected.
`),
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {

View file

@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"github.com/MakeNowJust/heredoc"
"github.com/cli/cli/api"
"github.com/cli/cli/context"
"github.com/cli/cli/internal/config"
@ -38,7 +39,13 @@ func NewCmdReady(f *cmdutil.Factory, runF func(*ReadyOptions) error) *cobra.Comm
cmd := &cobra.Command{
Use: "ready [<number> | <url> | <branch>]",
Short: "Mark a pull request as ready for review",
Args: cobra.MaximumNArgs(1),
Long: heredoc.Doc(`
Mark a pull request as ready for review
Without an argument, the pull request that belongs to the current branch
is displayed.
`),
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override
opts.BaseRepo = f.BaseRepo

View file

@ -15,7 +15,7 @@ import (
)
const (
defaultLimit = 10
defaultLimit = 20
)
type ListOptions struct {
@ -36,10 +36,9 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
}
cmd := &cobra.Command{
Use: "list",
Short: "List recent workflow runs",
Args: cobra.NoArgs,
Hidden: true,
Use: "list",
Short: "List recent workflow runs",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override
opts.BaseRepo = f.BaseRepo

View file

@ -31,7 +31,7 @@ func NewCmdRerun(f *cmdutil.Factory, runF func(*RerunOptions) error) *cobra.Comm
cmd := &cobra.Command{
Use: "rerun [<run-id>]",
Short: "Rerun a given run",
Short: "Rerun a failed run",
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override

View file

@ -12,10 +12,9 @@ import (
func NewCmdRun(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "run <command>",
Short: "View details about workflow runs",
Long: "List, view, and watch recent workflow runs from GitHub Actions.",
Hidden: true,
Use: "run <command>",
Short: "View details about workflow runs",
Long: "List, view, and watch recent workflow runs from GitHub Actions.",
Annotations: map[string]string{
"IsActions": "true",
},

View file

@ -87,25 +87,24 @@ func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Comman
}
cmd := &cobra.Command{
Use: "view [<run-id>]",
Short: "View a summary of a workflow run",
Args: cobra.MaximumNArgs(1),
Hidden: true,
Use: "view [<run-id>]",
Short: "View a summary of a workflow run",
Args: cobra.MaximumNArgs(1),
Example: heredoc.Doc(`
# Interactively select a run to view, optionally drilling down to a job
$ gh run view
# View a specific run
$ gh run view 12345
# Interactively select a run to view, optionally selecting a single job
$ gh run view
# View a specific run
$ gh run view 12345
# View a specific job within a run
$ gh run view --job 456789
# View the full log for a specific job
$ gh run view --log --job 456789
# Exit non-zero if a run failed
$ gh run view 0451 --exit-status && echo "run pending or passed"
# Exit non-zero if a run failed
$ gh run view 0451 --exit-status && echo "run pending or passed"
`),
RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override
@ -308,7 +307,7 @@ func runView(opts *ViewOptions) error {
fmt.Fprintln(out, shared.RenderRunHeader(cs, *run, utils.FuzzyAgo(ago), prNumber))
fmt.Fprintln(out)
if len(jobs) == 0 && run.Conclusion == shared.Failure {
if len(jobs) == 0 && run.Conclusion == shared.Failure || run.Conclusion == shared.StartupFailure {
fmt.Fprintf(out, "%s %s\n",
cs.FailureIcon(),
cs.Bold("This run likely failed because of a workflow file issue."))

View file

@ -771,6 +771,44 @@ func TestViewRun(t *testing.T) {
browsedURL: "jobs/10?check_suite_focus=true",
wantOut: "Opening jobs/10 in your browser.\n",
},
{
name: "hide job header, failure",
tty: true,
opts: &ViewOptions{
RunID: "123",
},
httpStubs: func(reg *httpmock.Registry) {
reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/123"),
httpmock.JSONResponse(shared.TestRun("failed no job", 123, shared.Completed, shared.Failure)))
reg.Register(
httpmock.REST("GET", "runs/123/jobs"),
httpmock.JSONResponse(shared.JobsPayload{Jobs: []shared.Job{}}))
reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/123/artifacts"),
httpmock.StringResponse(`{}`))
},
wantOut: "\nX trunk failed no job · 123\nTriggered via push about 59 minutes ago\n\nX This run likely failed because of a workflow file issue.\n\nFor more information, see: runs/123\n",
},
{
name: "hide job header, startup_failure",
tty: true,
opts: &ViewOptions{
RunID: "123",
},
httpStubs: func(reg *httpmock.Registry) {
reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/123"),
httpmock.JSONResponse(shared.TestRun("failed no job", 123, shared.Completed, shared.StartupFailure)))
reg.Register(
httpmock.REST("GET", "runs/123/jobs"),
httpmock.JSONResponse(shared.JobsPayload{Jobs: []shared.Job{}}))
reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/123/artifacts"),
httpmock.StringResponse(`{}`))
},
wantOut: "\nX trunk failed no job · 123\nTriggered via push about 59 minutes ago\n\nX This run likely failed because of a workflow file issue.\n\nFor more information, see: runs/123\n",
},
}
for _, tt := range tests {

View file

@ -7,6 +7,7 @@ import (
"runtime"
"time"
"github.com/MakeNowJust/heredoc"
"github.com/cli/cli/api"
"github.com/cli/cli/internal/ghrepo"
"github.com/cli/cli/pkg/cmd/run/shared"
@ -40,11 +41,15 @@ func NewCmdWatch(f *cmdutil.Factory, runF func(*WatchOptions) error) *cobra.Comm
}
cmd := &cobra.Command{
Use: "watch <run-selector>",
Use: "watch <run-id>",
Short: "Watch a run until it completes, showing its progress",
Annotations: map[string]string{
"IsActions": "true",
},
Example: heredoc.Doc(`
# Watch a run until it's done
gh run watch
# Run some other command when the run is finished
gh run watch && notify-send "run is done!"
`),
RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override
opts.BaseRepo = f.BaseRepo

View file

@ -29,8 +29,9 @@ func NewCmdDisable(f *cmdutil.Factory, runF func(*DisableOptions) error) *cobra.
}
cmd := &cobra.Command{
Use: "disable [<workflow ID> | <workflow name>]",
Use: "disable [<workflow-id> | <workflow-name>]",
Short: "Disable a workflow",
Long: "Disable a workflow, preventing it from running or showing up when listing workflows.",
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override

View file

@ -29,8 +29,9 @@ func NewCmdEnable(f *cmdutil.Factory, runF func(*EnableOptions) error) *cobra.Co
}
cmd := &cobra.Command{
Use: "enable [<workflow ID> | <workflow name>]",
Use: "enable [<workflow-id> | <workflow-name>]",
Short: "Enable a workflow",
Long: "Enable a workflow, allowing it to be run and show up when listing workflows.",
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override

View file

@ -34,7 +34,8 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
cmd := &cobra.Command{
Use: "list",
Short: "List GitHub Actions workflows",
Short: "List workflows",
Long: "List workflow files, hiding disabled workflows by default.",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override

View file

@ -46,8 +46,8 @@ func NewCmdRun(f *cmdutil.Factory, runF func(*RunOptions) error) *cobra.Command
}
cmd := &cobra.Command{
Use: "run [<workflow-ID> | <workflow-name>]",
Short: "Create a dispatch event for a workflow, starting a run",
Use: "run [<workflow-id> | <workflow-name>]",
Short: "Run a workflow by creating a workflow_dispatch event",
Long: heredoc.Doc(`
Create a workflow_dispatch event for a given workflow.

View file

@ -40,10 +40,9 @@ func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Comman
}
cmd := &cobra.Command{
Use: "view [<workflow-id> | <workflow name> | <file name>]",
Short: "View the summary of a workflow",
Args: cobra.MaximumNArgs(1),
Hidden: true,
Use: "view [<workflow-id> | <workflow-name> | <filename>]",
Short: "View the summary of a workflow",
Args: cobra.MaximumNArgs(1),
Example: heredoc.Doc(`
# Interactively select a workflow to view
$ gh workflow view

View file

@ -12,10 +12,9 @@ import (
func NewCmdWorkflow(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "workflow <command>",
Short: "View details about GitHub Actions workflows",
Long: "List, view, and run workflows in GitHub Actions.",
Hidden: true,
Use: "workflow <command>",
Short: "View details about GitHub Actions workflows",
Long: "List, view, and run workflows in GitHub Actions.",
Annotations: map[string]string{
"IsActions": "true",
},