Skip to content

Commit

Permalink
Merge pull request #8 from Kpler/perf/git-branch-linearity/add-target…
Browse files Browse the repository at this point in the history
…-branch-option

feat(git-branch-linearity): add target-branch option
  • Loading branch information
gmocquet authored Jun 16, 2021
2 parents 872f868 + de9a60c commit 8d428a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ Some out-of-the-box hooks for [pre-commit](https://github.com/pre-commit/pre-com
Add this to your `.pre-commit-config.yaml`

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

### Hooks available

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

#### `check-branch-name`
Expand Down
6 changes: 5 additions & 1 deletion git-branch-linearity.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/sh
out=$(git log origin/master..HEAD --merges --oneline)

if [ "$(git branch --list main)" ]; then TARGET_BRANCH="main"; else TARGET_BRANCH="master"; fi

echo "Target branch: $TARGET_BRANCH"
out=$(git log origin/${TARGET_BRANCH}..HEAD --merges --oneline)

exit_status=$?
if [ -n "$out" ]
Expand Down

0 comments on commit 8d428a2

Please sign in to comment.