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
6 changes: 5 additions & 1 deletion .github/workflows/lint_audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ jobs:
id: changed-files
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "Pull Request detected"
echo "PR Head SHA: ${{ github.event.pull_request.head.sha }}"
echo "github.sha: ${{ github.sha }}"
git fetch origin ${{ github.base_ref }} || git fetch --unshallow
git diff --name-only origin/${{ github.base_ref }}...${{ github.sha }} > changed_files.txt || echo "Unable to determine changed files"
git fetch origin ${{ github.event.pull_request.head.sha }} || git fetch --unshallow
Comment on lines 48 to +49

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Improve error handling in git fetch operations.

The current implementation uses || git fetch --unshallow as a fallback, but this could mask other types of failures.

Consider using explicit error handling:

-            git fetch origin ${{ github.base_ref }} || git fetch --unshallow
-            git fetch origin ${{ github.event.pull_request.head.sha }} || git fetch --unshallow
+            if ! git fetch origin ${{ github.base_ref }}; then
+              if ! git fetch --unshallow; then
+                echo "Error: Failed to fetch ${{ github.base_ref }}"
+                exit 1
+              fi
+            fi
+            if ! git fetch origin ${{ github.event.pull_request.head.sha }}; then
+              if ! git fetch --unshallow; then
+                echo "Error: Failed to fetch PR head SHA"
+                exit 1
+              fi
+            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
git fetch origin ${{ github.base_ref }} || git fetch --unshallow
git diff --name-only origin/${{ github.base_ref }}...${{ github.sha }} > changed_files.txt || echo "Unable to determine changed files"
git fetch origin ${{ github.event.pull_request.head.sha }} || git fetch --unshallow
if ! git fetch origin ${{ github.base_ref }}; then
if ! git fetch --unshallow; then
echo "Error: Failed to fetch ${{ github.base_ref }}"
exit 1
fi
fi
if ! git fetch origin ${{ github.event.pull_request.head.sha }}; then
if ! git fetch --unshallow; then
echo "Error: Failed to fetch PR head SHA"
exit 1
fi
fi

git diff --name-only origin/${{ github.base_ref }}...${{ github.event.pull_request.head.sha }} > changed_files.txt || echo "Unable to determine changed files"
elif [ "${{ github.event_name }}" == "push" ]; then
git diff --name-only ${{ github.event.before }} ${{ github.sha }} > changed_files.txt || echo "Unable to determine changed files"
else
Expand Down