use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.
the class CommitIncludedInIT method includedInOpenChange.
@Test
public void includedInOpenChange() throws Exception {
Result result = createChange();
assertThat(getIncludedIn(result.getCommit().getId()).branches).isEmpty();
assertThat(getIncludedIn(result.getCommit().getId()).tags).isEmpty();
}
use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.
the class CommitIncludedInIT method includedInMergedChange.
@Test
public void includedInMergedChange() throws Exception {
Result result = createChange();
gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).review(ReviewInput.approve());
gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).submit();
assertThat(getIncludedIn(result.getCommit().getId()).branches).containsExactly("master");
assertThat(getIncludedIn(result.getCommit().getId()).tags).isEmpty();
grantTagPermissions();
gApi.projects().name(result.getChange().project().get()).tag("test-tag").create(new TagInput());
assertThat(getIncludedIn(result.getCommit().getId()).tags).containsExactly("test-tag");
createBranch(new Branch.NameKey(project.get(), "test-branch"));
assertThat(getIncludedIn(result.getCommit().getId()).branches).containsExactly("master", "test-branch");
}
use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.
the class CorsIT method origin.
@Test
public void origin() throws Exception {
Result change = createChange();
String url = "/changes/" + change.getChangeId() + "/detail";
RestResponse r = adminRestSession.get(url);
r.assertOK();
assertThat(r.getHeader(ACCESS_CONTROL_ALLOW_ORIGIN)).isNull();
assertThat(r.getHeader(ACCESS_CONTROL_ALLOW_CREDENTIALS)).isNull();
check(url, true, "http://example.com");
check(url, true, "https://sub.example.com");
check(url, true, "http://friend.ly");
check(url, false, "http://evil.attacker");
check(url, false, "http://friendsly");
}
use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.
the class DeleteDraftPatchSetIT method createDraftChangeWith2PS.
private String createDraftChangeWith2PS() throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
Result result = push.to("refs/drafts/master");
push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "4711", result.getChangeId());
return push.to("refs/drafts/master").getChangeId();
}
use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.
the class AbstractDaemonTest method createNParentsMergeCommitChange.
protected PushOneCommit.Result createNParentsMergeCommitChange(String ref, List<String> fileNames) throws Exception {
// This method creates n different commits and creates a merge commit pointing to all n parents.
// Each commit will contain all the fileNames. Commit i will have the following file names and
// their contents:
// {$file_1_name, ${file_1_name}-1}
// {$file_2_name, ${file_2_name}-1}, etc...
// The merge commit will have:
// {$file_1_name, ${file_1_name}-1}
// {$file_2_name, ${file_2_name}-2},
// {$file_3_name, ${file_3_name}-3}, etc...
// i.e. taking the ith file from the ith commit.
int n = fileNames.size();
ObjectId initial = repo().exactRef(HEAD).getLeaf().getObjectId();
List<PushOneCommit.Result> pushResults = new ArrayList<>();
for (int i = 1; i <= n; i++) {
int finalI = i;
pushResults.add(pushFactory.create(admin.newIdent(), testRepo, "parent " + i, fileNames.stream().collect(Collectors.toMap(f -> f, f -> f + "-" + finalI))).to(ref));
// reset HEAD in order to create a sibling of the first change
if (i < n) {
testRepo.reset(initial);
}
}
PushOneCommit m = pushFactory.create(admin.newIdent(), testRepo, "merge", IntStream.range(1, n + 1).boxed().collect(Collectors.toMap(i -> fileNames.get(i - 1), i -> fileNames.get(i - 1) + "-" + i)));
m.setParents(pushResults.stream().map(PushOneCommit.Result::getCommit).collect(toList()));
PushOneCommit.Result result = m.to(ref);
result.assertOkStatus();
return result;
}
Aggregations