Skip to content

Commit d7759cc

Browse files
committed
Add a script to prohibit merge commits
1 parent e9e1146 commit d7759cc

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

bin/prohibit-merge-commits.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env ruby
2+
3+
require "open3"
4+
5+
ARGV.each_slice(3) do |oldrev, newrev, refname|
6+
out, = Open3.capture2("git", "rev-list", "--parents", oldrev + ".." + newrev)
7+
out.lines.each do |s|
8+
if s.split.size >= 3
9+
puts "A merge commit is prohibited."
10+
exit 1
11+
end
12+
end
13+
end

hooks/pre-receive-pre.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ ruby_git="/var/git/ruby.git"
77
hook_log="/tmp/pre-receive-pre.log"
88
ruby_commit_hook="$(cd "$(dirname $0)"; cd ..; pwd)"
99

10+
$ruby_commit_hook/bin/prohibit-merge-commits.rb $* || exit 1
11+
1012
$ruby_commit_hook/bin/check-email.rb $* || exit 1

0 commit comments

Comments
 (0)