lib/github-status/out.rb in concourse-github-status-0.1.0 vs lib/github-status/out.rb in concourse-github-status-0.1.1

- old
+ new

@@ -5,10 +5,23 @@ require 'git' require 'octokit' module GitHubStatus class Out < Fuselage::Out + Contract None => Sawyer::Resource + def update! + github.create_status repo, sha, state, options + rescue Octokit::Error => error + STDERR.puts error.message + abort + end + + Contract None => HashOf[String, String] + def version + { 'context@sha' => "#{context}@#{sha}" } + end + Contract None => String def repo @repo ||= source.fetch 'repo' rescue KeyError STDERR.puts 'Source is missing repo' @@ -61,37 +74,24 @@ target_url: target_url, description: description } end - Contract None => Git::Repository + Contract None => Git::Base def git - @git ||= Git.open "#{working_path}/#{path}" + @git ||= Git.open "#{workdir}/#{path}" rescue ArgumentError STDERR.puts "#{path} is not a git repository" abort end Contract None => String def sha @repo ||= git.revparse 'HEAD' end - Contract None => HashOf[String, String] - def version - { 'context@sha' => "#{context}@#{sha}" } - end - Contract None => Octokit::Client def github @github ||= Octokit::Client.new access_token: access_token - end - - Contract None => Sawyer::Resource - def update! - github.create_status repo, sha, state, options - rescue Octokit::Error => error - STDERR.puts error.message - abort end end end