Sha256: d4b632b506a7f299030d9d9156c8eb100d42ab0a0f29ebdb8b8b80ca8ac0165f

Contents?: true

Size: 743 Bytes

Versions: 32

Compression:

Stored size: 743 Bytes

Contents

# frozen_string_literal: true

module CiToolkit
  # Utility class to provide information about git related data
  class Git
    def initialize(dir = nil, env = CiToolkit::BitriseEnv.new)
      @branch = env.git_branch
      @dir = dir
    end

    def latest_tag
      describe = "git describe --abbrev=0"
      return `#{describe}`.gsub("\n", "") unless @dir

      `cd #{@dir} && #{describe}`.gsub("\n", "")
    end

    def branch
      return @branch unless @branch.nil?

      git_branch_cmd = "git branch --show-current"
      return `cd #{@dir} && #{git_branch_cmd}`.gsub(/\s+/, "") unless @dir.nil?

      `#{git_branch_cmd}`.gsub(/\s+/, "")
    end

    def infrastructure_branch?
      !(branch =~ %r{infra/}).nil?
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
ci_toolkit-1.4.10 lib/ci_toolkit/git.rb
ci_toolkit-1.4.9 lib/ci_toolkit/git.rb
ci_toolkit-1.4.8 lib/ci_toolkit/git.rb
ci_toolkit-1.4.7 lib/ci_toolkit/git.rb
ci_toolkit-1.4.6 lib/ci_toolkit/git.rb
ci_toolkit-1.4.4 lib/ci_toolkit/git.rb
ci_toolkit-1.4.3 lib/ci_toolkit/git.rb
ci_toolkit-1.4.2 lib/ci_toolkit/git.rb
ci_toolkit-1.4.1 lib/ci_toolkit/git.rb
ci_toolkit-1.4.0 lib/ci_toolkit/git.rb
ci_toolkit-1.3.21 lib/ci_toolkit/git.rb
ci_toolkit-1.3.20 lib/ci_toolkit/git.rb
ci_toolkit-1.3.18 lib/ci_toolkit/git.rb
ci_toolkit-1.3.17 lib/ci_toolkit/git.rb
ci_toolkit-1.3.16 lib/ci_toolkit/git.rb
ci_toolkit-1.3.15 lib/ci_toolkit/git.rb
ci_toolkit-1.3.14 lib/ci_toolkit/git.rb
ci_toolkit-1.3.13 lib/ci_toolkit/git.rb
ci_toolkit-1.3.12 lib/ci_toolkit/git.rb
ci_toolkit-1.3.10 lib/ci_toolkit/git.rb