Below the *update *ruby script from 
*/opt/gitlab/embedded/service/gitlab-shell/hooks/update*
which does the trick. Note that I put a *.pgpass* file into the GitLab home 
folder */var/opt/gitlab/*

-----------------
#!/opt/gitlab/embedded/bin/ruby
# Fix the PATH so that gitlab-shell can find git-upload-pack and friends.
ENV['PATH'] = '/opt/gitlab/bin:/opt/gitlab/embedded/bin:' + ENV['PATH']

#!/usr/bin/env ruby

# This file was placed here by GitLab. It makes sure that your pushed 
commits
# will be processed properly.
# You can add your own hooks to this file, but be careful when updating 
gitlab-shell!

refname = ARGV[0]
key_id = ENV['GL_ID']
repo_path = Dir.pwd
shanew = ARGV[2]
shaold = ARGV[1]

require_relative '../lib/gitlab_update'

## cn = committers name
## ce = committers e-mail
## gln = GitLab usernames
## gle = GitLab user e-mails
cn = `git log #{shanew} --pretty=format:%cn --max-count=1`
ce = `git log #{shanew} --pretty=format:%ce --max-count=1`
gln = `psql -h localhost -At -d gitlab -c "select username from users;"`
gln = gln.split("\n")
gle = `psql -h localhost -At -d gitlab -c "select email from users;"`
gle = gle.split("\n")

## loop all GitLab usernames and compare with committers name
found = 0
for username in gln
  if username == cn
    found = 1
  end
end

## reject push
if found == 0
  puts "Rejected push because of unknown committer '#{cn}'"
  exit 1
end

## do original GitLab code
GitlabUpdate.new(repo_path, key_id, refname).exec

-- 
You received this message because you are subscribed to the Google Groups 
"GitLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to gitlabhq+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/gitlabhq/4e76a552-78e2-45dd-a32d-6fae7468103c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to