gitlab hook declined错误

在向gitlab提交工程的时候,出现错误提示:

remote: GitLab: You are not allowed to access master!
remote: error: hook declined to update refs/heads/master
To sa_gitlab@192.168.xxx:xxx/xxx.git
! [remote rejected] master -> master (hook declined)

这个问题主要是由于git工程里的hooks/post-receive和update引起的。可以删除这两个文件;

但是问题的根源不在这,在新建工程的hooks里面的这两个文件只是ln -s 出来的软链接,关键问题是,这两个软链接链错了位置。

查看 gitlab-shell/lib/gitlab_project.rb这个创建新工程的文件,里面有

def add_project
   FileUtils.mkdir_p(full_path, mode: 0770)
   #cmd = "cd #{full_path} && git init --bare && #{create_hooks_cmd}"
   cmd = "cd #{full_path} && git init --bare"
   system(cmd)
 end
 def create_hooks_cmd
   pr_hook_path = File.join(ROOT_PATH, 'hooks', 'post-receive')
   up_hook_path = File.join(ROOT_PATH, 'hooks', 'update')
   #2013年11月5日 <feixiang> path alway add /home/repositories/ ,but what we want is a absolute path , comment it
   "ln -s #{pr_hook_path} #{full_path}/hooks/post-receive && ln -s #{up_hook_path} #{full_path}/hooks/update"
 end

把create_hooks_cmd注释了即可,但是,这样在后面如果要在网页修改hooks的话,可能还会出问题...

posted @ 2013-11-05 15:36  ifeixiang  阅读(55866)  评论(0编辑  收藏  举报