Skip to content

Commit 9facaf2

Browse files
author
Tulga Tsogtgerel
committed
git commit auto formatting disabled
1 parent 9e07e6e commit 9facaf2

File tree

1 file changed

+60
-57
lines changed

1 file changed

+60
-57
lines changed

.husky/pre-commit

Lines changed: 60 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,67 +4,70 @@ bun test
44
# Exit on any error
55
set -e
66

7-
# Check if there are any staged files
8-
if [ -z "$(git diff --cached --name-only)" ]; then
9-
echo "No staged files to format"
10-
exit 0
11-
fi
7+
# Auto-formatting disabled
8+
# Uncomment the code below to re-enable auto-formatting on commit
129

13-
# Store the hash of staged changes to detect modifications
14-
STAGED_HASH=$(git diff --cached | sha256sum | cut -d' ' -f1)
10+
# # Check if there are any staged files
11+
# if [ -z "$(git diff --cached --name-only)" ]; then
12+
# echo "No staged files to format"
13+
# exit 0
14+
# fi
1515

16-
# Save list of staged files (handling all file states)
17-
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR)
18-
PARTIALLY_STAGED=$(git diff --name-only)
16+
# # Store the hash of staged changes to detect modifications
17+
# STAGED_HASH=$(git diff --cached | sha256sum | cut -d' ' -f1)
1918

20-
# Stash unstaged changes to preserve working directory
21-
# --keep-index keeps staged changes in working tree
22-
git stash push --quiet --keep-index --message "pre-commit-stash" || true
23-
STASHED=$?
19+
# # Save list of staged files (handling all file states)
20+
# STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR)
21+
# PARTIALLY_STAGED=$(git diff --name-only)
2422

25-
# Run formatter on the staged files
26-
bun x ultracite fix
27-
FORMAT_EXIT_CODE=$?
23+
# # Stash unstaged changes to preserve working directory
24+
# # --keep-index keeps staged changes in working tree
25+
# git stash push --quiet --keep-index --message "pre-commit-stash" || true
26+
# STASHED=$?
2827

29-
# Restore working directory state
30-
if [ $STASHED -eq 0 ]; then
31-
# Re-stage the formatted files
32-
if [ -n "$STAGED_FILES" ]; then
33-
echo "$STAGED_FILES" | while IFS= read -r file; do
34-
if [ -f "$file" ]; then
35-
git add "$file"
36-
fi
37-
done
38-
fi
39-
40-
# Restore unstaged changes
41-
git stash pop --quiet || true
42-
43-
# Restore partial staging if files were partially staged
44-
if [ -n "$PARTIALLY_STAGED" ]; then
45-
for file in $PARTIALLY_STAGED; do
46-
if [ -f "$file" ] && echo "$STAGED_FILES" | grep -q "^$file$"; then
47-
# File was partially staged - need to unstage the unstaged parts
48-
git restore --staged "$file" 2>/dev/null || true
49-
git add -p "$file" < /dev/null 2>/dev/null || git add "$file"
50-
fi
51-
done
52-
fi
53-
else
54-
# No stash was created, just re-add the formatted files
55-
if [ -n "$STAGED_FILES" ]; then
56-
echo "$STAGED_FILES" | while IFS= read -r file; do
57-
if [ -f "$file" ]; then
58-
git add "$file"
59-
fi
60-
done
61-
fi
62-
fi
28+
# # Run formatter on the staged files
29+
# bun x ultracite fix
30+
# FORMAT_EXIT_CODE=$?
6331

64-
# Check if staged files actually changed
65-
NEW_STAGED_HASH=$(git diff --cached | sha256sum | cut -d' ' -f1)
66-
if [ "$STAGED_HASH" != "$NEW_STAGED_HASH" ]; then
67-
echo "✨ Files formatted by Ultracite"
68-
fi
32+
# # Restore working directory state
33+
# if [ $STASHED -eq 0 ]; then
34+
# # Re-stage the formatted files
35+
# if [ -n "$STAGED_FILES" ]; then
36+
# echo "$STAGED_FILES" | while IFS= read -r file; do
37+
# if [ -f "$file" ]; then
38+
# git add "$file"
39+
# fi
40+
# done
41+
# fi
6942

70-
exit $FORMAT_EXIT_CODE
43+
# # Restore unstaged changes
44+
# git stash pop --quiet || true
45+
46+
# # Restore partial staging if files were partially staged
47+
# if [ -n "$PARTIALLY_STAGED" ]; then
48+
# for file in $PARTIALLY_STAGED; do
49+
# if [ -f "$file" ] && echo "$STAGED_FILES" | grep -q "^$file$"; then
50+
# # File was partially staged - need to unstage the unstaged parts
51+
# git restore --staged "$file" 2>/dev/null || true
52+
# git add -p "$file" < /dev/null 2>/dev/null || git add "$file"
53+
# fi
54+
# done
55+
# fi
56+
# else
57+
# # No stash was created, just re-add the formatted files
58+
# if [ -n "$STAGED_FILES" ]; then
59+
# echo "$STAGED_FILES" | while IFS= read -r file; do
60+
# if [ -f "$file" ]; then
61+
# git add "$file"
62+
# fi
63+
# done
64+
# fi
65+
# fi
66+
67+
# # Check if staged files actually changed
68+
# NEW_STAGED_HASH=$(git diff --cached | sha256sum | cut -d' ' -f1)
69+
# if [ "$STAGED_HASH" != "$NEW_STAGED_HASH" ]; then
70+
# echo "✨ Files formatted by Ultracite"
71+
# fi
72+
73+
# exit $FORMAT_EXIT_CODE

0 commit comments

Comments
 (0)