Skip to content

Commit

Permalink
mini-yetus : Improve error reporting
Browse files Browse the repository at this point in the history
Improve error reporting in mini-yetus.sh script and don't exit if files
dosn't exist. Instead, print an error message and continue. This can happen
if the current branch is built on top of the source branch but source
branch has diverged and some files are not present in the current branch.
This changes allow the script to atleast run yetus on the files that do
exist in the current branch.

Signed-off-by: Shahriyar Jalayeri <[email protected]>
  • Loading branch information
shjala committed Aug 31, 2024
1 parent 9306726 commit dfc4fbc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tools/mini-yetus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,17 @@ if ! git rev-parse --verify "$DST_BRANCH" >/dev/null 2>&1; then
exit 1
fi

MISSING_FILE_REPORTED=false
SRC_DIR=$(mktemp -d)
git diff --name-only "$SRC_BRANCH".."$DST_BRANCH" | grep -v '/vendor/' | while IFS= read -r file; do
if [ -e "$file" ]; then
cp --parents -r "$PWD/$file" "$SRC_DIR/" || { echo "Failed to copy $file"; exit 1; }
else
if [ "$MISSING_FILE_REPORTED" = false ]; then
echo "[*] Some files are missing from current branch, if you are comparing against main/master, a rebase might be needed."
MISSING_FILE_REPORTED=true
fi
echo "[!] File does not exist: $PWD/$file"
exit 1
fi
done

Expand Down Expand Up @@ -111,7 +115,7 @@ if [ "$FULL" = true ]; then
echo "[+] Full results:"
if [ "$(uname)" = "Darwin" ]; then
if ! command -v gsed >/dev/null 2>&1; then
echo "[*] GNU sed not found. install it to have the best experience."
echo "[*] GNU sed not found. Install it to have the best experience."
cat "$SRC_DIR/yetus-output/results-full.txt"
else
gsed -e '/^\./!s|^|/|' "$SRC_DIR/yetus-output/results-full.txt"
Expand All @@ -123,4 +127,4 @@ if [ "$FULL" = true ]; then
fi
fi

echo "[+] results stored in $SRC_DIR/yetus-output"
echo "[+] Results stored in $SRC_DIR/yetus-output"

0 comments on commit dfc4fbc

Please sign in to comment.