Skip to content

Commit

Permalink
[cli] Fix link in gerrit output
Browse files Browse the repository at this point in the history
If `CC_REPORT_URL` is defined and `gerrit` format is used at `CodeChecker parse`
or `CodeChecker cmd diff` commands, the output will contain the value of this
environment variable wrapped inside quotes. When this output is sent to gerrit,
it will convert URL links to HTML `a` tags. Unfortunately gerrit will think that
the ending quote is part of the URL, so it will not remove it. This way the
URL will be invalid.

To solve this problem in this patch we will remove the quotes around the URL link.
  • Loading branch information
csordasmarton committed Jan 6, 2022
1 parent 8ddb9bd commit 8f9e2e8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def test_gerrit_output(self):
self.assertEqual(lbls["Code-Review"], -1)
self.assertEqual(review_data["message"],
"CodeChecker found 1 issue(s) in the code. "
"See: '{0}'".format(report_url))
"See: {0}".format(report_url))
self.assertEqual(review_data["tag"], "jenkins")

# Because the CC_CHANGED_FILES is set we will see reports only for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def __convert_reports(reports: List[Report],
report_messages_in_unchanged_files)))

if report_url:
message += " See: '{0}'".format(report_url)
message += f" See: {report_url}"

review = {"tag": "jenkins",
"message": message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_report_to_gerrit_conversion_report_url(self):
expected = {
"tag": "jenkins",
"message": "CodeChecker found 1 issue(s) in the code. "
"See: 'localhost:8080/index.html'",
"See: localhost:8080/index.html",
"labels": {"Code-Review": -1, "Verified": -1},
"comments": {
"main.cpp": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def test_set_env_diff_gerrit_output(self):
self.assertIn(
"CodeChecker found 25 issue(s) in the code.",
review_data["message"])
self.assertIn(f"See: '{report_url}'", review_data["message"])
self.assertIn(f"See: {report_url}", review_data["message"])
self.assertEqual(review_data["tag"], "jenkins")

# Because the CC_CHANGED_FILES is set we will see reports only for
Expand Down

0 comments on commit 8f9e2e8

Please sign in to comment.