Fix exception when having no args for cherry-pick

https://github.com/jingweno/gh/issues/223
This commit is contained in:
Owen Ou 2014-10-16 11:55:08 -07:00
Родитель 9694397a1d
Коммит 8e340bd0eb
2 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -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())