Skip to content

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

Merged
rdhar merged 1 commit intoOP5dev:mainfrom
jemc:fix/change-count-grep
Jun 25, 2025
Merged

fix: change counting logic for case of zero changes#461
rdhar merged 1 commit intoOP5dev:mainfrom
jemc:fix/change-count-grep

Conversation

@jemc
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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