use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.
the class SubmoduleSectionParserTest method withAnotherURI.
@Test
public void withAnotherURI() throws Exception {
Project.NameKey p = Project.nameKey("a");
Config cfg = new Config();
cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = http://localhost:80/" + p.get() + "\n" + "branch = master\n");
BranchNameKey targetBranch = BranchNameKey.create(Project.nameKey("project"), "master");
Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, BranchNameKey.create(p, "master"), "a"));
assertThat(res).containsExactlyElementsIn(expected);
}
use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.
the class SubmoduleSectionParserTest method withSubProjectFound.
@Test
public void withSubProjectFound() throws Exception {
Project.NameKey p1 = Project.nameKey("a/b");
Project.NameKey p2 = Project.nameKey("b");
Config cfg = new Config();
cfg.fromText("\n" + "[submodule \"a/b\"]\n" + "path = a/b\n" + "url = ssh://localhost/" + p1.get() + "\n" + "branch = .\n" + "[submodule \"b\"]\n" + "path = b\n" + "url = http://localhost/" + p2.get() + "\n" + "branch = .\n");
BranchNameKey targetBranch = BranchNameKey.create(Project.nameKey("project"), "master");
Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, BranchNameKey.create(p2, "master"), "b"), new SubmoduleSubscription(targetBranch, BranchNameKey.create(p1, "master"), "a/b"));
assertThat(res).containsExactlyElementsIn(expected);
}
use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.
the class SubmitByCherryPickIT method changeMessageOnSubmit.
@Test
public void changeMessageOnSubmit() throws Throwable {
PushOneCommit.Result change = createChange();
ChangeMessageModifier link = new ChangeMessageModifier() {
@Override
public String onSubmit(String newCommitMessage, RevCommit original, RevCommit mergeTip, BranchNameKey destination) {
return newCommitMessage + "Custom: " + destination.branch();
}
};
try (Registration registration = extensionRegistry.newRegistration().add(link)) {
submit(change.getChangeId());
}
testRepo.git().fetch().setRemote("origin").call();
ChangeInfo info = get(change.getChangeId(), CURRENT_REVISION);
RevCommit c = testRepo.getRevWalk().parseCommit(ObjectId.fromString(info.currentRevision));
testRepo.getRevWalk().parseBody(c);
assertThat(c.getFooterLines("Custom")).containsExactly("refs/heads/master");
assertThat(c.getFooterLines(FooterConstants.REVIEWED_ON)).hasSize(1);
}
use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.
the class MoveChangeIT method moveChangeToBranchWithoutUploadPerms.
@Test
public void moveChangeToBranchWithoutUploadPerms() throws Exception {
// Move change to a destination where user doesn't have upload permissions
PushOneCommit.Result r = createChange();
BranchNameKey newBranch = BranchNameKey.create(r.getChange().change().getProject(), "blocked_branch");
createBranch(newBranch);
projectOperations.project(project).forUpdate().add(block(Permission.PUSH).ref("refs/for/" + newBranch.branch()).group(REGISTERED_USERS)).update();
AuthException thrown = assertThrows(AuthException.class, () -> move(r.getChangeId(), newBranch.branch()));
assertThat(thrown).hasMessageThat().isEqualTo("move not permitted");
}
use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.
the class MoveChangeIT method moveChangeToBranchThatContainsCurrentCommit.
@Test
public void moveChangeToBranchThatContainsCurrentCommit() throws Exception {
// Move change to a branch for which current PS revision is reachable from
// tip
// Create a change
PushOneCommit.Result r = createChange();
int changeNum = r.getChange().change().getChangeId();
// Create a branch with that same commit
BranchNameKey newBranch = BranchNameKey.create(r.getChange().change().getProject(), "moveTest");
BranchInput bi = new BranchInput();
bi.revision = r.getCommit().name();
gApi.projects().name(newBranch.project().get()).branch(newBranch.branch()).create(bi);
// Try to move the change to the branch with the same commit
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> move(changeNum, newBranch.branch()));
assertThat(thrown).hasMessageThat().contains("Current patchset revision is reachable from tip of " + newBranch.branch());
}
Aggregations