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

26 lines
419 B
Ruby
Raw Normal View History

2016-05-09 22:45:37 +00:00
module Gitlab
module GithubImport
class BranchFormatter < BaseFormatter
delegate :repo, :sha, :ref, to: :raw_data
def exists?
project.repository.branch_exists?(ref)
end
def name
@name ||= exists? ? ref : "#{ref}-#{short_id}"
end
def valid?
repo.present?
end
private
def short_id
sha.to_s[0..7]
end
end
end
end