зеркало из https://github.com/mislav/hub.git
`ci-status -v` prints the URL to CI build results
Fixes #422, closes #423
This commit is contained in:
Родитель
8909a3b2f0
Коммит
c3fe678459
|
@ -11,6 +11,13 @@ Feature: hub ci-status
|
|||
Then the output should contain exactly "success\n"
|
||||
And the exit status should be 0
|
||||
|
||||
Scenario: Fetch commit SHA with URL
|
||||
Given there is a commit named "the_sha"
|
||||
Given the remote commit state of "michiels/pencilbox" "the_sha" is "success"
|
||||
When I run `hub ci-status the_sha -v`
|
||||
Then the output should contain "success: https://travis-ci.org/michiels/pencilbox/builds/1234567"
|
||||
And the exit status should be 0
|
||||
|
||||
Scenario: Multiple statuses, latest is passing
|
||||
Given there is a commit named "the_sha"
|
||||
Given the remote commit states of "michiels/pencilbox" "the_sha" are:
|
||||
|
@ -41,6 +48,13 @@ Feature: hub ci-status
|
|||
Then the output should contain exactly "no status\n"
|
||||
And the exit status should be 3
|
||||
|
||||
Scenario: Exit status 3 for no statuses available without URL
|
||||
Given there is a commit named "the_sha"
|
||||
Given the remote commit state of "michiels/pencilbox" "the_sha" is nil
|
||||
When I run `hub ci-status -v the_sha`
|
||||
Then the output should contain exactly "no status\n"
|
||||
And the exit status should be 3
|
||||
|
||||
Scenario: Abort with message when invalid ref given
|
||||
When I run `hub ci-status this-is-an-invalid-ref`
|
||||
Then the exit status should be 1
|
||||
|
|
|
@ -175,7 +175,10 @@ Given(/^the remote commit states of "(.*?)" "(.*?)" are:$/) do |proj, ref, json_
|
|||
end
|
||||
|
||||
Given(/^the remote commit state of "(.*?)" "(.*?)" is "(.*?)"$/) do |proj, ref, status|
|
||||
step %{the remote commit states of "#{proj}" "#{ref}" are:}, "[ { :state => \"#{status}\" } ]"
|
||||
step %{the remote commit states of "#{proj}" "#{ref}" are:}, <<-EOS
|
||||
[ { :state => \"#{status}\",
|
||||
:target_url => 'https://travis-ci.org/#{proj}/builds/1234567' } ]
|
||||
EOS
|
||||
end
|
||||
|
||||
Given(/^the remote commit state of "(.*?)" "(.*?)" is nil$/) do |proj, ref|
|
||||
|
|
|
@ -78,6 +78,7 @@ module Hub
|
|||
def ci_status(args)
|
||||
args.shift
|
||||
ref = args.words.first || 'HEAD'
|
||||
verbose = args.include?('-v')
|
||||
|
||||
unless head_project = local_repo.current_project
|
||||
abort "Aborted: the origin remote doesn't point to a GitHub repository."
|
||||
|
@ -89,7 +90,13 @@ module Hub
|
|||
|
||||
statuses = api_client.statuses(head_project, sha)
|
||||
status = statuses.first
|
||||
ref_state = status ? status['state'] : 'no status'
|
||||
if status
|
||||
ref_state = status['state']
|
||||
ref_target_url = status['target_url']
|
||||
else
|
||||
ref_state = 'no status'
|
||||
ref_target_url = nil
|
||||
end
|
||||
|
||||
exit_code = case ref_state
|
||||
when 'success' then 0
|
||||
|
@ -98,7 +105,11 @@ module Hub
|
|||
else 3
|
||||
end
|
||||
|
||||
$stdout.puts ref_state
|
||||
if verbose and ref_target_url
|
||||
$stdout.puts "%s: %s" % [ref_state, ref_target_url]
|
||||
else
|
||||
$stdout.puts ref_state
|
||||
end
|
||||
exit exit_code
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "HUB" "1" "July 2013" "GITHUB" "Git Manual"
|
||||
.TH "HUB" "1" "October 2013" "GITHUB" "Git Manual"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBhub\fR \- git + hub = github
|
||||
|
@ -64,7 +64,7 @@
|
|||
\fBgit pull\-request\fR [\fB\-f\fR] [\fB\-m\fR \fIMESSAGE\fR|\fB\-F\fR \fIFILE\fR|\fB\-i\fR \fIISSUE\fR|\fIISSUE\-URL\fR] [\fB\-b\fR \fIBASE\fR] [\fB\-h\fR \fIHEAD\fR]
|
||||
.
|
||||
.br
|
||||
\fBgit ci\-status\fR [\fICOMMIT\fR]
|
||||
\fBgit ci\-status\fR [\fB\-v\fR] [\fICOMMIT\fR]
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
hub enhances various git commands to ease most common workflows with GitHub\.
|
||||
|
@ -155,12 +155,15 @@ Without \fIMESSAGE\fR or \fIFILE\fR, a text editor will open in which title and
|
|||
If instead of normal \fITITLE\fR an issue number is given with \fB\-i\fR, the pull request will be attached to an existing GitHub issue\. Alternatively, instead of title you can paste a full URL to an issue on GitHub\.
|
||||
.
|
||||
.TP
|
||||
\fBgit ci\-status\fR [\fICOMMIT\fR]
|
||||
\fBgit ci\-status\fR [\fB\-v\fR] [\fICOMMIT\fR]
|
||||
Looks up the SHA for \fICOMMIT\fR in GitHub Status API and displays the latest status\. Exits with one of:
|
||||
.
|
||||
.br
|
||||
success (0), error (1), failure (1), pending (2), no status (3)
|
||||
.
|
||||
.IP
|
||||
If \fB\-v\fR is given, additionally print the URL to CI build results\.
|
||||
.
|
||||
.SH "CONFIGURATION"
|
||||
Hub will prompt for GitHub username & password the first time it needs to access the API and exchange it for an OAuth token, which it saves in "~/\.config/hub"\.
|
||||
.
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
<code>git compare</code> [<code>-u</code>] [<var>USER</var>] [<var>START</var>...]<var>END</var><br />
|
||||
<code>git fork</code> [<code>--no-remote</code>]<br />
|
||||
<code>git pull-request</code> [<code>-f</code>] [<code>-m</code> <var>MESSAGE</var>|<code>-F</code> <var>FILE</var>|<code>-i</code> <var>ISSUE</var>|<var>ISSUE-URL</var>] [<code>-b</code> <var>BASE</var>] [<code>-h</code> <var>HEAD</var>]<br />
|
||||
<code>git ci-status</code> [<var>COMMIT</var>]</p>
|
||||
<code>git ci-status</code> [<code>-v</code>] [<var>COMMIT</var>]</p>
|
||||
|
||||
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
||||
|
||||
|
@ -194,9 +194,11 @@ Pull request message can also be passed via stdin with <code>-F -</code>.</p>
|
|||
<p>If instead of normal <var>TITLE</var> an issue number is given with <code>-i</code>, the pull
|
||||
request will be attached to an existing GitHub issue. Alternatively, instead
|
||||
of title you can paste a full URL to an issue on GitHub.</p></dd>
|
||||
<dt><code>git ci-status</code> [<var>COMMIT</var>]</dt><dd><p>Looks up the SHA for <var>COMMIT</var> in GitHub Status API and displays the latest
|
||||
<dt><code>git ci-status</code> [<code>-v</code>] [<var>COMMIT</var>]</dt><dd><p>Looks up the SHA for <var>COMMIT</var> in GitHub Status API and displays the latest
|
||||
status. Exits with one of:<br />
|
||||
success (0), error (1), failure (1), pending (2), no status (3)</p></dd>
|
||||
success (0), error (1), failure (1), pending (2), no status (3)</p>
|
||||
|
||||
<p>If <code>-v</code> is given, additionally print the URL to CI build results.</p></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
@ -453,7 +455,7 @@ $ git help hub
|
|||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'>GITHUB</li>
|
||||
<li class='tc'>July 2013</li>
|
||||
<li class='tc'>October 2013</li>
|
||||
<li class='tr'>hub(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ hub(1) -- git + hub = github
|
|||
`git compare` [`-u`] [<USER>] [<START>...]<END>
|
||||
`git fork` [`--no-remote`]
|
||||
`git pull-request` [`-f`] [`-m` <MESSAGE>|`-F` <FILE>|`-i` <ISSUE>|<ISSUE-URL>] [`-b` <BASE>] [`-h` <HEAD>]
|
||||
`git ci-status` [<COMMIT>]
|
||||
`git ci-status` [`-v`] [<COMMIT>]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
|
@ -154,11 +154,13 @@ hub also adds some custom commands that are otherwise not present in git:
|
|||
request will be attached to an existing GitHub issue. Alternatively, instead
|
||||
of title you can paste a full URL to an issue on GitHub.
|
||||
|
||||
* `git ci-status` [<COMMIT>]:
|
||||
* `git ci-status` [`-v`] [<COMMIT>]:
|
||||
Looks up the SHA for <COMMIT> in GitHub Status API and displays the latest
|
||||
status. Exits with one of:
|
||||
success (0), error (1), failure (1), pending (2), no status (3)
|
||||
|
||||
If `-v` is given, additionally print the URL to CI build results.
|
||||
|
||||
## CONFIGURATION
|
||||
|
||||
Hub will prompt for GitHub username & password the first time it needs to access
|
||||
|
|
Загрузка…
Ссылка в новой задаче