Error in commit hook?

91 views
Skip to first unread message

Jacek Ziora

unread,
Jun 17, 2016, 7:49:07 AM6/17/16
to Repo and Gerrit Discussion
Hi!

I think that I found an error in commit-msg hook in gerrit.

From documentation:
"The hook implementation is reasonably intelligent at inserting the Change-Id line before any Signed-off-by or Acked-by lines placed at the end of the commit message by the author, but if no such lines are present then it will just insert a blank line, and add the Change-Id at the bottom of the message."

In my commit messages I have always this in footer:
git-svn-id: <repo_name> <hash>

And commit-msg hook adds Change-Id before this, so I have:

Change-Id: I4b186c6b4582104c1b91d36fe93d4613783c490b
git-svn-id: <repo_name> <hash>

BUT!
Sometimes (about 2% of commits) situation is that Change-Id is added with the blank line between Change-Id and git-svn-id, like this:

Change-Id: I4b186c6b4582104c1b91d36fe93d4613783c490b

git-svn-id: <repo_name> <hash>

And then gerrit doesn't allow to push such commit with error:
ERROR: missing Change-Id in commit message

When I remove this blank line (using git commit --amend) and push again - everything works.
But the problem is, that I push commits using script and when one push failed, no more commits are pushed...
I will try to edit this commit hook to add Change-Id on the last line of commit msg, but I think this doesn't work properly.

Best regards,
Jacek Ziora

Edwin Kempin

unread,
Jun 17, 2016, 8:03:01 AM6/17/16
to Jacek Ziora, Repo and Gerrit Discussion
On Fri, Jun 17, 2016 at 1:49 PM, Jacek Ziora <jacek.ad...@gmail.com> wrote:
Hi!

I think that I found an error in commit-msg hook in gerrit.

From documentation:
"The hook implementation is reasonably intelligent at inserting the Change-Id line before any Signed-off-by or Acked-by lines placed at the end of the commit message by the author, but if no such lines are present then it will just insert a blank line, and add the Change-Id at the bottom of the message."

In my commit messages I have always this in footer:
git-svn-id: <repo_name> <hash>

And commit-msg hook adds Change-Id before this, so I have:

Change-Id: I4b186c6b4582104c1b91d36fe93d4613783c490b
git-svn-id: <repo_name> <hash>

BUT!
Sometimes (about 2% of commits) situation is that Change-Id is added with the blank line between Change-Id and git-svn-id, like this:

Change-Id: I4b186c6b4582104c1b91d36fe93d4613783c490b

git-svn-id: <repo_name> <hash>
Do you add the git-svn-id footer manually or this is added by another hook?
Can it be that this other hooks runs after the commit-msg hook?
In this case it would be an issue with that other hook.

 

And then gerrit doesn't allow to push such commit with error:
ERROR: missing Change-Id in commit message

When I remove this blank line (using git commit --amend) and push again - everything works.
But the problem is, that I push commits using script and when one push failed, no more commits are pushed...
I will try to edit this commit hook to add Change-Id on the last line of commit msg, but I think this doesn't work properly.

Best regards,
Jacek Ziora

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Jacek Ziora

unread,
Jun 17, 2016, 8:44:32 AM6/17/16
to Repo and Gerrit Discussion, jacek.ad...@gmail.com
git-svn-id is added automatically before the commit-msg hook runs.

Jacek Ziora

unread,
Jun 20, 2016, 4:18:58 AM6/20/16
to Edwin Kempin, Repo and Gerrit Discussion
Forward back to main discussion.
Another commit came and error occurred again. This commit doesn't differ from other commits. I will try to modify this hook, but I think it doesn't work properly.



2016-06-17 15:02 GMT+02:00 Jacek Ziora <jacek.ad...@gmail.com>:
Yes, I am 100% sure, because I have additional repo between original repo and gerrit repo. So the flow is:
original_repo (here git-svn-id is added) ----> gerrit_transfer_repo ---- < push-to-gerrit script (here Change-Id is added) > ----> Gerrit_repo


2016-06-17 14:49 GMT+02:00 Edwin Kempin <eke...@google.com>:

On Fri, Jun 17, 2016 at 2:44 PM, Jacek Ziora <jacek.ad...@gmail.com> wrote:
git-svn-id is added automatically before the commit-msg hook runs.
Are you sure that it is also added before the commit-msg hook runs for those 2% of commits where the footers are incorrect?
Maybe in case of those 2% it's run afterwards?

Björn Pedersen

unread,
Jul 5, 2016, 12:38:55 PM7/5/16
to Repo and Gerrit Discussion, eke...@google.com


Am Montag, 20. Juni 2016 10:18:58 UTC+2 schrieb Jacek Ziora:
Forward back to main discussion.
Another commit came and error occurred again. This commit doesn't differ from other commits. I will try to modify this hook, but I think it doesn't work properly.



2016-06-17 15:02 GMT+02:00 Jacek Ziora <jacek.ad...@gmail.com>:
Yes, I am 100% sure, because I have additional repo between original repo and gerrit repo. So the flow is:
original_repo (here git-svn-id is added) ----> gerrit_transfer_repo ---- < push-to-gerrit script (here Change-Id is added) > ----> Gerrit_repo

This is the way from svn to gerrit. Is the other way also implemented? Because I still think that the  git-svn hook is possible causing your troubles (check if the offending changes started from gerrit and where then transfered back to svn).

Björn

Jacek Ziora

unread,
Jul 12, 2016, 5:40:11 AM7/12/16
to Repo and Gerrit Discussion, eke...@google.com
Hi Björn,

Actually, there is no way back from gerrit to svn repo. So the flow I have shown is the only way.

I thought I've fixed this modifying commit hook. I added to CHANGE_ID_AFTER "|git-svn-id"
And it was OK for couple of days.
Today I've noticed that commit msg is wrong again and commit push FAILED.

Commit msg content:
"Change <file> to <file> and change ****** core id.

Change-Id: I15db7599eee07df08cccae00e9461e063185a4ba

git-svn-id: <repo_address>/trunk@396008 b3e923c4-5104-4be0-ac5e-26e73b769f6b "


I have no more ideas how to change commit msg hook to work properly.

What is interesting, every time when commit hook doesn't work, committer is from China. Do you have any ideas how it can be related?

Best regards,
Jacek Ziora

David Pursehouse

unread,
Jul 12, 2016, 5:43:18 AM7/12/16
to Jacek Ziora, Repo and Gerrit Discussion, eke...@google.com
Could it be something related to character encoding in the commit message text?

Jacek Ziora

unread,
Jul 12, 2016, 6:03:27 AM7/12/16
to Repo and Gerrit Discussion, jacek.ad...@gmail.com, eke...@google.com
Hmm, but then all commits from China should be broken. This situation seems to occur randomly to me...

David Pursehouse

unread,
Jul 12, 2016, 9:19:19 PM7/12/16
to Jacek Ziora, Repo and Gerrit Discussion, eke...@google.com
On Tue, Jul 12, 2016 at 7:03 PM Jacek Ziora <jacek.ad...@gmail.com> wrote:
Hmm, but then all commits from China should be broken. This situation seems to occur randomly to me...


Not necessarily.  There may be some users using a different encoding.

 
Reply all
Reply to author
Forward
0 new messages