Skip to content

Commit

Permalink
Merge pull request #105 from bwrsandman/multi-split-review-empty
Browse files Browse the repository at this point in the history
Fix split workflow when no comments can be posted
  • Loading branch information
ZedThree authored Jan 17, 2024
2 parents 6894fd3 + 0b1bf4c commit 90f19b9
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions post/clang_tidy_review/clang_tidy_review/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,14 +775,32 @@ def create_review(
files = filter_files(diff, include, exclude)

if files == []:
print("No files to check!")
with message_group("No files to check!"):
with open(REVIEW_FILE, "w") as review_file:
json.dump(
{
"body": "clang-tidy found no files to check",
"event": "COMMENT",
"comments": [],
},
review_file,
)
return None

print(f"Checking these files: {files}", flush=True)

line_ranges = get_line_ranges(diff, files)
if line_ranges == "[]":
print("No lines added in this PR!")
with message_group("No lines added in this PR!"):
with open(REVIEW_FILE, "w") as review_file:
json.dump(
{
"body": "clang-tidy found no lines added",
"event": "COMMENT",
"comments": [],
},
review_file,
)
return None

print(f"Line filter for clang-tidy:\n{line_ranges}\n")
Expand Down Expand Up @@ -891,7 +909,7 @@ def load_and_merge_reviews(review_files: List[pathlib.Path]) -> Optional[PRRevie
reviews = []
for file in review_files:
review = load_review(file)
if review is not None:
if review is not None and len(review.get("comments", [])) > 0:
reviews.append(review)

if not reviews:
Expand Down

0 comments on commit 90f19b9

Please sign in to comment.