use of org.eclipse.jgit.transport.PushResult in project gerrit by GerritCodeReview.
the class ExternalIdIT method testPushToExternalIdsBranchRejectsInvalidExternalId.
private void testPushToExternalIdsBranchRejectsInvalidExternalId(ExternalId invalidExtId) throws Exception {
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS + ":" + RefNames.REFS_EXTERNAL_IDS);
allUsersRepo.reset(RefNames.REFS_EXTERNAL_IDS);
addExtId(allUsersRepo, invalidExtId);
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.transport.PushResult in project gerrit by GerritCodeReview.
the class ExternalIdIT method pushToExternalIdsBranch.
@Test
public void pushToExternalIdsBranch() throws Exception {
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS + ":" + RefNames.REFS_EXTERNAL_IDS);
allUsersRepo.reset(RefNames.REFS_EXTERNAL_IDS);
// different case email is allowed
ExternalId newExtId = createExternalIdWithOtherCaseEmail("foo:bar");
addExtId(allUsersRepo, newExtId);
allUsersRepo.reset(RefNames.REFS_EXTERNAL_IDS);
List<AccountExternalIdInfo> extIdsBefore = gApi.accounts().self().getExternalIds();
allowPushOfExternalIds();
PushResult r = pushHead(allUsersRepo, RefNames.REFS_EXTERNAL_IDS);
assertThat(r.getRemoteUpdate(RefNames.REFS_EXTERNAL_IDS).getStatus()).isEqualTo(Status.OK);
List<AccountExternalIdInfo> extIdsAfter = gApi.accounts().self().getExternalIds();
assertThat(extIdsAfter).containsExactlyElementsIn(Iterables.concat(extIdsBefore, ImmutableSet.of(toExternalIdInfo(newExtId))));
}
use of org.eclipse.jgit.transport.PushResult in project gerrit by GerritCodeReview.
the class SubmitByFastForwardIT method submitSameCommitsAsInExperimentalBranch.
@Test
public void submitSameCommitsAsInExperimentalBranch() throws Exception {
RevCommit initialHead = getRemoteHead();
grant(project, "refs/heads/*", Permission.CREATE);
grant(project, "refs/heads/experimental", Permission.PUSH);
RevCommit c1 = commitBuilder().add("b.txt", "1").message("commit at tip").create();
String id1 = GitUtil.getChangeId(testRepo, c1).get();
PushResult r1 = pushHead(testRepo, "refs/for/master", false);
assertThat(r1.getRemoteUpdate("refs/for/master").getNewObjectId()).isEqualTo(c1.getId());
PushResult r2 = pushHead(testRepo, "refs/heads/experimental", false);
assertThat(r2.getRemoteUpdate("refs/heads/experimental").getNewObjectId()).isEqualTo(c1.getId());
submit(id1);
RevCommit headAfterSubmit = getRemoteHead();
assertThat(getRemoteHead().getId()).isEqualTo(c1.getId());
assertSubmitter(id1, 1);
assertRefUpdatedEvents(initialHead, headAfterSubmit);
assertChangeMergedEvents(id1, headAfterSubmit.name());
}
use of org.eclipse.jgit.transport.PushResult in project gerrit by GerritCodeReview.
the class PushTagIT method pushTag.
private String pushTag(TagType tagType, String tagName, boolean newCommit, boolean force, Status expectedStatus) throws Exception {
if (force) {
testRepo.reset(initialHead);
}
commit(user.getIdent(), "subject");
boolean createTag = tagName == null;
tagName = MoreObjects.firstNonNull(tagName, "v1_" + System.nanoTime());
switch(tagType) {
case LIGHTWEIGHT:
break;
case ANNOTATED:
if (createTag) {
createAnnotatedTag(testRepo, tagName, user.getIdent());
} else {
updateAnnotatedTag(testRepo, tagName, user.getIdent());
}
break;
default:
throw new IllegalStateException("unexpected tag type: " + tagType);
}
if (!newCommit) {
grant(project, "refs/for/refs/heads/master", Permission.SUBMIT, false, REGISTERED_USERS);
pushHead(testRepo, "refs/for/master%submit");
}
String tagRef = tagRef(tagName);
PushResult r = tagType == LIGHTWEIGHT ? pushHead(testRepo, tagRef, false, force) : GitUtil.pushTag(testRepo, tagName, !createTag);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(tagRef);
assertThat(refUpdate.getStatus()).named(tagType.name()).isEqualTo(expectedStatus);
return tagName;
}
use of org.eclipse.jgit.transport.PushResult in project camel by apache.
the class GitRemoteProducerTest method pushTest.
@Ignore("Require a remote git repository")
@Test
public void pushTest() throws Exception {
Repository repository = getTestRepository();
File fileToAdd = new File(gitLocalRepo, filenameToAdd);
fileToAdd.createNewFile();
template.send("direct:add", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
}
});
File gitDir = new File(gitLocalRepo, ".git");
assertEquals(gitDir.exists(), true);
Status status = new Git(repository).status().call();
assertTrue(status.getAdded().contains(filenameToAdd));
template.send("direct:commit", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
}
});
Iterable<PushResult> result = template.requestBody("direct:push", "", Iterable.class);
repository.close();
}
Aggregations