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:
		@@ -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
 | 
					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
 | 
					commits, as well as merge commits. This makes it consistent with the old
 | 
				
			||||||
change screen.
 | 
					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.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -113,13 +113,24 @@ public abstract class RefPatternMatcher {
 | 
				
			|||||||
        u = username;
 | 
					        u = username;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      RefPatternMatcher next =
 | 
					      RefPatternMatcher next = getMatcher(expand(template, u));
 | 
				
			||||||
          getMatcher(template.replace(Collections.singletonMap("username", u)));
 | 
					      return next != null ? next.match(expand(ref, u), username) : false;
 | 
				
			||||||
      return next != null && next.match(ref, username);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    boolean matchPrefix(String ref) {
 | 
					    boolean matchPrefix(String ref) {
 | 
				
			||||||
      return ref.startsWith(prefix);
 | 
					      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));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -262,6 +262,13 @@ public class RefControlTest {
 | 
				
			|||||||
        u.controlForRef("refs/heads/master").canUpload());
 | 
					        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
 | 
					  @Test
 | 
				
			||||||
  public void testUsernamePatternNonRegex() {
 | 
					  public void testUsernamePatternNonRegex() {
 | 
				
			||||||
    allow(local, READ, DEVS, "refs/sb/${username}/heads/*");
 | 
					    allow(local, READ, DEVS, "refs/sb/${username}/heads/*");
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user