repo fork: tweak docs
This commit is contained in:
parent
1eefda0b45
commit
512208ca96
2 changed files with 18 additions and 15 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/context"
|
||||
"github.com/cli/cli/v2/git"
|
||||
|
|
@ -61,21 +62,23 @@ func NewCmdFork(f *cmdutil.Factory, runF func(*ForkOptions) error) *cobra.Comman
|
|||
Use: "fork [<repository>] [-- <gitflags>...]",
|
||||
Args: func(cmd *cobra.Command, args []string) error {
|
||||
if cmd.ArgsLenAtDash() == 0 && len(args[1:]) > 0 {
|
||||
return cmdutil.FlagErrorf("repository argument required when passing 'git clone' flags")
|
||||
return cmdutil.FlagErrorf("repository argument required when passing git clone flags")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Short: "Create a fork of a repository",
|
||||
Long: `Create a fork of a repository.
|
||||
Long: heredoc.Docf(`
|
||||
Create a fork of a repository.
|
||||
|
||||
With no argument, creates a fork of the current repository. Otherwise, forks
|
||||
the specified repository.
|
||||
With no argument, creates a fork of the current repository. Otherwise, forks
|
||||
the specified repository.
|
||||
|
||||
By default, the new fork is set to be your 'origin' remote and any existing
|
||||
origin remote is renamed to 'upstream'. To alter this behavior, you can set
|
||||
a name for the new fork's remote with --remote-name.
|
||||
By default, the new fork is set to be your "origin" remote and any existing
|
||||
origin remote is renamed to "upstream". To alter this behavior, you can set
|
||||
a name for the new fork's remote with %[1]s--remote-name%[1]s.
|
||||
|
||||
Additional 'git clone' flags can be passed in by listing them after '--'.`,
|
||||
Additional git clone flags can be passed after %[1]s--%[1]s.
|
||||
`, "`"),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
promptOk := opts.IO.CanPrompt()
|
||||
if len(args) > 0 {
|
||||
|
|
@ -109,14 +112,14 @@ Additional 'git clone' flags can be passed in by listing them after '--'.`,
|
|||
if err == pflag.ErrHelp {
|
||||
return err
|
||||
}
|
||||
return cmdutil.FlagErrorf("%w\nSeparate git clone flags with '--'.", err)
|
||||
return cmdutil.FlagErrorf("%w\nSeparate git clone flags with `--`.", err)
|
||||
})
|
||||
|
||||
cmd.Flags().BoolVar(&opts.Clone, "clone", false, "Clone the fork {true|false}")
|
||||
cmd.Flags().BoolVar(&opts.Remote, "remote", false, "Add remote for fork {true|false}")
|
||||
cmd.Flags().StringVar(&opts.RemoteName, "remote-name", defaultRemoteName, "Specify a name for a fork's new remote.")
|
||||
cmd.Flags().BoolVar(&opts.Clone, "clone", false, "Clone the fork")
|
||||
cmd.Flags().BoolVar(&opts.Remote, "remote", false, "Add a git remote for the fork")
|
||||
cmd.Flags().StringVar(&opts.RemoteName, "remote-name", defaultRemoteName, "Specify the name for the new remote")
|
||||
cmd.Flags().StringVar(&opts.Organization, "org", "", "Create the fork in an organization")
|
||||
cmd.Flags().StringVar(&opts.ForkName, "fork-name", "", "Specify a name for the forked repo")
|
||||
cmd.Flags().StringVar(&opts.ForkName, "fork-name", "", "Rename the forked repository")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ func TestNewCmdFork(t *testing.T) {
|
|||
name: "git args without repo",
|
||||
cli: "-- --foo bar",
|
||||
wantErr: true,
|
||||
errMsg: "repository argument required when passing 'git clone' flags",
|
||||
errMsg: "repository argument required when passing git clone flags",
|
||||
},
|
||||
{
|
||||
name: "repo",
|
||||
|
|
@ -130,7 +130,7 @@ func TestNewCmdFork(t *testing.T) {
|
|||
name: "git flags in wrong place",
|
||||
cli: "--depth 1 OWNER/REPO",
|
||||
wantErr: true,
|
||||
errMsg: "unknown flag: --depth\nSeparate git clone flags with '--'.",
|
||||
errMsg: "unknown flag: --depth\nSeparate git clone flags with `--`.",
|
||||
},
|
||||
{
|
||||
name: "with fork name",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue