Sha256: 802ef03264692cdf5f26a0bea60db5b8272251f9b4da1e4305375245c5ea8d9f

Contents?: true

Size: 869 Bytes

Versions: 21

Compression:

Stored size: 869 Bytes

Contents

require "omnibus/util"

module Omnibus
  class GitRepository
    include Util

    def initialize(path = "./")
      @repo_path = path
    end

    def authors(start_ref, end_ref)
      formatted_log_between(start_ref, end_ref, "%aN").lines.map(&:chomp).uniq
    end

    def commit_messages(start_ref, end_ref)
      formatted_log_between(start_ref, end_ref, "%B").lines.to_a
    end

    def revision
      git("rev-parse HEAD").strip
    end

    def latest_tag
      git("describe --abbrev=0").chomp
    end

    def file_at_revision(path, revision)
      git("show #{revision}:#{path}")
    end

    private

    attr_reader :repo_path

    def formatted_log_between(start_ref, end_ref, format)
      git("log #{start_ref}..#{end_ref} --pretty=\"format:#{format}\"")
    end

    def git(cmd)
      shellout!("git #{cmd}", cwd: repo_path).stdout
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
omnibus-9.0.24 lib/omnibus/git_repository.rb
omnibus-9.0.23 lib/omnibus/git_repository.rb
omnibus-9.0.22 lib/omnibus/git_repository.rb
omnibus-9.0.17 lib/omnibus/git_repository.rb
omnibus-9.0.12 lib/omnibus/git_repository.rb
omnibus-9.0.11 lib/omnibus/git_repository.rb
omnibus-9.0.8 lib/omnibus/git_repository.rb
omnibus-8.3.2 lib/omnibus/git_repository.rb
omnibus-8.2.2 lib/omnibus/git_repository.rb
omnibus-8.1.15 lib/omnibus/git_repository.rb
omnibus-8.0.15 lib/omnibus/git_repository.rb
omnibus-8.0.9 lib/omnibus/git_repository.rb
omnibus-7.0.34 lib/omnibus/git_repository.rb
omnibus-7.0.13 lib/omnibus/git_repository.rb
omnibus-7.0.12 lib/omnibus/git_repository.rb
omnibus-6.1.9 lib/omnibus/git_repository.rb
omnibus-6.1.7 lib/omnibus/git_repository.rb
omnibus-6.1.4 lib/omnibus/git_repository.rb
omnibus-6.0.30 lib/omnibus/git_repository.rb
omnibus-6.0.25 lib/omnibus/git_repository.rb