class EacLauncher::Git::PublishBase

Constants

CHECKERS
REMOTE_UNAVAILABLE_MESSAGES

Protected Instance Methods

internal_check() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 21
def internal_check
  CHECKERS.each do |checker|
    result = send("#{checker}_check_result")
    return result if result
  end
  divergent_result_check_result
rescue ::StandardError => e
  raise e unless remote_unavailable_error?(e)

  ::EacLauncher::Publish::CheckResult.blocked(e.message)
end

Private Instance Methods

divergent_result_check_result() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 72
def divergent_result_check_result
  ::EacLauncher::Publish::CheckResult.blocked(
    "Divergent (L: #{local_sha}, R: #{remote_sha})"
  )
end
local_following?() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 78
def local_following?
  return true if remote_sha.blank?

  sgit.descendant?(local_sha, remote_sha)
end
local_following_check_result() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 84
def local_following_check_result
  ::EacLauncher::Publish::CheckResult.pending('Local following')
end
local_sha() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 99
def local_sha
  sgit.git.object('HEAD').sha
end
publish() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 92
def publish
  info 'Pushing...'
  sgit.push(remote_name, 'HEAD:master',
            dryrun: !::EacLauncher::Context.current.publish_options[:confirm])
  info 'Pushed!'
end
publish_remote_no_exist_check_result() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 54
def publish_remote_no_exist_check_result
  return nil if sgit.remote_exist?(remote_name)

  ::EacLauncher::Publish::CheckResult.blocked('Remote does not exist')
end
remote_equal_check_result() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 60
def remote_equal_check_result
  return nil unless remote_sha.present? && remote_sha == local_sha

  ::EacLauncher::Publish::CheckResult.updated('Remote equal')
end
remote_fetch_check_result() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 42
def remote_fetch_check_result
  remote_fetch
  nil
end
remote_fetch_uncached() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 109
def remote_fetch_uncached
  sgit.fetch(remote_name)
end
remote_following_check_result() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 66
def remote_following_check_result
  return nil unless remote_sha.present? && sgit.descendant?(remote_sha, local_sha)

  ::EacLauncher::Publish::CheckResult.outdated('Remote following')
end
remote_name() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 113
def remote_name
  ::EacLauncher::Git::WarpBase::TARGET_REMOTE
end
remote_sha_uncached() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 103
def remote_sha_uncached
  remote_fetch
  b = sgit.git.branches["#{remote_name}/master"]
  b ? b.gcommit.sha : nil
end
remote_unavailable_error?(error) click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 47
def remote_unavailable_error?(error)
  error_message = error.message.downcase
  REMOTE_UNAVAILABLE_MESSAGES.any? do |message|
    error_message.include?(message)
  end
end
remote_url_check_result() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 35
def remote_url_check_result
  remote = sgit.remote(remote_name)
  return if remote.exist? && remote.url.present?

  ::EacLauncher::Publish::CheckResult.blocked("Remote \"#{remote_name}\" has blank path")
end
sgit_uncached() click to toggle source
# File lib/eac_launcher/git/publish_base.rb, line 88
def sgit_uncached
  ::EacLauncher::Git::Base.new(instance.warped)
end