Bug 215002 - www/gitlab: pre-receive hook declined
Summary: www/gitlab: pre-receive hook declined
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Torsten Zuehlsdorff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-02 13:32 UTC by Julien Cigar
Modified: 2016-12-02 14:11 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (tz)


Attachments
Add missing files to gitlab-shell (1.42 KB, patch)
2016-12-02 13:52 UTC, Torsten Zuehlsdorff
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Julien Cigar 2016-12-02 13:32:50 UTC
Hello,

I have the following error after upgrading to version 8.11.11:

/usr/local/etc/salt/ git push
Enter passphrase for key '/home/jcigar/.ssh/id_rsa': 
Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 552 bytes | 0 bytes/s, done.
Total 6 (delta 3), reused 0 (delta 0)
remote: hooks/pre-receive:12:in `require_relative': cannot load such file -- /usr/local/share/gitlab-shell/lib/gitlab_reference_counter (LoadError)
remote:         from hooks/pre-receive:12:in `<main>'
To xxx.xxx.be:bbpf/saltcfg.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@xxx.xxx.be:bbpf/saltcfg.git'

any idea ...?
Comment 1 Julien Cigar 2016-12-02 13:36:16 UTC
it looks like gitlab_reference_counter.rb is missing from lib/:

█▓▒░jcigar@dev█▓▒░ Fri Dec 02 02:34:47P 
/usr/local/share/gitlab-shell/hooks/ cat pre-receive 
#!/usr/bin/env ruby

# This file was placed here by GitLab. It makes sure that your pushed commits
# will be processed properly.

refs = $stdin.read
key_id = ENV.delete('GL_ID')
protocol = ENV.delete('GL_PROTOCOL')
repo_path = Dir.pwd

require_relative '../lib/gitlab_custom_hook'
require_relative '../lib/gitlab_reference_counter'
require_relative '../lib/gitlab_access'

# It's important that on pre-receive `increase_reference_counter` gets executed
# last so that it only runs if everything else succeeded. On post-receive on the
# other hand, we run GitlabPostReceive first because the push is already done
# and we don't want to skip it if the custom hook fails.
if GitlabAccess.new(repo_path, key_id, refs, protocol).exec &&
    GitlabCustomHook.new.pre_receive(refs, repo_path) &&
    GitlabReferenceCounter.new(repo_path).increase
  exit 0
else
  exit 1
end

█▓▒░jcigar@dev█▓▒░ Fri Dec 02 02:34:49P 
/usr/local/share/gitlab-shell/hooks/ ls -l ../lib 
total 64
-r--r--r--  1 root  wheel   1018 Aug 19 20:55 gitlab_access.rb
-r--r--r--  1 root  wheel    406 Aug 19 20:55 gitlab_access_status.rb
-r--r--r--  1 root  wheel      0 Aug 19 20:55 gitlab_authorized_keys.rb
-r--r--r--  1 root  wheel    950 Aug 19 20:55 gitlab_config.rb
-r--r--r--  1 root  wheel   1403 Aug 19 20:55 gitlab_custom_hook.rb
-r--r--r--  1 root  wheel    104 Aug 19 20:55 gitlab_init.rb
-r--r--r--  1 root  wheel   3783 Aug 19 20:55 gitlab_keys.rb
-r--r--r--  1 root  wheel    394 Aug 19 20:55 gitlab_logger.rb
-r--r--r--  1 root  wheel   5122 Aug 19 20:55 gitlab_net.rb
-r--r--r--  1 root  wheel   3343 Aug 19 20:55 gitlab_post_receive.rb
-r--r--r--  1 root  wheel  10866 Aug 19 20:55 gitlab_projects.rb
-r--r--r--  1 root  wheel    100 Aug 19 20:55 gitlab_redis.rb
-r--r--r--  1 root  wheel   5176 Aug 19 20:55 gitlab_shell.rb
-r--r--r--  1 root  wheel   1462 Aug 19 20:55 httpunix.rb
-r--r--r--  1 root  wheel    296 Aug 19 20:55 names_helper.rb
drwxr-xr-x  3 root  wheel      3 Dec  1 22:43 vendor/
Comment 2 Julien Cigar 2016-12-02 13:39:55 UTC
this is with gitlab-8.11.11 and gitlab-shell-3.4.0
Comment 3 Julien Cigar 2016-12-02 13:44:22 UTC
 I checked in the gitlab repository (1) and apparently this file is included in 3.4.0, I don't know why it is not included (or has been removed) from the gitlab-shell package ..?

(1) https://gitlab.com/gitlab-org/gitlab-shell/tree/v3.4.0/lib
Comment 4 Julien Cigar 2016-12-02 13:50:15 UTC
after a:

█▓▒░jcigar@dev█▓▒░ Fri Dec 02 02:42:45P 
/usr/local/share/gitlab-shell/lib/ sudo fetch https://gitlab.com/gitlab-org/gitlab-shell/raw/v3.4.0/lib/gitlab_reference_counter.rb
gitlab_reference_counter.rb                   100% of 1032  B   12 MBps 00m00s

I have another error:

/usr/local/etc/salt/ git push
Enter passphrase for key '/home/jcigar/.ssh/id_rsa': 
Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 552 bytes | 0 bytes/s, done.
Total 6 (delta 3), reused 0 (delta 0)
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
To xxx.xxx.be:bbpf/saltcfg.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@xxx.xxx.be:bbpf/saltcfg.git'

... but that's maybe a new feature in 8.11
Comment 5 Torsten Zuehlsdorff freebsd_committer freebsd_triage 2016-12-02 13:52:17 UTC
Created attachment 177602 [details]
Add missing files to gitlab-shell

Thanks for the report and the close look into the issue!

There were two more files missing and i'm really baffled that this was not catched by my QA. :(

Please try attached patch against devel/gitlab-shell.
Comment 6 Torsten Zuehlsdorff freebsd_committer freebsd_triage 2016-12-02 13:55:13 UTC
(In reply to Julien Cigar from comment #4)

> ... but that's maybe a new feature in 8.11

Yes, it is.

The error states:

> You are not allowed to force push code to a protected branch on this project.

After you added the file the original error message is gone:

> remote: hooks/pre-receive:12:in `require_relative': cannot load such file -- 
> /usr/local/share/gitlab-shell/lib/gitlab_reference_counter (LoadError)

So please check if you get the same error message with my patch ;)
Comment 7 Julien Cigar 2016-12-02 13:57:26 UTC
ok apparently all branches become "protected" automatically during the upgrade.. so that's normal

to resume: everythihng works when the missing gitlab_reference_counter.rb is included..
Comment 8 commit-hook freebsd_committer freebsd_triage 2016-12-02 14:01:43 UTC
A commit references this bug:

Author: tz
Date: Fri Dec  2 14:01:17 UTC 2016
New revision: 427557
URL: https://svnweb.freebsd.org/changeset/ports/427557

Log:
  devel/gitlab-shell: add missing files to pkg-plist

  PR:          215002
  Reported by: Julien Cigar <julien@perdition.city>
  Approved by: mentors (implicit)

Changes:
  head/devel/gitlab-shell/Makefile
  head/devel/gitlab-shell/pkg-plist
Comment 9 Torsten Zuehlsdorff freebsd_committer freebsd_triage 2016-12-02 14:03:34 UTC
Thanks for the report and investigation! Fix is committed now!
Comment 10 Julien Cigar 2016-12-02 14:08:00 UTC
I confirm that it works with the proposed patch :) thanks for your quick reply, much appreciated!
Comment 11 Torsten Zuehlsdorff freebsd_committer freebsd_triage 2016-12-02 14:11:28 UTC
Hey, you did most of the work! I'm the one thanking :)