Граф коммитов

53 Коммитов

Автор SHA1 Сообщение Дата
Mislav Marohnić 3edbd86fab
Merge pull request #2218 from tpope/empty-alias-error
Fix error message on hub --paginate
2019-08-19 15:41:56 +02:00
Tim Pope cf4772eed0 Fix error message on hub --paginate
Calling hub with one or more options but no subcommand resulted in the
following error message trying to expand an empty string as an alias:

	error: key does not contain variable name: alias.

This fixes the root cause: attempting to retrieve an invalid config key.
2019-08-03 18:25:56 -04:00
Christian Muehlhaeuser f0c3ce9fb3
Simplify code
- Use bytes.Equal instead of bytes.Compare
- Use time.Since instead of manual timestamp subtracting
- Use sort.Strings instead of sort.StringSlice
- No need to specify the len of the slice
2019-07-23 09:28:32 +02:00
Mislav Marohnić 4412eddff1 Fix compatibility with git when run with no arguments
Fixes this error:

    $ hub --git-dir=.git
    git: '' is not a git command. See 'git --help'.

Instead, help text is shown just like with normal git.
2019-03-28 23:55:24 +01:00
Mislav Marohnić c0db6e6f0c Use ArgsParser for commands that don't declare flags via pflag 2019-01-18 01:50:28 +01:00
Mislav Marohnić f1771054ca Fix tests broken by `--list-cmds` hacks 2018-07-07 13:35:00 +02:00
Mislav Marohnić d7ef572416 Fix integration with git 2.18 shell completions
Wrap `git --list-cmds=others` command used by git built-in shell
completions to add a list of hub custom commands.

Fixes #1792
2018-07-07 12:38:02 +02:00
Mislav Marohnić c6425bfc38 Fix `git --(exec|html|man|info)-path`
When any of these global flags are passed, don't try to decorate the
output as if `git help` was invoked.

Fixes https://github.com/github/hub/issues/1446
2017-06-26 20:22:11 +02:00
Mislav Marohnić d400838ecf Remove obsolete self-updating functionality
We might bring back the self-updater at some point, but right now it's
dead code and it's not clear to me how to implement it in a fashion
where it also updates dependent files such as shell completion scripts
and man pages.
2016-12-05 22:07:31 +01:00
Goel 3792b5e7f9 Do not expand aliases which are in-built git and hub commands 2016-11-07 14:30:45 +01:00
Mislav Marohnić ce24b1cf7e New `hub sync` command to update local branches
Ported from my bash version over at
370154a5ad/bin/git-sync
2016-09-12 06:29:53 +02:00
Mislav Marohnić 0c4689c673 Fix printing content on Windows after successful run
The old `args.After("echo", ...)` approach won't cut it on Windows since
there is no `echo` executable. Thus, nothing was printed on Windows.

Instead, expand Args type with extra functionality that allows Go
callbacks after all commands in the chain have been run.

Also, the new `args.NoForward()` is now preferred to `os.Exit()` since
it's more descriptive and allows `defer` in the calling function.
2016-09-10 23:49:58 +02:00
Mislav Marohnić f507de0596 Show error to stderr if shelling out failed
If shelling out to nonexistent command, such as `echo` on Windows, print
the error on stderr instead of failing silently. This is also helpful
when hub tries to forward a command to `git`, but git is not installed.
2016-09-10 23:08:48 +02:00
Mislav Marohnić 8dcd2a463f Exit with status "1" when `hub` is run without arguments
This mimics `git` behavior.
2016-01-25 02:30:47 +11:00
Mislav Marohnić 21089ec0e4 Change `hub help` to display man pages when available
Instead of displaying plain text help, `hub help <command>` will now
search for man pages to display.

* If `man` is available, hub first tries to locate the local
  `../man/hub-<command>.1` file relative to the `hub` executable. If
  found, open it with `man`. If not, execute `man 1 hub-<command>`.

* Otherwise, resort to displaying plain text help.
2016-01-25 02:30:47 +11:00
Mislav Marohnić 1b862e3388 Switch from godep & rewriting import paths to GO15VENDOREXPERIMENT 2016-01-20 14:46:44 +11:00
Mislav Marohnić c83a4488fb Make `--help`/`--version` explicit aliases for `help`/`version`
Before, the argument parser would translate `--help` and `--version` to
their equivalents without the dashes. Now it's not the parser's
responsibility to do that anymore. Instead, wire them up as subcommand
aliases in the runner.
2015-07-08 11:33:58 -07:00
Jingwen Owen Ou 177640dbd4 Extract logic of printing out to console
Introduce a `console` package which encapsulates logic of printing out
to console. This provides flexibility of discarding output in tests.
It also allows us to unify format of printing to console (if we want to).

This fixes #801.
2015-02-20 13:19:24 -08:00
Jingwen Owen Ou 2699a6b718 Parse more global flags from by following https://github.com/github/hub/blob/1.12-stable/lib/hub/commands.rb#L961-L995 2015-01-14 09:34:04 -08:00
Jingwen Owen Ou 15be76697c Preserve global config flags specified with `-c` 2015-01-12 22:13:08 -08:00
Jingwen Owen Ou 0270835a07 Don’t shell out commands in Go tests
The changes in 0ed14758b7 mess up `go test`’s exit code since it executes test commands with exec(3) - `go test` always return 0. We need to stop shelling out commands in tests.
2014-12-22 08:34:57 -08:00
Jingwen Owen Ou 0ed14758b7 Use `Exec` except Windows for the last command run in the commands chain
This is to avoid the interrupt/pagination issues like https://github.com/github/hub/issues/708. Note that `exec(3)` is not available on Windows: http://golang.org/src/pkg/syscall/exec_windows.go#L339. A fall to `spawn(3)` is used in this case.
2014-11-30 12:14:18 -08:00
Jingwen Owen Ou 8cd1ba849d Rename `Cmd.Exec` to `Cmd.Spawn`
This is to `spawn` a process not to `exec` one
2014-11-30 11:15:13 -08:00
Jingwen Owen Ou 6137851f15 Vendor dependencies by rewriting import paths 2014-11-30 09:16:57 -08:00
Jingwen Owen Ou 82dedbf6a0 Slurp `--noop` during parsing of args 2014-04-08 07:23:01 -07:00
Jingwen Owen Ou 408876e9bd Use octokit/go-octokit instead of jingweno/go-octokit 2014-02-21 09:08:34 -08:00
Jingwen Owen Ou 498789a999 Change namespace to github/hub 2014-02-10 08:29:03 -08:00
David Calavera 4fb7042963 Set usage function for subcommands. 2013-12-29 19:20:41 -08:00
David Calavera 109fb85818 Use a POSIX compatible flag parser.
So we can use flags before and after arguments, and we can group boolean flags, just like git does.
2013-12-29 15:07:58 -08:00
David Calavera 6b14c4a7e5 Do not parse the argument for git extensions. 2013-12-29 14:44:09 -08:00
David Calavera 371ae8b432 Add global commands to the runner.
- Use a hash to lookup for commands.
- Add more tests for the command and runner execution.
2013-12-29 14:18:14 -08:00
David Calavera 51428d5449 Allow to chain subcommands using `command.Use(subcommandName, subcommand)`. 2013-12-28 21:24:08 -08:00
Jingwen Owen Ou 334d8ab2b7 Only split alias command if it doesn't start with ! 2013-12-28 19:17:21 -08:00
Jingwen Owen Ou 8f797c11fd Only prompt for update if there's a new release
Reference: https://github.com/jingweno/gh/pull/128#issuecomment-30971747
2013-12-19 14:44:58 -08:00
Jingwen Owen Ou 4dfb4c58db Automatically prompt for update 2013-12-19 13:40:36 -08:00
Jingwen Owen Ou d9429d55f2 Fix alias bug that doesn't expand command 2013-12-04 07:08:52 -08:00
Jingwen Owen Ou 6d5397ba48 Remove unnecessary rename of package 2013-10-23 14:39:37 -07:00
Jingwen Owen Ou b0ec2212e5 Return from runner for help 2013-09-23 16:26:32 -07:00
Jingwen Owen Ou 76b2ca00ee Use noop flag instead of no-op 2013-09-22 17:55:30 -07:00
Jingwen Owen Ou fa8f2c95a7 Spawning processes to run git commands; Exec(1) doesn't work on Windows... 2013-09-22 17:51:37 -07:00
Jingwen Owen Ou c980c10c1e Revert "Remove sysexec since Windows doesn't support it…:-("
This reverts commit d527efb3f83de97c111dd2a2867e72aaa4cd5678.
2013-09-21 07:33:22 -07:00
Jingwen Owen Ou e0b66f06db Remove sysexec since Windows doesn't support it…:-( 2013-09-20 15:13:11 -07:00
Jingwen Owen Ou 1eb87b822b Respect git alias 2013-08-16 07:16:59 -07:00
Jingwen Owen Ou 6e559d86d2 Don't return error if it's ErrHelp 2013-07-18 15:09:15 -07:00
Jingwen Owen Ou 8c3c848ddf Slurp global flags 2013-07-05 13:48:22 -07:00
Jingwen Owen Ou 61bbf079a8 Fix all comands to aware of noop 2013-07-05 13:45:22 -07:00
Jingwen Owen Ou 87430090a9 Enable noop 2013-07-05 11:10:24 -07:00
Jingwen Owen Ou 2801e65e2a Use passin args 2013-07-03 21:36:04 -07:00
Jingwen Owen Ou e3d6319fa5 Rename to Args#Params 2013-07-02 11:56:45 -07:00
Jingwen Owen Ou 13240c7021 Implement merge 2013-07-02 11:28:50 -07:00