Sha256: ecff56ea3227e68a98907616f1d9fa102a547a1720d060bc51af57d7ac6cbfdd

Contents?: true

Size: 750 Bytes

Versions: 32

Compression:

Stored size: 750 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 --tags --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.6.4 lib/ci_toolkit/git.rb
ci_toolkit-1.6.3 lib/ci_toolkit/git.rb
ci_toolkit-1.6.2 lib/ci_toolkit/git.rb
ci_toolkit-1.6.1 lib/ci_toolkit/git.rb
ci_toolkit-1.6.0 lib/ci_toolkit/git.rb
ci_toolkit-1.5.24 lib/ci_toolkit/git.rb
ci_toolkit-1.5.23 lib/ci_toolkit/git.rb
ci_toolkit-1.5.22 lib/ci_toolkit/git.rb
ci_toolkit-1.5.21 lib/ci_toolkit/git.rb
ci_toolkit-1.5.20 lib/ci_toolkit/git.rb
ci_toolkit-1.5.19 lib/ci_toolkit/git.rb
ci_toolkit-1.5.17 lib/ci_toolkit/git.rb
ci_toolkit-1.5.16 lib/ci_toolkit/git.rb
ci_toolkit-1.5.15 lib/ci_toolkit/git.rb
ci_toolkit-1.5.14 lib/ci_toolkit/git.rb
ci_toolkit-1.5.13 lib/ci_toolkit/git.rb
ci_toolkit-1.5.12 lib/ci_toolkit/git.rb
ci_toolkit-1.5.11 lib/ci_toolkit/git.rb
ci_toolkit-1.5.10 lib/ci_toolkit/git.rb
ci_toolkit-1.5.9 lib/ci_toolkit/git.rb