Skip to content

Commit

Permalink
Clean up detection of revision 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Stan Hu committed Sep 19, 2012
1 parent 730f63c commit ae4c008
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/git_commit_notifier/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def new_commits(oldrev, newrev, refname, unique_to_current_branch)
# Where B1, B2, ..., are any other branch
a = Array.new

# Zero revision comes in the form:
# "0000000000000000000000000000000000000000"
zero_rev = (oldrev =~ /^0+$/)

# If we want to include only those commits that are
# unique to this branch, then exclude commits that occur on
# other branches
Expand All @@ -126,15 +130,14 @@ def new_commits(oldrev, newrev, refname, unique_to_current_branch)
# 0. In this case, this is a new branch or an empty repository and we
# will want to keep it excluded, otherwise we will process every
# commit prior to the creation of this branch. Fixes issue #159.
zero_rev = (oldrev =~ /^0+$/)
if zero_rev.nil?
current_branch = rev_parse(refname)
a.delete_at a.index("^#{current_branch}") unless a.index("^#{current_branch}").nil?
end
end

# Add not'd oldrev (^oldrev)
a.push("^#{oldrev}") unless oldrev =~ /^0+$/
a.push("^#{oldrev}") unless zero_rev

# Add newrev
a.push(newrev)
Expand Down

0 comments on commit ae4c008

Please sign in to comment.