debian-mirror-gitlab/lib/gitlab/github_import/branch_formatter.rb

30 lines
499 B
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
module Gitlab
module GithubImport
class BranchFormatter < BaseFormatter
delegate :repo, :sha, :ref, to: :raw_data
def exists?
2016-08-24 12:49:21 +05:30
branch_exists? && commit_exists?
2016-06-02 11:05:42 +05:30
end
def valid?
repo.present?
end
2016-08-24 12:49:21 +05:30
private
def branch_exists?
project.repository.branch_exists?(ref)
2016-06-02 11:05:42 +05:30
end
2016-08-24 12:49:21 +05:30
def commit_exists?
project.repository.commit(sha).present?
end
2016-06-02 11:05:42 +05:30
def short_id
sha.to_s[0..7]
end
end
end
end