summaryrefslogtreecommitdiff
path: root/lib/gitlab/github_import/branch_formatter.rb
blob: a15fc84b4182b3f5beed5005410688f4b03704cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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

      def valid?
        repo.present?
      end

      private

      def short_id
        sha.to_s[0..7]
      end
    end
  end
end