Skip to content

Commit 9a227ba

Browse files
committed
Fix release script pre-commit hook race condition
- Use lefthook's stage_fixed option instead of manual git add - Prevents index.lock errors when hooks run in parallel - Fixes rake release task failures during version bumps
1 parent c1ae439 commit 9a227ba

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

.lefthook.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,23 @@ pre-commit:
66
parallel: true
77
commands:
88
autofix:
9+
glob: "*.{rb,rake,ru}"
910
run: bin/lefthook/ruby-autofix all-changed
11+
stage_fixed: true
1012

1113
rubocop:
14+
glob: "*.{rb,rake,ru}"
1215
run: bin/lefthook/ruby-lint all-changed
1316

1417
eslint:
18+
glob: "*.{js,jsx,ts,tsx}"
1519
run: bin/lefthook/eslint-lint all-changed
20+
stage_fixed: true
1621

1722
prettier:
23+
glob: "*.{js,jsx,ts,tsx,json,md,yml,yaml}"
1824
run: bin/lefthook/prettier-format all-changed
25+
stage_fixed: true
1926

2027
trailing-newlines:
2128
run: bin/lefthook/check-trailing-newlines all-changed

bin/lefthook/prettier-format

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ if [ -n "$root_files" ]; then
2424
printf " %s\n" $root_files
2525

2626
yarn run prettier --write $root_files
27-
28-
# Re-stage files if running on staged or all-changed context
29-
if [ "$CONTEXT" = "staged" ] || [ "$CONTEXT" = "all-changed" ]; then
30-
echo $root_files | xargs -r git add
31-
fi
3227
fi
3328

3429
# Format Pro files (using Pro's Prettier config)
@@ -44,11 +39,6 @@ if [ -n "$pro_files" ]; then
4439
pro_files_relative=$(echo "$pro_files" | sed 's|^react_on_rails_pro/||')
4540

4641
(cd react_on_rails_pro && yarn run prettier --write $pro_files_relative)
47-
48-
# Re-stage files if running on staged or all-changed context
49-
if [ "$CONTEXT" = "staged" ] || [ "$CONTEXT" = "all-changed" ]; then
50-
echo $pro_files | xargs -r git add
51-
fi
5242
fi
5343

5444
echo "✅ Prettier formatting complete"

bin/lefthook/ruby-autofix

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,4 @@ printf " %s\n" $files
1919

2020
bundle exec rake autofix
2121

22-
# Re-stage files if running on staged or all-changed context
23-
if [ "$CONTEXT" = "staged" ] || [ "$CONTEXT" = "all-changed" ]; then
24-
echo $files | xargs -r git add
25-
echo "✅ Re-staged formatted files"
26-
fi
22+
echo "Completed auto-fixing all linting violations"

0 commit comments

Comments
 (0)