Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support empty commits/PRs #132

Merged
merged 1 commit into from
Jul 19, 2024
Merged

Conversation

Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Jul 19, 2024

When opening a PR without any changes (with one or more empty commits), clang-tidy-review currently fails with

Traceback (most recent call last):
  File "/usr/local/bin/review", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/clang_tidy_review/review.py", line 154, in main
    review = create_review(
             ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/clang_tidy_review/__init__.py", line 843, in create_review
    diff = pull_request.get_pr_diff()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/clang_tidy_review/__init__.py", line 297, in get_pr_diff
    diffs = data["data"]
            ~~~~^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

This PR checks data and returns with no changes.

While doing that, I noticed the return-type being wrong in this method, so I fixed that too.

Copy link
Owner

@ZedThree ZedThree left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely, thanks @Nerixyz !

@ZedThree ZedThree merged commit 0eccb1c into ZedThree:master Jul 19, 2024
1 check passed
@Nerixyz Nerixyz deleted the fix/empty-commit branch July 19, 2024 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants