File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,20 +7,29 @@ Some out-of-the-box hooks for [pre-commit](https://github.com/pre-commit/pre-com
77
88Add this to your ` .pre-commit-config.yaml `
99
10+ ``` yaml
1011 - repo : https://github.com/Kpler/kp-pre-commit-hooks.git
1112 rev : v0.0.7 # Use the ref you want to point at
1213 hooks :
1314 - id : check-branch-linearity
1415 - id : check-branch-name
1516 - id : no-ephemeral-links
1617 exclude : ' \.md$'
18+ ` ` `
1719
1820### Hooks available
1921
2022#### ` check-branch-linearity`
21- Simply check that your branch doesn't not contain any merge compare to ` master ` or ` main ` branch .
23+ Simply check that your branch doesn't not contain any merge compare to a target branch, `master` by default .
2224It's a pre-push hook and will always run
2325
26+ To configure the target branch :
27+ ` ` ` yaml
28+ hooks:
29+ - id: check-branch-linearity
30+ args: [targetbranch]
31+ ` ` `
32+
2433# ### `check-branch-name`
2534Check that branch name is less than 70 characters
2635It's a pre-push hook and will always run
Original file line number Diff line number Diff line change 11#! /bin/sh
22
3- git fetch origin main:refs/remotes/origin/main 2> /dev/null
4- if [ $? -eq 0 ]; then TARGET_BRANCH=" main" ; else TARGET_BRANCH=" master" ; fi
3+ # Use parameter passed to the script or default to master
4+ TARGET_BRANCH=" ${1:- master} "
5+
56echo " Target branch: $TARGET_BRANCH "
7+ git fetch origin $TARGET_BRANCH 2> /dev/null
68
79out=$( git log origin/${TARGET_BRANCH} ..HEAD --merges --oneline)
810exit_status=$?
You can’t perform that action at this time.
0 commit comments