diff --git a/README.md b/README.md index c32c037..704623e 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/git-branch-linearity.sh b/git-branch-linearity.sh index ca0eac7..9a7164f 100755 --- a/git-branch-linearity.sh +++ b/git-branch-linearity.sh @@ -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" ]