Merge branch 'stable-2.6'

* stable-2.6:
  Grant most permissions when creating All-Projects
  Don't create verified category by default
  Cleanup ugly trailing comments when creating All-Projects
  Enable content merge by default
  Change the default description for All-Projects
  Rename initWildCardProject to initAllProjects
  Highlight optimized clone and workflow on 2.6
This commit is contained in:
Shawn Pearce
2013-03-28 23:20:29 -04:00
4 changed files with 121 additions and 95 deletions

View File

@@ -5,56 +5,10 @@ As part of the code review process, reviewers score each change with
values for each label configured for the project. The label values that
a given user is allowed to set are defined according to the
link:access-control.html#access_labels[access controls]. Gerrit comes
pre-configured with several default labels that can be granted to groups
pre-configured with the Code-Review label that can be granted to groups
within projects, enabling functionality for that group's members.
[[label_Verified]]
Label: Verified
---------------
The verified label is one of two default labels that is configured upon
the creation of a Gerrit instance. It may have any meaning the project
desires. It was originally invented by the Android Open Source Project
to mean 'compiles, passes basic unit tests'.
The range of values is:
* -1 Fails
+
Tried to compile, but got a compile error, or tried to run tests,
but one or more tests did not pass.
+
*Any -1 blocks submit.*
* 0 No score
+
Didn't try to perform the verification tasks.
* +1 Verified
+
Compiled (and ran tests) successfully.
+
*Any +1 enables submit.*
For a change to be submittable, the change must have a `+1 Verified`
in this label, and no `-1 Fails`. Thus, `-1 Fails` can block a submit,
while `+1 Verified` enables a submit.
If a Gerrit installation does not wish to use this label in any project,
the `[label "Verified"]` section can be deleted from `project.config` in
`All-Projects`.
If a Gerrit installation or project wants to modify the description text
associated with these label values, the text can be updated in the
`label.Verified.value` fields in `project.config`.
Additional values could also be added to this label, to allow it to
behave more like `Code-Review` (below). Add -2 and +2 entries to the
`label.Verified.value` fields in `project.config` to get the same
behavior.
[[label_Code-Review]]
Label: Code-Review
------------------
@@ -128,6 +82,54 @@ label is a `MaxWithBlock` type, which means that the lowest negative
value if present blocks a submit, while the highest positive value is
required to enable submit.
[[label_Verified]]
Label: Verified
---------------
The Verified label was originally invented by the Android Open Source
Project to mean 'compiles, passes basic unit tests'. Some CI tools
expect to use the Verified label to vote on a change after running.
Administrators can install the Verified label by adding the following
text to `project.config`:
====
[label "Verified"]
functionName = MaxWithBlock
value = -1 Fails
value = 0 No score
value = +1 Verified
====
The range of values is:
* -1 Fails
+
Tried to compile, but got a compile error, or tried to run tests,
but one or more tests did not pass.
+
*Any -1 blocks submit.*
* 0 No score
+
Didn't try to perform the verification tasks.
* +1 Verified
+
Compiled (and ran tests) successfully.
+
*Any +1 enables submit.*
For a change to be submittable, the change must have a `+1 Verified`
in this label, and no `-1 Fails`. Thus, `-1 Fails` can block a submit,
while `+1 Verified` enables a submit.
Additional values could also be added to this label, to allow it to
behave more like `Code-Review` (below). Add -2 and +2 entries to the
`label.Verified.value` fields in `project.config` to get the same
behavior.
[[label_custom]]
Your Label Here
---------------

View File

@@ -21,6 +21,23 @@ Schema Change
a later 2.1.x version), and then to 2.6.x. If you are upgrading from 2.2.x.x or
newer, you may ignore this warning and upgrade directly to 2.6.x.
Release Highlights
------------------
* 42x improvement on `git clone` and `git fetch`
+
Running link:http://gerrit-documentation.googlecode.com/svn/Documentation/2.6/cmd-gc.html[
gerrit gc] allows JGit to optimize a repository to serve clone and fetch
faster than C Git can, with massively lower server CPU required. Typically
Gerrit 2.6 can completely transfer a project to a client faster than C Git
can finish "Counting" the objects.
* Completely customizable workflow
+
Individual projects can add (or remove) score categories through
link:http://gerrit-documentation.googlecode.com/svn/Documentation/2.6/config-labels.html[
labels] and link:http://gerrit-documentation.googlecode.com/svn/Documentation/2.6/prolog-cookbook.html[
Prolog rules].
New Features
------------
@@ -740,7 +757,7 @@ Performance
* Bitmap Optimizations
+
On running the http://gerrit-documentation.googlecode.com/svn/Documentation/2.6/cmd-gc.html[
garbage collection] Jgit creates bitmap data that is saved to an
garbage collection] JGit creates bitmap data that is saved to an
auxiliary file. The bitmap optimizations improve the clone and fetch
performance. git-core will ignore the bitmap data.

View File

@@ -110,7 +110,7 @@ public class SchemaCreator {
db.schemaVersion().insert(Collections.singleton(sVer));
initSystemConfig(db);
initWildCardProject();
initAllProjects();
dataSourceType.getIndexScript().run(db);
}
@@ -177,17 +177,17 @@ public class SchemaCreator {
return s;
}
private void initWildCardProject() throws IOException, ConfigInvalidException {
private void initAllProjects() throws IOException, ConfigInvalidException {
Repository git = null;
try {
git = mgr.openRepository(allProjectsName);
initWildCardProject(git);
initAllProjects(git);
} catch (RepositoryNotFoundException notFound) {
// A repository may be missing if this project existed only to store
// inheritable permissions. For example 'All-Projects'.
try {
git = mgr.createRepository(allProjectsName);
initWildCardProject(git);
initAllProjects(git);
final RefUpdate u = git.updateRef(Constants.HEAD);
u.link(GitRepositoryManager.REF_CONFIG);
} catch (RepositoryNotFoundException err) {
@@ -201,7 +201,7 @@ public class SchemaCreator {
}
}
private void initWildCardProject(Repository git) throws IOException,
private void initAllProjects(Repository git) throws IOException,
ConfigInvalidException {
MetaDataUpdate md =
new MetaDataUpdate(GitReferenceUpdated.DISABLED, allProjectsName, git);
@@ -210,59 +210,75 @@ public class SchemaCreator {
ProjectConfig config = ProjectConfig.read(md);
Project p = config.getProject();
p.setDescription("Rights inherited by all other projects");
p.setDescription("Access inherited by all other projects.");
p.setRequireChangeID(InheritableBoolean.TRUE);
p.setUseContentMerge(InheritableBoolean.FALSE);
p.setUseContentMerge(InheritableBoolean.TRUE);
p.setUseContributorAgreements(InheritableBoolean.FALSE);
p.setUseSignedOffBy(InheritableBoolean.FALSE);
AccessSection cap = config.getAccessSection(AccessSection.GLOBAL_CAPABILITIES, true);
AccessSection all = config.getAccessSection(AccessSection.ALL, true);
AccessSection heads = config.getAccessSection(AccessSection.HEADS, true);
AccessSection tags = config.getAccessSection("refs/tags/*", true);
AccessSection meta = config.getAccessSection(GitRepositoryManager.REF_CONFIG, true);
AccessSection magic = config.getAccessSection("refs/for/" + AccessSection.ALL, true);
cap.getPermission(GlobalCapability.ADMINISTRATE_SERVER, true)
.add(rule(config, admin));
grant(config, cap, GlobalCapability.ADMINISTRATE_SERVER, admin);
grant(config, all, Permission.READ, admin, anonymous);
PermissionRule review = rule(config, registered);
review.setRange(-1, 1);
heads.getPermission(Permission.LABEL + "Code-Review", true).add(review);
LabelType cr = initCodeReviewLabel(config);
grant(config, heads, cr, -1, 1, registered);
grant(config, heads, cr, -2, 2, admin, owners);
grant(config, heads, Permission.CREATE, admin, owners);
grant(config, heads, Permission.PUSH, admin, owners);
grant(config, heads, Permission.SUBMIT, admin, owners);
grant(config, heads, Permission.FORGE_AUTHOR, registered);
grant(config, heads, Permission.FORGE_COMMITTER, admin, owners);
all.getPermission(Permission.READ, true) //
.add(rule(config, admin));
all.getPermission(Permission.READ, true) //
.add(rule(config, anonymous));
grant(config, tags, Permission.PUSH_TAG, admin, owners);
grant(config, tags, Permission.PUSH_SIGNED_TAG, admin, owners);
config.getAccessSection("refs/for/" + AccessSection.ALL, true) //
.getPermission(Permission.PUSH, true) //
.add(rule(config, registered));
all.getPermission(Permission.FORGE_AUTHOR, true) //
.add(rule(config, registered));
grant(config, magic, Permission.PUSH, registered);
grant(config, magic, Permission.PUSH_MERGE, registered);
Permission metaReadPermission = meta.getPermission(Permission.READ, true);
metaReadPermission.setExclusiveGroup(true);
metaReadPermission.add(rule(config, owners));
initVerifiedLabel(config);
initCodeReviewLabel(config);
meta.getPermission(Permission.READ, true).setExclusiveGroup(true);
grant(config, meta, Permission.READ, admin, owners);
grant(config, meta, cr, -2, 2, admin, owners);
grant(config, meta, Permission.PUSH, admin, owners);
grant(config, meta, Permission.SUBMIT, admin, owners);
md.setMessage("Initialized Gerrit Code Review " + Version.getVersion());
config.commit(md);
}
private PermissionRule grant(ProjectConfig config, AccessSection section,
String permission, AccountGroup group1, AccountGroup... groupList) {
Permission p = section.getPermission(permission, true);
PermissionRule rule = rule(config, group1);
p.add(rule);
for (AccountGroup group : groupList) {
p.add(rule(config, group));
}
return rule;
}
private void grant(ProjectConfig config,
AccessSection section, LabelType type,
int min, int max, AccountGroup... groupList) {
String name = Permission.LABEL + type.getName();
Permission p = section.getPermission(name, true);
for (AccountGroup group : groupList) {
PermissionRule r = rule(config, group);
r.setRange(min, max);
p.add(r);
}
}
private PermissionRule rule(ProjectConfig config, AccountGroup group) {
return new PermissionRule(config.resolve(group));
}
public static void initVerifiedLabel(ProjectConfig c) {
LabelType type = new LabelType("Verified", ImmutableList.of(
new LabelValue((short) 1, "Verified"),
new LabelValue((short) 0, "No score"),
new LabelValue((short) -1, "Fails")));
c.getLabelSections().put(type.getName(), type);
}
public static void initCodeReviewLabel(ProjectConfig c) {
public static LabelType initCodeReviewLabel(ProjectConfig c) {
LabelType type = new LabelType("Code-Review", ImmutableList.of(
new LabelValue((short) 2, "Looks good to me, approved"),
new LabelValue((short) 1, "Looks good to me, but someone else must approve"),
@@ -272,5 +288,6 @@ public class SchemaCreator {
type.setAbbreviatedName("CR");
type.setCopyMinScore(true);
c.getLabelSections().put(type.getName(), type);
return type;
}
}

View File

@@ -107,17 +107,7 @@ public class SchemaCreatorTest extends TestCase {
for (LabelType label : getLabelTypes().getLabelTypes()) {
labels.add(label.getName());
}
assertEquals(ImmutableList.of("Verified", "Code-Review"), labels);
}
public void testCreateSchema_Label_Verified() throws Exception {
LabelType verified = getLabelTypes().byLabel("Verified");
assertNotNull(verified);
assertEquals("Verified", verified.getName());
assertEquals("V", verified.getAbbreviatedName());
assertEquals("MaxWithBlock", verified.getFunctionName());
assertFalse(verified.isCopyMinScore());
assertValueRange(verified, 1, 0, -1);
assertEquals(ImmutableList.of("Code-Review"), labels);
}
public void testCreateSchema_Label_CodeReview() throws Exception {