Allow mutating BranchOrder in project.config and add a test
This allows testing different behavior of change mergeability added in I6ab0b73. Change-Id: Id3bc861367443651a85cd57f1bfd0bdd55fd27f2
This commit is contained in:
@@ -357,6 +357,10 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
||||
return branchOrderSection;
|
||||
}
|
||||
|
||||
public void setBranchOrderSection(BranchOrderSection branchOrderSection) {
|
||||
this.branchOrderSection = branchOrderSection;
|
||||
}
|
||||
|
||||
public Map<Project.NameKey, SubscribeSection> getSubscribeSections() {
|
||||
return subscribeSections;
|
||||
}
|
||||
@@ -814,6 +818,12 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
||||
}
|
||||
}
|
||||
|
||||
private void saveBranchOrderSection(Config rc) {
|
||||
if (branchOrderSection != null) {
|
||||
rc.setStringList(BRANCH_ORDER, null, BRANCH, branchOrderSection.order());
|
||||
}
|
||||
}
|
||||
|
||||
private ImmutableList<String> loadPatterns(
|
||||
Config rc, String section, String subsection, String varName) {
|
||||
ImmutableList.Builder<String> patterns = ImmutableList.builder();
|
||||
@@ -1176,6 +1186,7 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
||||
saveLabelSections(rc);
|
||||
saveCommentLinkSections(rc);
|
||||
saveSubscribeSections(rc);
|
||||
saveBranchOrderSection(rc);
|
||||
|
||||
saveConfig(PROJECT_CONFIG, rc);
|
||||
saveGroupList();
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.google.gerrit.server.config.AllProjectsName;
|
||||
import com.google.gerrit.server.config.PluginConfig;
|
||||
import com.google.gerrit.server.config.SitePaths;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.git.BranchOrderSection;
|
||||
import com.google.gerrit.server.git.ValidationError;
|
||||
import com.google.gerrit.server.git.meta.MetaDataUpdate;
|
||||
import com.google.gerrit.server.project.testing.TestLabels;
|
||||
@@ -360,6 +361,31 @@ public class ProjectConfigTest {
|
||||
+ "\tvalue = +1 Positive\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readExistingBranchOrder() throws Exception {
|
||||
RevCommit rev =
|
||||
tr.commit()
|
||||
.add("project.config", "[branchOrder]\n" + "\tbranch = foo\n" + "\tbranch = bar\n")
|
||||
.create();
|
||||
update(rev);
|
||||
|
||||
ProjectConfig cfg = read(rev);
|
||||
assertThat(cfg.getBranchOrderSection())
|
||||
.isEqualTo(BranchOrderSection.create(ImmutableList.of("foo", "bar")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void editBranchOrder() throws Exception {
|
||||
RevCommit rev = tr.commit().create();
|
||||
update(rev);
|
||||
|
||||
ProjectConfig cfg = read(rev);
|
||||
cfg.setBranchOrderSection(BranchOrderSection.create(ImmutableList.of("foo", "bar")));
|
||||
rev = commit(cfg);
|
||||
assertThat(text(rev, "project.config"))
|
||||
.isEqualTo("[branchOrder]\n" + "\tbranch = foo\n" + "\tbranch = bar\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addCommentLink() throws Exception {
|
||||
RevCommit rev = tr.commit().create();
|
||||
|
||||
Reference in New Issue
Block a user