зеркало из https://github.com/mislav/hub.git
Fix exception when having no args for cherry-pick
https://github.com/jingweno/gh/issues/223
This commit is contained in:
Родитель
9694397a1d
Коммит
8e340bd0eb
|
@ -43,6 +43,10 @@ func cherryPick(command *Command, args *Args) {
|
|||
}
|
||||
|
||||
func transformCherryPickArgs(args *Args) {
|
||||
if args.IsParamsEmpty() {
|
||||
return
|
||||
}
|
||||
|
||||
ref := args.LastParam()
|
||||
project, sha := parseCherryPickProjectAndSha(ref)
|
||||
if project != nil {
|
||||
|
|
|
@ -33,11 +33,17 @@ func TestTransformCherryPickArgs(t *testing.T) {
|
|||
testConfigs := fixtures.SetupTestConfigs()
|
||||
defer testConfigs.TearDown()
|
||||
|
||||
args := NewArgs([]string{})
|
||||
transformCherryPickArgs(args)
|
||||
cmds := args.Commands()
|
||||
assert.Equal(t, 1, len(cmds))
|
||||
|
||||
os.Setenv("HUB_PROTOCOL", "git")
|
||||
args := NewArgs([]string{"cherry-pick", "https://github.com/jingweno/gh/commit/a319d88#comments"})
|
||||
defer os.Setenv("HUB_PROTOCOL", "")
|
||||
args = NewArgs([]string{"cherry-pick", "https://github.com/jingweno/gh/commit/a319d88#comments"})
|
||||
transformCherryPickArgs(args)
|
||||
|
||||
cmds := args.Commands()
|
||||
cmds = args.Commands()
|
||||
assert.Equal(t, 2, len(cmds))
|
||||
assert.Equal(t, "git remote add -f jingweno git://github.com/jingweno/gh.git", cmds[0].String())
|
||||
assert.Equal(t, "git cherry-pick a319d88", cmds[1].String())
|
||||
|
|
Загрузка…
Ссылка в новой задаче