Merge branch 'stable-2.10'

* stable-2.10:
  Update 2.9.1 release notes again
  Update 2.9.1 release notes
  Fix: permission on user specific reference name cannot work

Change-Id: I93a11945f1aad88ae617b415bc40397af2291b21
This commit is contained in:
David Pursehouse 2014-09-11 16:48:28 +02:00
commit c67a13c06f
3 changed files with 27 additions and 3 deletions

View File

@ -97,3 +97,9 @@ Display parents for all changes, not only merge commits.
In the new change screen the parent commit is now also shown for regular
commits, as well as merge commits. This makes it consistent with the old
change screen.
* Fix handling of permissions for user-specific refs.
+
Push permission granted on a ref using the `${username}` placeholder, for
example `refs/heads/users/${username}/*`, was not honored if this was the
only ref on which the user had push permission.

View File

@ -113,13 +113,24 @@ public abstract class RefPatternMatcher {
u = username;
}
RefPatternMatcher next =
getMatcher(template.replace(Collections.singletonMap("username", u)));
return next != null && next.match(ref, username);
RefPatternMatcher next = getMatcher(expand(template, u));
return next != null ? next.match(expand(ref, u), username) : false;
}
boolean matchPrefix(String ref) {
return ref.startsWith(prefix);
}
private String expand(String parameterizedRef, String userName) {
if (parameterizedRef.contains("${")) {
return expand(new ParameterizedString(parameterizedRef), userName);
}
return parameterizedRef;
}
private String expand(ParameterizedString parameterizedRef, String userName) {
return parameterizedRef.replace(Collections.singletonMap("username",
userName));
}
}
}

View File

@ -262,6 +262,13 @@ public class RefControlTest {
u.controlForRef("refs/heads/master").canUpload());
}
@Test
public void testUsernamePatternCanUploadToAnyRef() {
grant(local, PUSH, REGISTERED_USERS, "refs/heads/users/${username}/*");
ProjectControl u = util.user(local, "a-registered-user");
assertTrue("can upload", u.canPushToAtLeastOneRef() == Capable.OK);
}
@Test
public void testUsernamePatternNonRegex() {
allow(local, READ, DEVS, "refs/sb/${username}/heads/*");