diff --git a/.goxc.json b/.goxc.json index 08cbb5bcb8ba8223d813fcbb46ca09b3ed9cade1..e23f249e0542c1a9bdc32b44855f811b4c737edd 100644 --- a/.goxc.json +++ b/.goxc.json @@ -5,7 +5,7 @@ "ResourcesInclude": "INSTALL*,README*,LICENSE*", "ResourcesExclude": "*.go", "MainDirsExclude": "Godeps", - "PackageVersion": "1.0.0", + "PackageVersion": "2.0.0", "Verbosity": "v", "TaskSettings": { "downloads-page": { diff --git a/commands/browse.go b/commands/browse.go index 0e3c947bc8e9b8ac18833df99fafa01a72130c93..db2e51e1b4e3a87d458caf1b37ea2a967cd68952 100644 --- a/commands/browse.go +++ b/commands/browse.go @@ -122,7 +122,7 @@ func parseFlagBrowseURLOnly(args *Args) bool { } func branchInURL(branch *github.Branch) string { - parts := strings.Split(strings.Replace(branch.ShortName(), ".", "/", -1), "/") + parts := strings.Split(branch.ShortName(), "/") newPath := make([]string, len(parts)) for i, s := range parts { newPath[i] = url.QueryEscape(s) diff --git a/commands/help.go b/commands/help.go index bd1f9a1cd3ab7c0c3e6224085202424d61df4e76..49ecfc967fe9e7363a87518c38d49d7901335a5f 100644 --- a/commands/help.go +++ b/commands/help.go @@ -116,7 +116,7 @@ GitHub Commands: ci-status Show the CI status of a commit See 'git help ' for more information on a specific command. -Run 'git update' to update to the latest version of gh. +Run 'git selfupdate' to update to the latest version of gh. ` func printUsage() { diff --git a/commands/update.go b/commands/selfupdate.go similarity index 75% rename from commands/update.go rename to commands/selfupdate.go index fa2e2cddfed2257d36f718b24d6ea22bc44194f4..bb9f1f1a5c4870cbae72ea25a3d9680097e5740c 100644 --- a/commands/update.go +++ b/commands/selfupdate.go @@ -5,19 +5,19 @@ import ( "os" ) -var cmdUpdate = &Command{ +var cmdSelfupdate = &Command{ Run: update, - Usage: "update", + Usage: "selfupdate", Short: "Update gh", Long: `Update gh to the latest version. Examples: - git update + git selfupdate `, } func init() { - CmdRunner.Use(cmdUpdate) + CmdRunner.Use(cmdSelfupdate) } func update(cmd *Command, args *Args) { diff --git a/commands/utils.go b/commands/utils.go index 617cf9d9b1175ce7aef64c6c8818377ab2b6b789..d61da7a0c8980f89c4fc92aaff00c8de0ad1a2e3 100644 --- a/commands/utils.go +++ b/commands/utils.go @@ -93,6 +93,10 @@ func getTitleAndBodyFromFlags(messageFlag, fileFlag string) (title, body string, func readMsg(msg string) (title, body string) { split := strings.SplitN(msg, "\n\n", 2) + if len(split) == 1 { + split = strings.SplitN(msg, "\\n\\n", 2) + } + title = strings.TrimSpace(split[0]) if len(split) > 1 { body = strings.TrimSpace(split[1]) diff --git a/commands/utils_test.go b/commands/utils_test.go index 741f745ed387f87e35ccb580369b66387fd52f67..d682e049607c5432e361ffb3eb107d01c24baa5d 100644 --- a/commands/utils_test.go +++ b/commands/utils_test.go @@ -1,12 +1,29 @@ package commands import ( - "github.com/bmizerany/assert" "io/ioutil" "os" "testing" + + "github.com/bmizerany/assert" ) +func TestGetTitleAndBodyFromFlags(t *testing.T) { + s := "just needs raven\n\nnow it works" + title, body, err := getTitleAndBodyFromFlags(s, "") + + assert.Equal(t, nil, err) + assert.Equal(t, "just needs raven", title) + assert.Equal(t, "now it works", body) + + s = "just needs raven\\n\\nnow it works" + title, body, err = getTitleAndBodyFromFlags(s, "") + + assert.Equal(t, nil, err) + assert.Equal(t, "just needs raven", title) + assert.Equal(t, "now it works", body) +} + func TestDirIsNotEmpty(t *testing.T) { dir := createTempDir(t) defer os.RemoveAll(dir) diff --git a/commands/version.go b/commands/version.go index 1c22fdf8f63c85437cb91b68c01445fbb88ac217..2b4cb501623bd029dc92075289f348248ad66068 100644 --- a/commands/version.go +++ b/commands/version.go @@ -7,7 +7,7 @@ import ( "os" ) -const Version = "1.0.0" +const Version = "2.0.0" var cmdVersion = &Command{ Run: runVersion, diff --git a/features/browse.feature b/features/browse.feature index 6f4eb0f1ac0a7f89c16f62f1dafa2283a7ed01b6..cbbfa5cf7fe1b12045f657794a4e240cc5f37726 100644 --- a/features/browse.feature +++ b/features/browse.feature @@ -107,13 +107,20 @@ Feature: hub browse Then there should be no output # Then "open https://github.com/jashkenas/coffee-script/issues" should be run - Scenario: Complex branch + Scenario: Forward Slash Delimited branch Given I am in "git://github.com/mislav/dotfiles.git" git repo And git "push.default" is set to "upstream" And I am on the "foo/bar" branch with upstream "origin/baz/qux/moo" When I successfully run `hub browse` Then "open https://github.com/mislav/dotfiles/tree/baz/qux/moo" should be run + Scenario: Dot Delimited branch + Given I am in "git://github.com/mislav/dotfiles.git" git repo + And git "push.default" is set to "upstream" + And I am on the "fix-glob-for.js" branch with upstream "origin/fix-glob-for.js" + When I successfully run `hub browse` + Then "open https://github.com/mislav/dotfiles/tree/fix-glob-for.js" should be run + Scenario: Wiki repo Given I am in "git://github.com/defunkt/hub.wiki.git" git repo When I successfully run `hub browse`