Sha256: ef008d3a27229bdd2ca693a97101fc7c9469b17fbc0c37eea302d2c10a8e84e0

Contents?: true

Size: 809 Bytes

Versions: 2

Compression:

Stored size: 809 Bytes

Contents

module GitHelpers
  def heads(commit)
    repo = Grit::Repo.new('.')
    repo.heads.select{|head| head.commit.id == commit.id}
  end

  def remotes(commit)
    repo = Grit::Repo.new('.')
    repo.remotes.select{|head| head.commit.id == commit.id}
  end

  def tags(commit)
    repo = Grit::Repo.new('.')
    repo.tags.select{|head| head.commit.id == commit.id}
  end

  def merge_commit?(commit)
    commit.parents.count > 1
  end

  def large_commit?(commit)
    commit.diffs.count > 20
  end

  def large_diff?(diff)
    diff.diff.lines.count > 200
  end

  def is_head_ref(ref)
    ref.name.split('/').index('HEAD')
  end

  def is_image(diff)
    image_exts = ['.jpg', '.jpeg', '.png', '.gif']
    image_exts.include?(File.extname(diff.a_path)) or image_exts.include?(File.extname(diff.b_path))
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zitgit-0.1.1 lib/zitgit/helpers/git.rb
zitgit-0.1.0 lib/zitgit/helpers/git.rb