Sha256: 584f0ce4f49314b44d9e79b5cf0a77a20b41e4b83c600172de244fd072d72deb

Contents?: true

Size: 454 Bytes

Versions: 9

Compression:

Stored size: 454 Bytes

Contents

class CommitRange < Struct.new(:data, :current_branch)
  SHORT_LENGTH = 7

  def to_s(short = false)
    @_to_s ||= range.map do |commit|
      short ? shorten(commit) : commit
    end.join("..")
  end

  def is_range?
    data.is_a?(Array)
  end

  def range
    is_range? ? data : [data]
  end
  
  private

  def branch?(commit)
    current_branch == commit
  end

  def shorten(commit)
    branch?(commit) ? commit : commit[0..SHORT_LENGTH]
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
git_fame-2.5.3 lib/git_fame/commit_range.rb
git_fame-2.5.2 lib/git_fame/commit_range.rb
git_fame-2.5.1 lib/git_fame/commit_range.rb
git_fame-2.5.0 lib/git_fame/commit_range.rb
git_fame-2.4.0 lib/git_fame/commit_range.rb
git_fame-2.3.1 lib/git_fame/commit_range.rb
git_fame-2.2.0 lib/git_fame/commit_range.rb
git_fame-2.0.1 lib/git_fame/commit_range.rb
git_fame-2.0.0 lib/git_fame/commit_range.rb