class Released::Goals::GitRefPushed
Public Class Methods
new(config)
click to toggle source
# File lib/released/goals/git_ref_pushed.rb, line 8 def initialize(config) @working_dir = config.fetch('working_dir') @remote = config.fetch('remote') @ref = config.fetch('ref') end
Public Instance Methods
achieved?()
click to toggle source
# File lib/released/goals/git_ref_pushed.rb, line 22 def achieved? local_sha == remote_sha end
failure_reason()
click to toggle source
# File lib/released/goals/git_ref_pushed.rb, line 26 def failure_reason if remote_sha "ref #{@ref} (#{abbr local_sha}) is not the same as #{@remote}/#{@ref} (#{abbr remote_sha})" else "ref #{@ref} (#{abbr local_sha}) does not exist on remote #{@remote}" end end
to_s()
click to toggle source
# File lib/released/goals/git_ref_pushed.rb, line 14 def to_s "Git ref pushed (#{@remote}/#{@ref})" end
try_achieve()
click to toggle source
# File lib/released/goals/git_ref_pushed.rb, line 18 def try_achieve g.push(@remote, @ref) end
Private Instance Methods
abbr(sha)
click to toggle source
# File lib/released/goals/git_ref_pushed.rb, line 40 def abbr(sha) sha && sha[0..7] end
g()
click to toggle source
# File lib/released/goals/git_ref_pushed.rb, line 36 def g @_g ||= Git.open(@working_dir) end
local_sha()
click to toggle source
# File lib/released/goals/git_ref_pushed.rb, line 51 def local_sha g.object(@ref).sha end
remote_sha()
click to toggle source
# File lib/released/goals/git_ref_pushed.rb, line 44 def remote_sha remote_url = g.remote(@remote).url res = Git.ls_remote(remote_url) ref = res['branches'].merge(res['tags']).find { |name, _data| name == @ref } ref ? ref[1][:sha] : nil end