use of sonia.scm.repository.Changeset in project scm-review-plugin by scm-manager.
the class MergeService method extractCoAuthorsFromSquashedCommitMessages.
private void extractCoAuthorsFromSquashedCommitMessages(List<Changeset> changesets, String author, Set<String> appendedCoAuthors, StringBuilder builder) {
Pattern delimiter = Pattern.compile("[\\n]");
for (Changeset changeset : changesets) {
if (changeset.getDescription() != null) {
try (Scanner scanner = new Scanner(changeset.getDescription())) {
scanner.useDelimiter(delimiter);
while (scanner.hasNext()) {
String line = scanner.next();
if (shouldExtractLineFromSquashedCommit(appendedCoAuthors, line, author)) {
appendedCoAuthors.add(line);
builder.append(line).append("\n");
}
}
}
}
}
}
use of sonia.scm.repository.Changeset in project scm-review-plugin by scm-manager.
the class ModificationCollectorTest method shouldCollectModification.
@Test
void shouldCollectModification() throws IOException {
Changeset one = changeset("21").added("a.txt").removed("b.txt").build();
Changeset two = changeset("42").modified("c.txt", "d.txt").build();
Set<String> modifications = collector.collect(repository, ImmutableList.of(one, two));
assertThat(modifications).containsExactlyInAnyOrder("a.txt", "b.txt", "c.txt", "d.txt");
}
use of sonia.scm.repository.Changeset in project scm-review-plugin by scm-manager.
the class ProcessChangedFilesHookTest method prepareEvent.
private PostReceiveRepositoryHookEvent prepareEvent(Comment... comments) {
lenient().when(commentCollector.collectNonOutdated(repository, pullRequest)).thenReturn(Stream.of(comments));
List<String> branches = ImmutableList.of(pullRequest.getSource(), pullRequest.getTarget());
PostReceiveRepositoryHookEvent event = createRepositoryHookEvent(branches);
lenient().when(pullRequestCollector.collectAffectedPullRequests(repository, branches)).thenReturn(ImmutableList.of(pullRequest));
List<Changeset> changesets = ImmutableList.of(new Changeset(), new Changeset());
lenient().when(event.getContext().getChangesetProvider().getChangesets()).thenReturn(changesets);
return event;
}
use of sonia.scm.repository.Changeset in project scm-review-plugin by scm-manager.
the class BranchRevisionResolverTest method mockSingleChangeset.
private void mockSingleChangeset(String branch) throws IOException {
when(repositoryService.getLogCommand()).thenReturn(logCommandBuilder);
LogCommandBuilder subLogCommandBuilder = mock(LogCommandBuilder.class);
lenient().when(logCommandBuilder.setBranch(branch)).thenReturn(subLogCommandBuilder);
lenient().when(subLogCommandBuilder.setPagingStart(0)).thenReturn(subLogCommandBuilder);
lenient().when(subLogCommandBuilder.setPagingLimit(1)).thenReturn(subLogCommandBuilder);
Changeset changeset = new Changeset();
changeset.setId(branch + "Id");
lenient().when(subLogCommandBuilder.getChangesets()).thenReturn(new ChangesetPagingResult(1, singletonList(changeset)));
}
use of sonia.scm.repository.Changeset in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldCreateNewValidPullRequest.
@Test
@SubjectAware(username = "slarti")
public void shouldCreateNewValidPullRequest() throws URISyntaxException, IOException {
mockPrincipal();
mockChangesets("sourceBranch", "targetBranch", new Changeset());
byte[] pullRequestJson = loadJson("com/cloudogu/scm/review/pullRequest.json");
MockHttpRequest request = MockHttpRequest.post("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/space/name").content(pullRequestJson).contentType(PullRequestMediaType.PULL_REQUEST);
dispatcher.invoke(request, response);
assertEquals(HttpServletResponse.SC_CREATED, response.getStatus());
assertThat(response.getOutputHeaders().getFirst("Location")).hasToString("/v2/pull-requests/space/name/1");
PullRequest pullRequest = pullRequestStoreCaptor.getValue();
assertThat(pullRequest.getAuthor()).isEqualTo("user1");
}
Aggregations