Skip to content

Commit

Permalink
Indicates to Gerrit that the review is posted by an automated system
Browse files Browse the repository at this point in the history
  • Loading branch information
reda-alaoui committed Jan 31, 2022
1 parent c4ff5c4 commit f2cf40f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public ReviewInput buildReview() {
// review
String reviewMessage = getReviewMessage(finalIssuesToComment);
ReviewInput reviewInput = new ReviewInput().message(reviewMessage);
reviewInput.tag = "autogenerated:sonar";

switch (reviewConfig.getCommentType()) {
case STANDARD:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

/** @author Réda Housni Alaoui */
@EnableCluster
class CommentTypeTest {
class ReviewTest {

private static final String MAVEN_TARGET =
"clean verify sonar:sonar "
Expand All @@ -45,7 +45,7 @@ class CommentTypeTest {
@BeforeAll
static void beforeAll(Cluster cluster, @TempDir Path workTree) throws Exception {

CommentTypeTest.cluster = cluster;
ReviewTest.cluster = cluster;

git = GerritGit.createAndCloneRepository(cluster.gerrit(), workTree);

Expand Down Expand Up @@ -122,6 +122,19 @@ void test2() throws Exception {
});
}

@Test
@DisplayName("Review tag is autogenerated:sonar")
void test3() throws Exception {
GerritChange change = createChangeViolatingS1186();
triggerAndAssertSuccess(createPipelineJob(change, ReviewCommentType.STANDARD));

ChangeInfo changeDetail = change.getDetail();
assertThat(changeDetail.labels.get(GerritServer.CODE_QUALITY_LABEL).all)
.hasSize(1)
.map(approvalInfo -> approvalInfo.tag)
.containsExactly("autogenerated:sonar");
}

private GerritChange createChangeViolatingS1186()
throws GitAPIException, IOException, RestApiException {
git.addAndCommitFile(
Expand Down

0 comments on commit f2cf40f

Please sign in to comment.