diff --git a/commands/compare.go b/commands/compare.go index dfb23bb49340d0ffa578653d6c3ec594e8617ab0..803e203df8e42b2027a2587b2903564d0b5769af 100644 --- a/commands/compare.go +++ b/commands/compare.go @@ -89,6 +89,11 @@ func compare(command *Command, args *Args) { } } + if project == nil { + project, err = localRepo.CurrentProject() + utils.Check(err) + } + subpage := utils.ConcatPaths("compare", rangeQueryEscape(r)) url := project.WebURL("", "", subpage) launcher, err := utils.BrowserLauncher() diff --git a/features/compare.feature b/features/compare.feature index 5eda312bfada1850d89020531492e734de13b62f..2d4e2baae74d5bdf5ee88e717b8fe1c7d9f47aa1 100644 --- a/features/compare.feature +++ b/features/compare.feature @@ -136,3 +136,14 @@ Feature: hub compare When I successfully run `hub compare refactor` Then there should be no output And "open http://git.my.org/mislav/dotfiles/compare/refactor" should be run + + Scenario: Compare in non-GitHub repo + Given the "origin" remote has url "git@bitbucket.org:mislav/dotfiles.git" + And I am on the "feature" branch + When I run `hub compare` + Then the stdout should contain exactly "" + And the stderr should contain exactly: + """ + Aborted: the origin remote doesn't point to a GitHub repository.\n + """ + And the exit status should be 1