Skip to content

Commit

Permalink
correct and tidy up some of the logging for the git commit status upd…
Browse files Browse the repository at this point in the history
…ates
  • Loading branch information
joshk committed Sep 27, 2012
1 parent 20b2e1d commit b0cb556
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/travis/notification/instrument/task.rb
Expand Up @@ -78,7 +78,7 @@ def run_completed
# :request_id => data['request_id'], # TODO
:object_type => 'Build',
:object_id => data['build']['id'],
:url => task.url
:url => task.full_url.to_s
)
end
end
Expand Down
9 changes: 4 additions & 5 deletions lib/travis/task/github_commit_status.rb
Expand Up @@ -11,6 +11,10 @@ def url
options[:url]
end

def full_url
GH.api_host + url
end

def build_url
options[:build_url]
end
Expand All @@ -25,7 +29,6 @@ def process
authenticated do
GH.post(url, :target_url => build_url, :state => state, :description => description)
end
info "Successfully updated the PR status on #{full_url}."
rescue GH::Error => e
error "Could not update the PR status on #{full_url} (#{e.message})."
end
Expand Down Expand Up @@ -61,10 +64,6 @@ def friendly_state
end
end

def full_url
GH.api_host + url
end

Notification::Instrument::Task::GithubCommitStatus.attach_to(self)
end
end
Expand Down
Expand Up @@ -5,7 +5,7 @@

let(:data) { Travis::Api.data(build, :for => 'event', :version => 'v2') }
let(:build_url) { 'http://travis-ci.org/#!/travis-repos/test-project-1/1234' }
let(:url) { "https://api.github.com/repos/svenfuchs/minimal/statuses/#{sha}" }
let(:url) { "/repos/svenfuchs/minimal/statuses/#{sha}" }
let(:sha) { 'ab2784e55bcf71ac9ef5f6ade8e02334c6524eea' }
let(:token) { '12345' }
let(:task) { Travis::Task::GithubCommitStatus.new(data, :url => url, :sha => sha, :build_url => build_url, :token => token) }
Expand Down
6 changes: 0 additions & 6 deletions spec/travis/task/github_commit_status_spec.rb
Expand Up @@ -96,12 +96,6 @@ def run
end

describe 'logging' do
it 'logs a successful request' do
GH.stubs(:post)
run
io.string.should include('[githubcommitstatus] Successfully updated the PR status on https://api.github.com/repos/travis-repos/test-project-1/statuses/ab2784e55bcf71ac9ef5f6ade8e02334c6524eea')
end

it 'warns about a failed request' do
GH.stubs(:post).raises(GH::Error.new(nil))
run
Expand Down

0 comments on commit b0cb556

Please sign in to comment.