Skip to content

Commit d1c4b37

Browse files
committed
treat all refs/users/.* references as internal and to be ignored
We noticed that Gerrit can create some references using the following naming scheme: refs/users/<last-2-digits-of-userid>/<userid> When it does, this causes the hooks to fail with a message indicating that it is unable to determine the type of reference it is, because it doesn't recognize it. This commit changes the hooks.ignore-refs default configuration to ignore all references whose name start with "refs/users/". We could be stricter in our matching, but I think this would be slightly overkill. And meanwhile, we can see that this is not the first time we notice that references in the "refs/users/" namespace where created by Gerrit (e.g. we were already ignoring references matching "refs/users/.*/edit-.*" before). So, being being more relaxed here helps us avoid having to change the config again in the future should Gerrit decide to expand on its use of this namespace. Change-Id: I3196cfc833ac94473d4b5fcdca773ded4ced24cf TN: V218-013
1 parent f92492c commit d1c4b37

5 files changed

Lines changed: 30 additions & 1 deletion

File tree

hooks/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# being garbage-collected.
1919
GERRIT_INTERNAL_REFS = (
2020
"refs/changes/.*",
21-
"refs/users/.*/edit-.*",
21+
"refs/users/.*",
2222
"refs/cache-automerge/.*",
2323
"refs/sequences/.*",
2424
"refs/groups/.*",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[core]
2+
repositoryformatversion = 0
3+
filemode = true
4+
bare = true
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[hooks]
2+
from-domain = adacore.com
3+
mailinglist = git-hooks-ci@example.com
4+
filer-email = filer@example.com
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def test_push_commit_to_ignored_ref(testcase):
2+
"""Try pushing master to a reference that's configured to be ignored."""
3+
4+
# Simulate one action that Gerrit does, which is to create
5+
# some "Special references" which are internal to its operations.
6+
# For instance, "refs/users/<last-2-digits-of-userid>/<userid>".
7+
#
8+
# The purpose of this testcase is to verify that the push is completely
9+
# ignored by the git-hooks (in particular no check, no style check, and
10+
# no emails).
11+
12+
p = testcase.run("git push origin master:refs/users/01/104201".split())
13+
expected_out = testcase.massage_git_output(
14+
"""\
15+
To ../bare/repo.git
16+
* [new reference] master -> refs/users/01/104201
17+
"""
18+
)
19+
20+
testcase.assertEqual(p.status, 0, p.image)
21+
testcase.assertRunOutputEqual(p, expected_out)

0 commit comments

Comments
 (0)