From 5d3a687bff1e4b0c72fa13f6ff84404ac28891f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Mon, 28 Sep 2015 16:22:34 +0200 Subject: [PATCH] Fix `compare` crash when used on a non-GitHub repo --- commands/compare.go | 5 +++++ features/compare.feature | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/commands/compare.go b/commands/compare.go index dfb23bb4..803e203d 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 5eda312b..2d4e2baa 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 -- GitLab