Skip to content

Switch to unidiff #115

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

Closed
wants to merge 12 commits into from
Closed

Switch to unidiff #115

wants to merge 12 commits into from

Conversation

2bndy5
Copy link
Contributor

@2bndy5 2bndy5 commented Sep 4, 2024

This migrates diff-parsing fallback mechanism (previously using regex patterns) to new dependecy unidiff.

This allows for a few new tactics:

  • able to parse partial patches provided by REST API endpoints that list files with individual patch for each file (addresses Unable to fetch diff for a large PR cpp-linter-action#249)

  • able to move PR review comment generation from rest_api/github_api.py module into new clang_tools.patcher.py module because we don't need to keep data (previously used by pygit2.Patch) alive for the entire process (which avoided data corruption when the string of changes dropped out of scope).

    This change employs a mixin class to generate PR suggestions (for better/clearer code reuse).

I originally intended to use this to merge suggestions from both tools, but that isn't as easy as it sounds. Perhaps later, I can experiment with diff merging using these changes.

@2bndy5 2bndy5 added enhancement New feature or request dependencies labels Sep 4, 2024
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Sep 4, 2024
@2bndy5
Copy link
Contributor Author

2bndy5 commented Sep 4, 2024

It seems that our pr-review test wasn't generating suggestions with clang tools v7 and v8. I'm inclined to skip those versions when running tests, but It might be better to adjust the checks so that those versions generate suggestions.

Also, there seems to be a problem in CI where the coverage data (.coverage* files) isn't generated into repo root. This doesn't happen locally, so I'll have to investigate more in depth.

Copy link

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (cf528d8) to head (7046060).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #115   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        24    +2     
  Lines         1665      1737   +72     
=========================================
+ Hits          1665      1737   +72     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@2bndy5 2bndy5 marked this pull request as ready for review September 4, 2024 08:14
@2bndy5
Copy link
Contributor Author

2bndy5 commented Sep 5, 2024

👀 uh oh

The generated diff from diff_lib.unified_diff() does not handle similarities very well (not at all actually). See test repo's PR review.

I'm going to have to rethink and revert somethings here.

@2bndy5
Copy link
Contributor Author

2bndy5 commented Sep 5, 2024

Ok, diff_lib.unified_diff() kind of works when --lines-changed-only is true, but I think it expects the line endings to be LF. If the lines end with CRLF, then the whole file gets adjusted to use LF endings (by clang tools according to the specified style guide), and the generated diff encompasses the entire file.

@2bndy5 2bndy5 marked this pull request as draft September 5, 2024 05:58
@2bndy5
Copy link
Contributor Author

2bndy5 commented Sep 5, 2024

I'm refactoring the branch and will open a new PR shortly.

@2bndy5 2bndy5 closed this Sep 5, 2024
@2bndy5 2bndy5 deleted the switch-to-unidiff branch September 5, 2024 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants