BigW Consortium Gitlab

git.rb 618 Bytes
Newer Older
1 2
module Gitlab
  module Git
3
    BLANK_SHA = ('0' * 40).freeze
4 5
    TAG_REF_PREFIX = "refs/tags/".freeze
    BRANCH_REF_PREFIX = "refs/heads/".freeze
6

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
    class << self
      def ref_name(ref)
        ref.gsub(/\Arefs\/(tags|heads)\//, '')
      end

      def tag_ref?(ref)
        ref.start_with?(TAG_REF_PREFIX)
      end

      def branch_ref?(ref)
        ref.start_with?(BRANCH_REF_PREFIX)
      end

      def blank_ref?(ref)
        ref == BLANK_SHA
      end
23 24 25 26

      def version
        Gitlab::VersionInfo.parse(Gitlab::Popen.popen(%W(#{Gitlab.config.git.bin_path} --version)).first)
      end
27
    end
28 29
  end
end