Source code file content
sources / blog-sources / subversion / hook-commit-allower.rb
Size: 1891 bytes, 1 line
# This start-commit hook verifies that user can commit to repository
# $HeadURL: http://svn.jyskebank.dk/repos/JB/TI/jb.itu.ti.subversion-tailoring/trunk/jb-scripts/hook-commit-allower.rb $
# $LastChangedRevision: 9787 $
#
# Written by Jesper Skov <jskov@jyskebank.dk>
# Copyright 2009 Jyske Bank
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
require "optparse"
USERS_DENIED_ACCESS = %w(jbbuildserverant00 ccusermain00 jbbuild00 jbcontint)
options = {}
ARGV.options do |opts|
opts.banner = "Usage: commit-allower.rb [options]"
opts.on("-u=username", "--user=username", "Username wanting to commit") do | username |
options[:username] = username.downcase()
end
opts.def_option("-r=repository", "--repository=repository", "Repository for commit") do | repository |
options[:repository] = repository
end
opts.on_tail("-h", "--help", "Show this message") do
puts(opts)
exit(0)
end
opts.parse!
end
if not (options[:username] and options[:repository])
$stderr.puts("Must specify username and repository")
exit(1)
end
if USERS_DENIED_ACCESS.include?(options[:username])
$stderr.puts("-----------------------")
$stderr.puts("User #{options[:username]} is not allowed to commit in SVN")
exit(1)
end
exit(0)





