Skip to content

Commit e9e1146

Browse files
committed
check-email.rb: check only the last commit in pushed commits
To allow merge commit
1 parent 9563343 commit e9e1146

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

bin/check-email.rb

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,29 @@
2828

2929
emails = SVN_TO_EMAILS[svn_account_name]
3030

31-
ARGV.each_slice(3) do |oldrev, newrev, refname|
32-
out, = Open3.capture2("git", "log", "--pretty=format:%H\n%ce", "-z", oldrev + ".." + newrev)
33-
34-
out.split("\0").reverse_each do |s|
35-
hash, git_committer_email = s.split("\n")
36-
if emails
37-
if emails == git_committer_email || emails.include?(git_committer_email)
38-
# OK
39-
else
40-
puts "Your ssh key is not associated to the git committer email."
41-
puts "Please see https://github.com/ruby/ruby-commit-hook/blob/master/bin/check-email.rb"
42-
puts "and send PR, or contact on ruby-core@ruby-lang.org."
43-
exit 1 # NG
44-
end
31+
ARGV.each_slice(3) do |_oldrev, newrev, _refname|
32+
out, = Open3.capture2("git", "show", "-s", "--pretty=format:%H\n%ce", newrev)
33+
34+
hash, git_committer_email = out.split("\n")
35+
if emails
36+
if emails == git_committer_email || emails.include?(git_committer_email)
37+
# OK
38+
else
39+
puts "Your ssh key is not associated to the git committer email."
40+
puts "Please see https://github.com/ruby/ruby-commit-hook/blob/master/bin/check-email.rb"
41+
puts "and send PR, or contact on ruby-core@ruby-lang.org."
42+
exit 1 # NG
43+
end
44+
else
45+
if Time.now > Time.new(2020, 1, 1)
46+
puts "Your ssh key is unknown."
47+
puts "Please see https://github.com/ruby/ruby-commit-hook/blob/master/bin/check-email.rb"
48+
puts "and send PR, or contact on ruby-core@ruby-lang.org."
49+
exit 1 # NG
4550
else
46-
if Time.now > Time.new(2020, 1, 1)
47-
puts "Your ssh key is unknown."
48-
puts "Please see https://github.com/ruby/ruby-commit-hook/blob/master/bin/check-email.rb"
49-
puts "and send PR, or contact on ruby-core@ruby-lang.org."
50-
exit 1 # NG
51-
else
52-
# Until the last of 2019, we record the association of SVN_ACCOUNT_NAME and GIT_COMMITTER_EMAIL.
53-
open(LOG_FILE, "a") do |f|
54-
f.puts "#{ hash } #{ svn_account_name } #{ git_committer_email }"
55-
end
51+
# Until the last of 2019, we record the association of SVN_ACCOUNT_NAME and GIT_COMMITTER_EMAIL.
52+
open(LOG_FILE, "a") do |f|
53+
f.puts "#{ hash } #{ svn_account_name } #{ git_committer_email }"
5654
end
5755
end
5856
end

0 commit comments

Comments
 (0)