Module: GitHelpers
- Defined in:
- lib/zitgit/helpers/git.rb
Instance Method Summary collapse
- #heads(commit) ⇒ Object
- #is_head_ref(ref) ⇒ Object
- #is_image(diff) ⇒ Object
- #large_commit?(commit) ⇒ Boolean
- #large_diff?(diff) ⇒ Boolean
- #merge_commit?(commit) ⇒ Boolean
- #remotes(commit) ⇒ Object
- #tags(commit) ⇒ Object
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
21 22 23 |
# File 'lib/zitgit/helpers/git.rb', line 21 def large_commit?(commit) commit.diffs.count > 20 end |
#large_diff?(diff) ⇒ 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
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 (commit) repo = Grit::Repo.new('.') repo..select{|head| head.commit.id == commit.id} end |