New issue
Advanced search Search tips
Starred by 3 users

Issue metadata

Status: Submitted
Owner: ----
Closed: May 16
Cc:
Components:



Sign in to add a comment

No hook is fired when a change is submitted

Reported by igor.lit...@gmail.com, May 15

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 com.google.gerrit.server.git.validators.RefOperationValidators : 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.

 
Project Member

Comment 1 by thomasmu...@yahoo.com, May 15

Cc: david.pu...@gmail.com
Components: -PolyGerrit
Components: plugins>hooks
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 
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.
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.

[1] https://gerrit-review.googlesource.com/c/plugins/hooks/+/178751
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.
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

[1] https://gerrit-review.googlesource.com/c/plugins/hooks/+/178770

Sign in to add a comment