Sha256: e75094dbd285ba8bf75a9c75b76227a18b7b51799344dc33bb17401aaa254536

Contents?: true

Size: 652 Bytes

Versions: 18

Compression:

Stored size: 652 Bytes

Contents

# frozen_string_literal: true

require "open3"
require "pathname"

module Datadog
  module CI
    module Utils
      module Git
        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

        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

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
datadog-ci-1.11.0 lib/datadog/ci/utils/git.rb
datadog-ci-1.10.0 lib/datadog/ci/utils/git.rb
datadog-ci-1.9.0 lib/datadog/ci/utils/git.rb
datadog-ci-1.8.1 lib/datadog/ci/utils/git.rb
datadog-ci-1.8.0 lib/datadog/ci/utils/git.rb
datadog-ci-1.7.0 lib/datadog/ci/utils/git.rb
datadog-ci-1.6.0 lib/datadog/ci/utils/git.rb
datadog-ci-1.5.0 lib/datadog/ci/utils/git.rb
datadog-ci-1.4.1 lib/datadog/ci/utils/git.rb
datadog-ci-1.4.0 lib/datadog/ci/utils/git.rb
datadog-ci-1.3.0 lib/datadog/ci/utils/git.rb
datadog-ci-1.2.0 lib/datadog/ci/utils/git.rb
datadog-ci-1.1.0 lib/datadog/ci/utils/git.rb
datadog-ci-1.0.1 lib/datadog/ci/utils/git.rb
datadog-ci-1.0.0 lib/datadog/ci/utils/git.rb
datadog-ci-1.0.0.beta6 lib/datadog/ci/utils/git.rb
datadog-ci-1.0.0.beta3 lib/datadog/ci/utils/git.rb
datadog-ci-1.0.0.beta2 lib/datadog/ci/utils/git.rb