Fix refPattern when using username/shardeduserid pattern with regexp
The special regexp caracters ('{', '}') from gerrit pattern are causing
an exception. As ${username} and ${shardeduserid} are only meaningful to
gerrit, we substitute them for placeholders.
Unlike what is done in RefPatternMatcher.ExpandParameters, the
placeholder does not contain ':' but '_' to be correctly evaluated by
Repository.isValidRefName later on.
Bug: Issue 3340
Change-Id: Iedf3022f6ce3068f7e9534f224cf05bb99b0f970
This commit is contained in:
committed by
David Pursehouse
parent
9a5141f0ad
commit
1b4b264adf
@@ -525,6 +525,13 @@ public class RefControlTest {
|
||||
assertCanUpload(u);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void usernamePatternRegExpCanUploadToAnyRef() throws Exception {
|
||||
allow(local, PUSH, REGISTERED_USERS, "^refs/heads/users/${username}/(public|private)/.+");
|
||||
ProjectControl u = user(local, "a-registered-user");
|
||||
assertCanUpdate("refs/heads/users/a-registered-user/private/a", u);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void usernamePatternNonRegex() throws Exception {
|
||||
allow(local, READ, DEVS, "refs/sb/${username}/heads/*");
|
||||
@@ -943,6 +950,7 @@ public class RefControlTest {
|
||||
RefPattern.validate("^refs/heads/*");
|
||||
RefPattern.validate("^refs/tags/[0-9a-zA-Z-_.]+");
|
||||
RefPattern.validate("refs/heads/review/${username}/*");
|
||||
RefPattern.validate("^refs/heads/review/${username}/.+");
|
||||
}
|
||||
|
||||
@Test(expected = InvalidNameException.class)
|
||||
|
||||
Reference in New Issue
Block a user