Skip to content

fix: change counting logic for case of zero changes #461

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

Merged
merged 1 commit into from
Jun 25, 2025

Conversation

jemc
Copy link
Contributor

@jemc jemc commented Jun 25, 2025

Prior to this PR,

In the case where a tf.diff.txt is generated, but it contains no changes (e.g. only moves and imports), then the grep that looks for lines not starting with ^# would find no lines at all, causing grep to return a non-zero exit code, which causes the CI/CD workflow to fail.

This PR fixes the issue by adding || true to the relevant grep. The true command will output zero lines with a zero exit code, so it makes a good fallback here when the grep fails (because the wc --lines that follows will count zero lines).

Prior to this PR,

In the case where a `tf.diff.txt` is generated, but it contains
no changes (e.g. only moves and imports), then the `grep` that
looks for lines not starting with `^# ` would find no lines at all,
causing `grep` to return a non-zero exit code, which causes
the CI/CD workflow to fail.

This PR fixes the issue by adding `|| true` to the relevant `grep`.
The `true` command will output zero lines with a zero exit code,
so it makes a good fallback here when the `grep` fails
(because the `wc --lines` that follows will count zero lines).
@jemc jemc requested a review from rdhar as a code owner June 25, 2025 01:48
Copy link
Member

@rdhar rdhar left a comment

Choose a reason for hiding this comment

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

This is fantastic, and the timing is superb! This has been plaguing TF-via-PR for a while so I'm grateful you took time out to contribute a fix -- thank you!

@rdhar rdhar merged commit e984206 into OP5dev:main Jun 25, 2025
10 checks passed
@rdhar rdhar mentioned this pull request Jun 25, 2025
5 tasks
@rdhar
Copy link
Member

rdhar commented Jun 26, 2025

Happy to see this shipped with v13.5.0 (v13), where your contribution has been credited!

Please consider ⭐ this project, if you or your team find it useful.

GitHub repository stargazers


@jemc Thanks once again for implementing this fix, and clarifying the change so clearly as well!

@wyardley
Copy link

wyardley commented Jul 8, 2025

Thanks for fixing this!

The "diff of 0 changes" cut is a little odd, but overall, it works, and fixes the issue we had in #433

image

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.

3 participants