From f3d61f61fcb0c2f9c38805a922ce056a50780418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Mon, 28 Sep 2015 13:25:48 +0200 Subject: [PATCH] Compensate for the fact that "target_url" might be blank CI statuses from GitHub API might not have "target_url" property. --- commands/ci_status.go | 6 +++++- features/ci_status.feature | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/commands/ci_status.go b/commands/ci_status.go index 1b804e30..1a16e7f2 100644 --- a/commands/ci_status.go +++ b/commands/ci_status.go @@ -128,6 +128,10 @@ func verboseFormat(statuses []*github.CIStatus) { stateMarker = fmt.Sprintf("\033[%dm%s\033[0m", color, stateMarker) } - ui.Printf("%s\t%-*s\t%s\n", stateMarker, contextWidth, status.Context, status.TargetUrl) + if status.TargetUrl == "" { + ui.Printf("%s\t%s\n", stateMarker, status.Context) + } else { + ui.Printf("%s\t%-*s\t%s\n", stateMarker, contextWidth, status.Context, status.TargetUrl) + } } } diff --git a/features/ci_status.feature b/features/ci_status.feature index f3374d3f..47a1703a 100644 --- a/features/ci_status.feature +++ b/features/ci_status.feature @@ -32,10 +32,12 @@ Feature: hub ci-status :target_url => "https://travis-ci.org/michiels/pencilbox/builds/1234567" }, { :state => "pending", :context => "continuous-integration/travis-ci/merge", - :target_url => "https://travis-ci.org/michiels/pencilbox/builds/1234567" }, + :target_url => nil }, { :state => "failure", :context => "GitHub CLA", :target_url => "https://cla.github.com/michiels/pencilbox/accept/mislav" }, + { :state => "error", + :context => "whatevs!" } ] } """ @@ -43,8 +45,9 @@ Feature: hub ci-status Then the output should contain exactly: """ ✔︎ continuous-integration/travis-ci/push https://travis-ci.org/michiels/pencilbox/builds/1234567 - ● continuous-integration/travis-ci/merge https://travis-ci.org/michiels/pencilbox/builds/1234567 - ✖︎ GitHub CLA https://cla.github.com/michiels/pencilbox/accept/mislav\n + ● continuous-integration/travis-ci/merge + ✖︎ GitHub CLA https://cla.github.com/michiels/pencilbox/accept/mislav + ✖︎ whatevs!\n """ And the exit status should be 2