use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.
the class ChangeIT method createNewPatchSetOnVisibleDraftPatchSet.
@Test
public void createNewPatchSetOnVisibleDraftPatchSet() throws Exception {
// Clone separate repositories of the same project as admin and as user
TestRepository<InMemoryRepository> adminTestRepo = cloneProject(project, admin);
TestRepository<InMemoryRepository> userTestRepo = cloneProject(project, user);
// Create change as admin
PushOneCommit push = pushFactory.create(db, admin.getIdent(), adminTestRepo);
PushOneCommit.Result r1 = push.to("refs/for/master");
r1.assertOkStatus();
// Amend draft as admin
PushOneCommit.Result r2 = amendChange(r1.getChangeId(), "refs/drafts/master", admin, adminTestRepo);
r2.assertOkStatus();
// Add user as reviewer to make this patch set visible
AddReviewerInput in = new AddReviewerInput();
in.reviewer = user.email;
gApi.changes().id(r1.getChangeId()).addReviewer(in);
// Fetch change
GitUtil.fetch(userTestRepo, r2.getPatchSet().getRefName() + ":ps");
userTestRepo.reset("ps");
// Amend change as user
PushOneCommit.Result r3 = amendChange(r2.getChangeId(), "refs/drafts/master", user, userTestRepo);
r3.assertOkStatus();
}
use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.
the class DiffPreferencesIT method cleanUp.
@After
public void cleanUp() throws Exception {
gApi.accounts().id(admin.getId().toString()).setDiffPreferences(DiffPreferencesInfo.defaults());
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
try {
fetch(allUsersRepo, RefNames.REFS_USERS_DEFAULT + ":defaults");
} catch (TransportException e) {
if (e.getMessage().equals("Remote does not have " + RefNames.REFS_USERS_DEFAULT + " available for fetch.")) {
return;
}
throw e;
}
allUsersRepo.reset("defaults");
PushOneCommit push = pushFactory.create(db, admin.getIdent(), allUsersRepo, "Delete default preferences", VersionedAccountPreferences.PREFERENCES, "");
push.rm(RefNames.REFS_USERS_DEFAULT).assertOkStatus();
}
use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.
the class ChangeEditIT method createEditWithoutPushPatchSetPermission.
@Test
public void createEditWithoutPushPatchSetPermission() throws Exception {
// Create new project with clean permissions
Project.NameKey p = createProject("addPatchSetEdit");
// Clone repository as user
TestRepository<InMemoryRepository> userTestRepo = cloneProject(p, user);
// Block default permission
block(p, "refs/for/*", Permission.ADD_PATCH_SET, REGISTERED_USERS);
// Create change as user
PushOneCommit push = pushFactory.create(db, user.getIdent(), userTestRepo);
PushOneCommit.Result r1 = push.to("refs/for/master");
r1.assertOkStatus();
// Try to create edit as admin
exception.expect(AuthException.class);
createEmptyEditFor(r1.getChangeId());
}
use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.
the class ExternalIdIT method pushToExternalIdsBranchRejectsExternalIdWithoutAccountId.
@Test
public void pushToExternalIdsBranchRejectsExternalIdWithoutAccountId() throws Exception {
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS + ":" + RefNames.REFS_EXTERNAL_IDS);
allUsersRepo.reset(RefNames.REFS_EXTERNAL_IDS);
insertExternalIdWithoutAccountId(allUsersRepo.getRepository(), allUsersRepo.getRevWalk(), "foo:bar");
allUsersRepo.reset(RefNames.REFS_EXTERNAL_IDS);
allowPushOfExternalIds();
PushResult r = pushHead(allUsersRepo, RefNames.REFS_EXTERNAL_IDS);
assertRefUpdateFailure(r.getRemoteUpdate(RefNames.REFS_EXTERNAL_IDS), "invalid external IDs");
}
use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.
the class ExternalIdIT method pushToExternalIdsBranchRejectsExternalIdWithEmptyNote.
@Test
public void pushToExternalIdsBranchRejectsExternalIdWithEmptyNote() throws Exception {
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS + ":" + RefNames.REFS_EXTERNAL_IDS);
allUsersRepo.reset(RefNames.REFS_EXTERNAL_IDS);
insertExternalIdWithEmptyNote(allUsersRepo.getRepository(), allUsersRepo.getRevWalk(), "foo:bar");
allUsersRepo.reset(RefNames.REFS_EXTERNAL_IDS);
allowPushOfExternalIds();
PushResult r = pushHead(allUsersRepo, RefNames.REFS_EXTERNAL_IDS);
assertRefUpdateFailure(r.getRemoteUpdate(RefNames.REFS_EXTERNAL_IDS), "invalid external IDs");
}
Aggregations