File tree 1 file changed +25
-1
lines changed
1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 329
329
echo 1>&2 " 3. add .pre-commit-config.yaml to .gitignore"
330
330
else
331
331
ln -s ${ configFile } .pre-commit-config.yaml
332
- pre-commit install
332
+ # Remove any previously installed hooks (since pre-commit iteslf has no idempotent design)
333
+ hooks="pre-commit pre-merge-commit pre-push prepare-commit-msg commit-msg post-checkout post-commit"
334
+ for hook in $hooks; do
335
+ pre-commit uninstall -t $hook
336
+ done
337
+ # Add hooks for configured stages (only) ...
338
+ if [ ! -z "${ concatStringsSep " " cfg . default_stages } " ]; then
339
+ for stage in ${ concatStringsSep " " cfg . default_stages } ; do
340
+ case $stage in
341
+ commit | merge-commit | push)
342
+ stage="pre-"$stage
343
+ pre-commit install -t $stage
344
+ ;;
345
+ prepare-commit-msg | commit-msg | post-checkout | post-commit)
346
+ stage="pre-"$stage
347
+ pre-commit install -t $stage
348
+ ;;
349
+ *)
350
+ ;;
351
+ esac
352
+ done
353
+ # ... or default 'pre-commit' hook
354
+ else
355
+ pre-commit install
356
+ fi
333
357
fi
334
358
fi
335
359
fi
You can’t perform that action at this time.
0 commit comments