Sha256: 5512fac23aa7eec1c2f1dfd6d9a8f90c4797bd28a5bccbe55c29b8132ab4e139

Contents?: true

Size: 1007 Bytes

Versions: 9

Compression:

Stored size: 1007 Bytes

Contents

module DerailedBenchmarks
  # Represents a specific commit in a git repo
  #
  # Can be used to get information from the commit or to check it out
  #
  # commit = GitCommit.new(path: "path/to/repo", ref: "6e642963acec0ff64af51bd6fba8db3c4176ed6e")
  # commit.short_sha # => "6e64296"
  # commit.checkout! # Will check out the current commit at the repo in the path
  class Git::Commit
    attr_reader :ref, :description, :time, :short_sha, :log

    def initialize(path: , ref: , log_dir: Pathname.new("/dev/null"))
      @in_git_path = Git::InPath.new(path)
      @ref = ref
      @log = log_dir.join("#{file_safe_ref}.bench.txt")

      Dir.chdir(path) do
        checkout!
        @description = @in_git_path.description
        @short_sha = @in_git_path.short_sha
        @time = @in_git_path.time
      end
    end

    alias :desc :description
    alias :file :log

    def checkout!
      @in_git_path.checkout!(ref)
    end

    private def file_safe_ref
      ref.gsub('/', ':')
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
derailed_benchmarks-2.2.1 lib/derailed_benchmarks/git/commit.rb
derailed_benchmarks-2.2.0 lib/derailed_benchmarks/git/commit.rb
derailed_benchmarks-2.1.2 lib/derailed_benchmarks/git/commit.rb
derailed_benchmarks-2.1.1 lib/derailed_benchmarks/git/commit.rb
derailed_benchmarks-2.1.0 lib/derailed_benchmarks/git/commit.rb
derailed_benchmarks-2.0.1 lib/derailed_benchmarks/git/commit.rb
derailed_benchmarks-2.0.0 lib/derailed_benchmarks/git/commit.rb
derailed_benchmarks-1.8.1 lib/derailed_benchmarks/git/commit.rb
derailed_benchmarks-1.8.0 lib/derailed_benchmarks/git/commit.rb