Skip to content
This repository has been archived by the owner on Jan 17, 2025. It is now read-only.

Commit

Permalink
Stage only files modified by pre-commit
Browse files Browse the repository at this point in the history
Signed-off-by: Karanjot Singh <[email protected]>
  • Loading branch information
0xquark committed Oct 4, 2023
1 parent 2275bac commit 03ffa64
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .git-hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ do
pre-commit run -a

# Check if there are any changes
if git diff --quiet; then
if [[ -n $(git diff --cached --name-only) ]]; then
echo "No changes after running pre-commit."
break # Exit the loop if there are no changes
else
# Stage the changes
git add .
# Stage only the files modified by the pre-commit
git diff --name-only --cached | xargs git add
fi
done

0 comments on commit 03ffa64

Please sign in to comment.