gitlab-org--gitlab-foss/lib/gitlab/github_import/branch_formatter.rb

30 lines
534 B
Ruby
Raw Normal View History

2016-05-09 18:45:37 -04:00
module Gitlab
module GithubImport
class BranchFormatter < BaseFormatter
delegate :repo, :sha, :ref, to: :raw_data
def exists?
branch_exists? && commit_exists?
2016-05-09 18:45:37 -04:00
end
def valid?
sha.present? && ref.present?
2016-05-09 18:45:37 -04:00
end
private
def branch_exists?
project.repository.branch_exists?(ref)
end
def commit_exists?
project.repository.branch_names_contains(sha).include?(ref)
end
2016-05-09 18:45:37 -04:00
def short_id
sha.to_s[0..7]
end
end
end
end