Skip to content

Commit 8d428a2

Browse files
authored
Merge pull request #8 from Kpler/perf/git-branch-linearity/add-target-branch-option
feat(git-branch-linearity): add target-branch option
2 parents 872f868 + de9a60c commit 8d428a2

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ Some out-of-the-box hooks for [pre-commit](https://github.com/pre-commit/pre-com
88
Add this to your `.pre-commit-config.yaml`
99

1010
- repo: https://github.com/Kpler/kp-pre-commit-hooks.git
11-
rev: v0.0.3 # Use the ref you want to point at
11+
rev: v0.0.7 # Use the ref you want to point at
1212
hooks:
1313
- id: check-branch-linearity
14-
- id: check-commit-first-line-length
1514
- id: check-branch-name
15+
- id: no-ephemeral-links
16+
exclude: '\.md$'
1617

1718
### Hooks available
1819

1920
#### `check-branch-linearity`
20-
Simply check that your branch doesn't not contain any merge compare to master.
21+
Simply check that your branch doesn't not contain any merge compare to `master` or `main` branch.
2122
It's a pre-push hook and will always run
2223

2324
#### `check-branch-name`

git-branch-linearity.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/sh
2-
out=$(git log origin/master..HEAD --merges --oneline)
2+
3+
if [ "$(git branch --list main)" ]; then TARGET_BRANCH="main"; else TARGET_BRANCH="master"; fi
4+
5+
echo "Target branch: $TARGET_BRANCH"
6+
out=$(git log origin/${TARGET_BRANCH}..HEAD --merges --oneline)
37

48
exit_status=$?
59
if [ -n "$out" ]

0 commit comments

Comments
 (0)