Skip to content

Instantly share code, notes, and snippets.

@refactorsaurusrex
Last active December 23, 2019 14:58
Show Gist options
  • Save refactorsaurusrex/2259e14c981e2b353df1f8b6066769dc to your computer and use it in GitHub Desktop.
Save refactorsaurusrex/2259e14c981e2b353df1f8b6066769dc to your computer and use it in GitHub Desktop.

Revisions

  1. refactorsaurusrex revised this gist Dec 23, 2019. No changes.
  2. refactorsaurusrex revised this gist Oct 23, 2017. No changes.
  3. refactorsaurusrex created this gist Oct 23, 2017.
    13 changes: 13 additions & 0 deletions prepare-commit-msg.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/bin/sh
    if [ "$2" = "merge" ]; then
    githead=$(env | grep GITHEAD)
    source="${githead##*=}"
    target=$(git symbolic-ref HEAD)
    behind=$(git rev-list --left-only --count $target...$source)
    if [ $behind -gt 0 ]; then
    echo "Aborting: The source branch is $behind commits behind the target branch."
    exit 1
    fi
    fi

    #ref https://superuser.com/a/926038/51794