S
S
Sonic_SE2011-09-30 20:29:39
git
Sonic_SE, 2011-09-30 20:29:39

Git. How to disable a commit without a '#' in a comment?

I want to disable commits to the master branch without specifying a link to the task in redmine, tell me how to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sonic_SE, 2011-09-30
@Sonic_SE

It's decided. Might be useful to someone in the future.
#!/usr/bin/env ruby
branchname = `git branch --no-color 2> /dev/null`[/^\* (.+)/, 1]
if branchname == 'master'
message_file = ARGV[0]
message = File.read(message_file)
$regex = /\#(\d+)/
if !$regex.match(message)
puts "[POLICY] Your message is not formatted correctly"
exit 1
end
end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question