use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class AgreementsIT method setUseContributorAgreements.
protected void setUseContributorAgreements(InheritableBoolean value) throws Exception {
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
ProjectConfig config = projectConfigFactory.read(md);
config.updateProject(p -> p.setBooleanConfig(BooleanProjectConfig.USE_CONTRIBUTOR_AGREEMENTS, value));
config.commit(md);
projectCache.evictAndReindex(config.getProject());
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class GroupsUpdate method commit.
private void commit(Repository allUsersRepo, GroupConfig groupConfig, @Nullable GroupNameNotes groupNameNotes) throws IOException {
BatchRefUpdate batchRefUpdate = allUsersRepo.getRefDatabase().newBatchUpdate();
try (MetaDataUpdate metaDataUpdate = metaDataUpdateFactory.create(allUsersName, allUsersRepo, batchRefUpdate)) {
groupConfig.commit(metaDataUpdate);
}
if (groupNameNotes != null) {
// MetaDataUpdates unfortunately can't be reused. -> Create a new one.
try (MetaDataUpdate metaDataUpdate = metaDataUpdateFactory.create(allUsersName, allUsersRepo, batchRefUpdate)) {
groupNameNotes.commit(metaDataUpdate);
}
}
RefUpdateUtil.executeChecked(batchRefUpdate, allUsersRepo);
gitRefUpdated.fire(allUsersName, batchRefUpdate, currentUser.map(user -> user.state()).orElse(null));
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class Schema_184 method commit.
private void commit(AllUsersName allUsersName, PersonIdent serverUser, Repository allUsersRepo, GroupConfig groupConfig, GroupNameNotes groupNameNotes) throws IOException {
BatchRefUpdate batchRefUpdate = allUsersRepo.getRefDatabase().newBatchUpdate();
try (MetaDataUpdate metaDataUpdate = createMetaDataUpdate(allUsersName, serverUser, allUsersRepo, batchRefUpdate)) {
groupConfig.commit(metaDataUpdate);
}
// MetaDataUpdates unfortunately can't be reused. -> Create a new one.
try (MetaDataUpdate metaDataUpdate = createMetaDataUpdate(allUsersName, serverUser, allUsersRepo, batchRefUpdate)) {
groupNameNotes.commit(metaDataUpdate);
}
RefUpdateUtil.executeChecked(batchRefUpdate, allUsersRepo);
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class AbstractSubmoduleSubscription method allowSubmoduleSubscription.
protected void allowSubmoduleSubscription(Project.NameKey submodule, String subBranch, Project.NameKey superproject, String superBranch, boolean match) throws Exception {
try (MetaDataUpdate md = metaDataUpdateFactory.create(submodule)) {
md.setMessage("Added superproject subscription");
SubscribeSection.Builder s;
ProjectConfig pc = projectConfigFactory.read(md);
if (pc.getSubscribeSections().containsKey(superproject)) {
s = pc.getSubscribeSections().get(superproject).toBuilder();
} else {
s = SubscribeSection.builder(superproject);
}
String refspec;
if (superBranch == null) {
refspec = subBranch;
} else {
refspec = subBranch + ":" + superBranch;
}
if (match) {
s.addMatchingRefSpec(refspec);
} else {
s.addMultiMatchRefSpec(refspec);
}
pc.addSubscribeSection(s.build());
ObjectId oldId = pc.getRevision();
ObjectId newId = pc.commit(md);
assertThat(newId).isNotEqualTo(oldId);
projectCache.evictAndReindex(pc.getProject());
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class AbstractGroupTest method createMetaDataUpdate.
protected MetaDataUpdate createMetaDataUpdate(PersonIdent authorIdent) {
MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED, allUsersName, allUsersRepo);
md.getCommitBuilder().setAuthor(authorIdent);
// Committer is always the server identity.
md.getCommitBuilder().setCommitter(serverIdent);
return md;
}
Aggregations