Sha256: 7cfc22f839e408a4060519f81a0111c40f9950c43f000bbbd5d2b89661897a23

Contents?: true

Size: 870 Bytes

Versions: 6

Compression:

Stored size: 870 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

6 entries across 6 versions & 1 rubygems

Version Path
omnibus-5.4.0 lib/omnibus/git_repository.rb
omnibus-5.3.0 lib/omnibus/git_repository.rb
omnibus-5.2.0 lib/omnibus/git_repository.rb
omnibus-5.1.0 lib/omnibus/git_repository.rb
omnibus-5.0.0 lib/omnibus/git_repository.rb
omnibus-4.1.0 lib/omnibus/git_repository.rb