diff --git a/commands/help.go b/commands/help.go index a89712a832a17a42b41cb17fde6de32ede78fd2e..b771000c9a89ede8825f2a816ad8201e4d223944 100644 --- a/commands/help.go +++ b/commands/help.go @@ -5,6 +5,9 @@ import ( "os" "sort" "strings" + + "github.com/github/hub/git" + "github.com/github/hub/utils" ) var cmdHelp = &Command{ @@ -52,45 +55,9 @@ func customCommands() []string { return cmds } -var helpText = `usage: git [--version] [--exec-path[=]] [--html-path] [--man-path] [--info-path] - [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] - [--git-dir=] [--work-tree=] [--namespace=] - [-c name=value] [--help] - [] - -Basic Commands: - init Create an empty git repository or reinitialize an existing one - add Add new or modified files to the staging area - rm Remove files from the working directory and staging area - mv Move or rename a file, a directory, or a symlink - status Show the status of the working directory and staging area - commit Record changes to the repository - -History Commands: - log Show the commit history log - diff Show changes between commits, commit and working tree, etc - show Show information about commits, tags or files - -Branching Commands: - branch List, create, or delete branches - checkout Switch the active branch to another branch - merge Join two or more development histories (branches) together - tag Create, list, delete, sign or verify a tag object +var helpText = ` +These GitHub commands are provided by hub: -Remote Commands: - clone Clone a remote repository into a new directory - fetch Download data, tags and branches from a remote repository - pull Fetch from and merge with another repository or a local branch - push Upload data, tags and branches to a remote repository - remote View and manage a set of remote repositories - -Advanced Commands: - reset Reset your staging area or working directory to another point - rebase Re-apply a series of patches in one branch onto another - bisect Find by binary search the change that introduced a bug - grep Print files with lines matching a pattern in your codebase - -GitHub Commands: pull-request Open a pull request on GitHub fork Make a fork of a remote repository on GitHub and add as remote create Create this repository on GitHub and add GitHub as origin @@ -99,10 +66,10 @@ GitHub Commands: release List or create releases (beta) issue List or create issues (beta) ci-status Show the CI status of a commit - -See 'git help ' for more information on a specific command. ` func printUsage() { + err := git.ForwardGitHelp() + utils.Check(err) fmt.Print(helpText) } diff --git a/features/help.feature b/features/help.feature new file mode 100644 index 0000000000000000000000000000000000000000..d052424fe6b1affe68fb9269a90cbdf81e84b065 --- /dev/null +++ b/features/help.feature @@ -0,0 +1,14 @@ +Feature: hub help + Scenario: Appends hub help to regular help text + When I successfully run `hub help` + Then the output should contain: + """ + These GitHub commands are provided by hub: + + pull-request Open a pull request on GitHub + """ + And the output should contain "usage: git " + + Scenario: Appends hub commands to `--all` output + When I successfully run `hub help -a` + Then the output should contain "pull-request" diff --git a/git/git.go b/git/git.go index 230dba24355c7fdf054d5a57cd68d0c7aca76776..aed8e7b8e161bb03579e93018c184d4cfcfad30b 100644 --- a/git/git.go +++ b/git/git.go @@ -277,3 +277,9 @@ func gitOutput(input ...string) (outputs []string, err error) { return outputs, err } + +func ForwardGitHelp() error { + cmd := cmd.New("git") + cmd.WithArgs("help") + return cmd.Spawn() +}