use of org.eclipse.jgit.junit.TestRepository in project gerrit by GerritCodeReview.
the class StickyApprovalsIT method noCodeChange.
private void noCodeChange(String changeId) throws Exception {
TestRepository<?>.CommitBuilder<?> commitBuilder = testRepo.amendRef("HEAD").insertChangeId(changeId.substring(1));
commitBuilder.message("New subject " + System.nanoTime()).author(admin.getIdent()).committer(new PersonIdent(admin.getIdent(), testRepo.getDate()));
commitBuilder.create();
GitUtil.pushHead(testRepo, "refs/for/master", false);
assertThat(getChangeKind(changeId)).isEqualTo(NO_CODE_CHANGE);
}
use of org.eclipse.jgit.junit.TestRepository in project gerrit by GerritCodeReview.
the class AbstractSubmit method assertRebase.
protected void assertRebase(TestRepository<?> testRepo, boolean contentMerge) throws Exception {
Repository repo = testRepo.getRepository();
RevCommit localHead = getHead(repo);
RevCommit remoteHead = getRemoteHead();
assert_().withFailureMessage(String.format("%s not equal %s", localHead.name(), remoteHead.name())).that(localHead.getId()).isNotEqualTo(remoteHead.getId());
assertThat(remoteHead.getParentCount()).isEqualTo(1);
if (!contentMerge) {
assertThat(getLatestRemoteDiff()).isEqualTo(getLatestDiff(repo));
}
assertThat(remoteHead.getShortMessage()).isEqualTo(localHead.getShortMessage());
}
use of org.eclipse.jgit.junit.TestRepository in project gerrit by GerritCodeReview.
the class AbstractDaemonTest method amendBuilder.
protected TestRepository<?>.CommitBuilder<?> amendBuilder() throws Exception {
ObjectId head = repo().exactRef("HEAD").getObjectId();
TestRepository<?>.CommitBuilder<?> b = testRepo.amendRef("HEAD");
Optional<String> id = GitUtil.getChangeId(testRepo, head);
// preserve an existing Change-Id. Tests probably want this.
if (id.isPresent()) {
b.insertChangeId(id.get().substring(1));
} else {
b.insertChangeId();
}
return b;
}
use of org.eclipse.jgit.junit.TestRepository in project gerrit by GerritCodeReview.
the class AccountIT method deleteUserBranchWithAccessDatabaseCapability.
@Test
@Sandboxed
public void deleteUserBranchWithAccessDatabaseCapability() throws Exception {
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
grant(allUsers, RefNames.REFS_USERS + "${" + RefPattern.USERID_SHARDED + "}", Permission.DELETE, true, REGISTERED_USERS);
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
String userRef = RefNames.refsUsers(admin.id);
PushResult r = deleteRef(allUsersRepo, userRef);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(userRef);
assertThat(refUpdate.getStatus()).isEqualTo(RemoteRefUpdate.Status.OK);
try (Repository repo = repoManager.openRepository(allUsers)) {
assertThat(repo.exactRef(userRef)).isNull();
}
// TODO(ekempin): assert that account was deleted from cache and index
}
use of org.eclipse.jgit.junit.TestRepository in project gerrit by GerritCodeReview.
the class AccountIT method cannotDeleteUserBranch.
@Test
@Sandboxed
public void cannotDeleteUserBranch() throws Exception {
grant(allUsers, RefNames.REFS_USERS + "${" + RefPattern.USERID_SHARDED + "}", Permission.DELETE, true, REGISTERED_USERS);
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
String userRef = RefNames.refsUsers(admin.id);
PushResult r = deleteRef(allUsersRepo, userRef);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(userRef);
assertThat(refUpdate.getStatus()).isEqualTo(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
assertThat(refUpdate.getMessage()).contains("Not allowed to delete user branch.");
try (Repository repo = repoManager.openRepository(allUsers)) {
assertThat(repo.exactRef(userRef)).isNotNull();
}
}
Aggregations