Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions hack/prow_pr_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -e

REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd)

echo "Using git version $(git version)"
echo "Using go version $(go version)"

cd "${REPO_ROOT}"

# Run tests
make test

# Generate syncset and package resources
go run build/resources.go \
-exclude debug-hook \
-syncsetfile build/selectorsyncset.yaml

go run build/resources.go \
-packagedir config/package

# Make sure nothing changed (i.e. generated resources being out of date)
if ! git diff --exit-code; then
echo "FAILURE: unexpected changes after building. Run 'make syncset package' and commit changes."
exit 1
Comment on lines +24 to +26
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

git diff --exit-code misses untracked generated files

Line 24 only checks tracked-file diffs, so newly generated untracked files can slip through. That weakens the “generated artifacts are committed” gate. Also, Line 25’s remediation message still points to container-based targets.

Suggested fix
-if ! git diff --exit-code; then
-    echo "FAILURE: unexpected changes after building. Run 'make syncset package' and commit changes."
+if [[ -n "$(git status --porcelain --untracked-files=all)" ]]; then
+    git status --short
+    echo "FAILURE: unexpected changes after building. Regenerate resources and commit all tracked/untracked changes."
     exit 1
 fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ! git diff --exit-code; then
echo "FAILURE: unexpected changes after building. Run 'make syncset package' and commit changes."
exit 1
if [[ -n "$(git status --porcelain --untracked-files=all)" ]]; then
git status --short
echo "FAILURE: unexpected changes after building. Regenerate resources and commit all tracked/untracked changes."
exit 1
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@build/prow_pr_check.sh` around lines 24 - 26, The current check uses git diff
--exit-code which misses untracked generated files; replace the check around git
diff --exit-code with a two-part verification: run git diff --exit-code and then
run git status --porcelain --untracked-files=all (or git ls-files --others
--exclude-standard) and fail if either reports changes, and update the failure
message printed by the echo that currently starts "FAILURE: unexpected changes
after building..." to instruct the user to regenerate artifacts and commit them
(e.g., "Run 'make syncset package' or 'make generate' to regenerate artifacts,
add and commit the changes.") — locate and modify the git diff --exit-code check
and the associated echo/exit 1 lines in build/prow_pr_check.sh.

fi