mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 16:35:33 +00:00
These changes come out of discussion in the team; we want to make use of git trailers and improve the quality of our commit messages. Starting by adding more hints to the commit suggestions. Includes some minor cleanup of the hooks, and hopefully also improves tests so that they don't interfere with interactions with non-Keyman repos. Note: the scopes list may need maintenance as the list still includes sub-scopes and 'oem'.
41 lines
1.1 KiB
Bash
Executable file
41 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
#
|
|
# for github.com/keymanapp repositories only!
|
|
#
|
|
|
|
GIT_ORIGIN="$(git remote get-url origin)"
|
|
|
|
if [[ ! "$GIT_ORIGIN" =~ github\.com/keymanapp ]]; then
|
|
# Not a Keyman repository. We have no opinion.
|
|
echo "DEBUG: Not a Keyman repository. We don't care"
|
|
exit 0
|
|
fi
|
|
|
|
#
|
|
# We want to make sure that .sh files are executable; however, .inc.sh need not
|
|
# be as they are always source-included in scripts.
|
|
#
|
|
SH_NON_EXECUTABLE=`git ls-files --stage | grep "\\.sh$" | grep -v "\\.inc\\.sh$" | grep -v 755 | cut -f 2 -`
|
|
|
|
if [ ! -z "$SH_NON_EXECUTABLE" ]; then
|
|
echo "ERROR: The following scripts are not marked as executable:"
|
|
echo
|
|
echo "$SH_NON_EXECUTABLE"
|
|
echo
|
|
echo "You can mark them as executable with:"
|
|
echo " git add --chmod=+x"
|
|
exit 1
|
|
fi
|
|
|
|
#
|
|
# Prevent accidental commits to master, beta, stable-x.y, or staging (for websites)
|
|
#
|
|
branch="$(git rev-parse --abbrev-ref HEAD)"
|
|
|
|
if [[ "$branch" =~ ^(master|beta|stable-\d+\.\d+|staging)$ ]]; then
|
|
echo "ERROR: You cannot commit to $branch for this repo. Create a branch and open a pull request\n"
|
|
exit 2
|
|
fi
|
|
|
|
exit 0
|