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

Support ignore deletions with "ignore_line_deletions" param #71

Merged
merged 6 commits into from
Apr 16, 2024

Conversation

johnlk
Copy link
Collaborator

@johnlk johnlk commented Apr 14, 2024

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Some users prefer to not include file line deletions in the total line change count. I'm allowing this by way of a new config variable ignore_line_deletions which defaults to false.

By request I may add another variable ignore_file_deletions which would not count files which are completely deleted. This will most likely come as a followup change.

Notes to Reviewer

This required I break up the changes variable in the PR files loop into additions and deletions. This makes the code more consistent between the if and else blocks in the calculate_total_modifications method.

How to test

I ensured that all four possible code paths were tested. files_to_ignore (set or not) x ignore_line_deletions (true/false).

In the process of adding these tests, I added an example response for the pull request API. This was missing.

Link to issues addressed

@johnlk johnlk self-assigned this Apr 14, 2024
@johnlk johnlk changed the title Support ignore deletions with "ignore_file_deletions" param [WIP] Support ignore deletions with "ignore_file_deletions" param Apr 14, 2024
@OnkarRuikar
Copy link
Contributor

Could we have two settings:

  1. ignore_file_deletions: Ignore lines from only deleted files but count deleted lines from modified files.
  2. ignore_line_deletions: ignore all the deleted lines. This would be super set of ignore_file_deletions which would ignore deleted files from all kinds of modifications.

Depending on the project, line deletions from modified files does require review efforts, so we do need to count lines from modified files but not from deleted files. In such case ignore_line_deletions won't cut it and ignore_file_deletions would be more precise.

@johnlk
Copy link
Collaborator Author

johnlk commented Apr 15, 2024

Could we have two settings:

  1. ignore_file_deletions: Ignore lines from only deleted files but count deleted lines from modified files.
  2. ignore_line_deletions: ignore all the deleted lines. This would be super set of ignore_file_deletions which would ignore deleted files from all kinds of modifications.

Depending on the project, line deletions from modified files does require review efforts, so we do need to count lines from modified files but not from deleted files. In such case ignore_line_deletions won't cut it and ignore_file_deletions would be more precise.

Thanks for the feedback, I think this is a great distinction and something I can incorporate. I could see why ignoring file deletions alone could prove valuable.

@johnlk johnlk force-pushed the john/allow-ignoring-deletion branch from ee92b38 to e7ddbea Compare April 15, 2024 13:29
@github-actions github-actions bot added size/m and removed size/s labels Apr 15, 2024
Test files_to_ignore code path

Tweak the variable type

Correct bad logic in the file ignore block

Debug

More debugging

More debugging

Fingers crossed

Another try

Last try

Lets see if this one does it

Testing again

More tests

More testing

Last test

Wait, I might be onto something

Put some changes back

Fixes

Whoops

Walk back yml test
@johnlk johnlk force-pushed the john/allow-ignoring-deletion branch from e7ddbea to c6dc97a Compare April 15, 2024 13:38
@johnlk johnlk changed the title [WIP] Support ignore deletions with "ignore_file_deletions" param [WIP] Support ignore deletions with "ignore_line_deletions" param Apr 15, 2024
@johnlk
Copy link
Collaborator Author

johnlk commented Apr 15, 2024

@OnkarRuikar to prevent this PR from getting any larger, I'm going to implement the ignore_file_deletions option in a followup PR.

This current change has test updates, refactoring, and a new feature, so I want to stop here for now.

@johnlk johnlk marked this pull request as ready for review April 15, 2024 14:12
if [[ "$pull_request_number" != "null" ]]; then
echo "$pull_request_number"
else
echo "Not a pull request event"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this code block would've saved me so much time while I was testing this. I was testing on push events and was getting very obscure errors. 🙃

@johnlk johnlk changed the title [WIP] Support ignore deletions with "ignore_line_deletions" param Support ignore deletions with "ignore_line_deletions" param Apr 15, 2024
Copy link
Member

@JavierCane JavierCane left a comment

Choose a reason for hiding this comment

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

Just some non-blocking comments 😊

action.yml Outdated Show resolved Hide resolved
src/github.sh Outdated
Comment on lines 25 to 27
_jq() {
echo ${file} | base64 -d | jq -r ${1}
}
Copy link
Member

Choose a reason for hiding this comment

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

Why not reusing jq::base64 instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh shoot, didn't realize this helper was already available. Will use!

@johnlk johnlk merged commit f2aafc4 into main Apr 16, 2024
2 checks passed
@johnlk johnlk deleted the john/allow-ignoring-deletion branch April 16, 2024 15:35
This was referenced Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants