Skip to content

Commit e984206

Browse files
authored
fix: change counting logic for case of zero changes (#461)
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).
1 parent 77bbb7a commit e984206

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ runs:
349349
# If "tf.diff.txt" exists, display it within a "diff" block, truncated for character limit.
350350
if [[ -s tf.diff.txt ]]; then
351351
# Get count of lines in "tf.diff.txt" which do not start with "# ".
352-
diff_count=$(grep --invert-match '^# ' tf.diff.txt | wc --lines)
352+
diff_count=$({ grep --invert-match '^# ' tf.diff.txt || true; } | wc --lines)
353353
if [[ $diff_count -eq 1 ]]; then diff_change="change"; else diff_change="changes"; fi
354354
355355
# Parse diff of changes, truncated for character limit.

0 commit comments

Comments
 (0)