Module: GitHelpers

Defined in:
lib/zitgit/helpers/git.rb

Instance Method Summary collapse

Instance Method Details

#heads(commit) ⇒ Object



2
3
4
5
# File 'lib/zitgit/helpers/git.rb', line 2

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

#is_head_ref(ref) ⇒ Object



29
30
31
# File 'lib/zitgit/helpers/git.rb', line 29

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

#is_image(diff) ⇒ Object



33
34
35
36
# File 'lib/zitgit/helpers/git.rb', line 33

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

#large_commit?(commit) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/zitgit/helpers/git.rb', line 21

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

#large_diff?(diff) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/zitgit/helpers/git.rb', line 25

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

#merge_commit?(commit) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/zitgit/helpers/git.rb', line 17

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

#remotes(commit) ⇒ Object



7
8
9
10
# File 'lib/zitgit/helpers/git.rb', line 7

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

#tags(commit) ⇒ Object



12
13
14
15
# File 'lib/zitgit/helpers/git.rb', line 12

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