New issue
Advanced search Search tips
Starred by 3 users

Issue metadata

Status: Submitted
Owner: ----
Closed: May 2018

Sign in to add a comment

Issue 9015: No hook is fired when a change is submitted

Reported by, May 15 2018

Issue description

Affected Version: 2.14.6

What steps will reproduce the problem?
1. I created a hook ref-update which always exits with rc=2

2. Direct push to refs/heads/master fails as expected:
   	git push origin master
	remote: error: --project test/super --uploader UPLOADER_EMAIL_REMOVED --oldrev 90ef80caf0aaaa256557c0fa3303104974985e32 --newrev 7c39280db6fbba747859369334f285e51299e521 --refname refs/heads/master
	To ssh://gerrit:29418/test/super
	 ! [remote rejected] master -> master (Ref "refs/heads/master" UPDATE in project test/super validation failed
	--project test/super --uploader UPLOADER_EMAIL_REMOVED --oldrev 90ef80caf0aaaa256557c0fa3303104974985e32 --newrev 7c39280db6fbba747859369334f285e51299e521 --refname refs/heads/master)
	error: failed to push some refs to 'ssh://gerrit:29418/test/super'
   Output in gerrit log:
	[2018-05-15 12:01:52,960] [SyncHook-6] DEBUG com.googlesource.gerrit.plugins.hooks.HookTask : hook[ref-update] exitValue: 2
	[2018-05-15 12:01:52,961] [SyncHook-6] DEBUG com.googlesource.gerrit.plugins.hooks.HookTask : hook[ref-update] output: --project test/super --uploader UPLOADER_EMAIL_REMOVED --oldrev 90ef80caf0aaaa256557c0fa3303104974985e32 --newrev 7c39280db6fbba747859369334f285e51299e521 --refname refs/heads/master
	[2018-05-15 12:01:52,961] [ReceiveCommits-1] ERROR : Ref "refs/heads/master" UPDATE in project test/super validation failed	

3. Same commit was uploaded to gerrit as new change. Gerrit allowed to submit the change via web UI, i.e. ref-update was not fired.

What is the expected output?
Since refs/heads/master is updated on change submit, the expected output is error with stdout and stderr from ref-update hook.

What do you see instead?
The change was submitted, master branch updated. The output from gerrit log:
	[2018-05-15 12:09:57,766] [HTTP-77] INFO  com.googlesource.gerrit.plugins.footers.SubmitListener : Repository: Repository[/home/gerrit2/review_site/git/test/super.git]

Please provide any additional information below.

Comment 1 by, May 15 2018

Project Member
Components: -PolyGerrit

Comment 2 by, May 16 2018

Components: plugins>hooks

Comment 3 by, May 16 2018

Status: WontFix (was: New)
The behavior of the ref-update hook was changed in 2.14

To prevent commits being pushed for review, use the commit-received hook instead.

See  issue 5739 

Comment 4 by, May 16 2018

My intention was to use ref-update hook to prevent updating superproject branch with commit that refers submodule commit, which is not yet in any branch. I know that this check can be done in commit-receive hook, however this is not sufficient. Here is the use case:

1. Two commits are pushed to gerrit - one commit in submodule, one commit in superproject with reference to submodule commit.

2. Superproject commit is merged before submodule commit. This creates the situation when a cloned superproject branch contains a reference to a non-reachable commit in submodule.

Comment 5 by, May 16 2018

I think the reworking of ref-update (and addition of commit-received) has caused more confusion than intended :(

I've just done some changes to the documentation that will hopefully clarify the intended behavior of these hooks [1].

And to solve the use case that you are describing, I propose to add a new hook (called "presubmit" or something similar) that will run on the MergeValidationListener interface. It would be a synchronous hook that is able to block submit.


Comment 6 by, May 16 2018

I still think that having a hook that fires when any standard reference is updated would be more convenient. It will be a single place to validate branch update.

However as far as I can see synchronous presubmit also can solve the issue.

Comment 7 by, May 18 2018

Status: Submitted (was: WontFix)
Summary: No hook is fired when a change is submitted (was: Hook ref-update not fired when submitting change)
The submit hook was implemented in [1] and will be in 2.14.9


Sign in to add a comment