Module: Datadog::CI::Utils::Git

Defined in:
lib/datadog/ci/utils/git.rb

Class Method Summary collapse

Class Method Details

.is_git_tag?(ref) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/datadog/ci/utils/git.rb', line 25

def self.is_git_tag?(ref)
  !ref.nil? && ref.include?("tags/")
end

.normalize_ref(ref) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/datadog/ci/utils/git.rb', line 16

def self.normalize_ref(ref)
  return nil if ref.nil?

  refs = %r{^refs/(heads/)?}
  origin = %r{^origin/}
  tags = %r{^tags/}
  ref.gsub(refs, "").gsub(origin, "").gsub(tags, "")
end

.valid_commit_sha?(sha) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
# File 'lib/datadog/ci/utils/git.rb', line 10

def self.valid_commit_sha?(sha)
  return false if sha.nil?

  sha.match?(/\A[0-9a-f]{40}\Z/) || sha.match?(/\A[0-9a-f]{64}\Z/)
end