Got golden hooks.

This commit is contained in:
Vahagn Khachatryan
2020-06-22 10:22:34 -04:00
parent 8122906e08
commit 227c9d884b
3 changed files with 90 additions and 1 deletions

View File

@@ -13,7 +13,10 @@
br = branch br = branch
co = checkout co = checkout
ci = commit ci = commit
svnsync = "!f(){ git co master && git pull && ssh devgit svnsync $(git config --get remote.origin.url | cut -d : -f 2 );}; f" upload = "!f(){ git push $@ origin $(git rev-parse --abbrev-ref HEAD); }; f"
faxm = "!f(){ git fetch upstream master && git checkout -b ENG1FAXM-$1 upstream/master; }; f"
drqs = "!f(){ git fetch upstream master && git checkout -b DRQS-$1 upstream/master; }; f"
install-hooks = "!f(){ GIT_HOOKS=\"$(git rev-parse --git-dir)/hooks/\"; GOLDEN_HOOKS=\"$HOME/devel/scripts/git/hooks\"; [ -d \"$GIT_HOOKS\" ] && [ -d \"$GOLDEN_HOOKS\" ] && cp -r \"$GOLDEN_HOOKS/.\" \"$GIT_HOOKS\"; }; f"
[merge] [merge]
tool = vimdiff tool = vimdiff
conflictstyle = diff3 conflictstyle = diff3

42
git/hooks/commit-msg Executable file
View File

@@ -0,0 +1,42 @@
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
# This example catches duplicate Signed-off-by lines.
#test "" = "$(grep '^Signed-off-by: ' "$1" |
# sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
# echo >&2 Duplicate Signed-off-by lines.
# exit 1
#}
#
# SPELL CHECK
#
# 1. Install hunspell
# 2. Download a dictionary
# $ open http://wiki.services.openoffice.org/wiki/Dictionaries
# 3. Move this file into your repository
# $ mv commit-msg /path/to/repo/.git/hooks
# $ chmod +x /path/to/repo/.git/hooks/commit-msg
#
CHECK=$(cat $1 | hunspell -d en_US -l)
if [ "${CHECK}" != "" ]; then
echo "Spell Check Error: ${CHECK}"
echo "Message: $(cat $1)"
exit 1
fi

44
git/hooks/prepare-commit-msg Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".
#
# Extract ticket id from the branch name and Append to commit message.
# Pattern NAME-NUMBER. e.g. ERROR-234
#
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3
MESSAGE=$(cat $COMMIT_MSG_FILE)
TICKET=$(git rev-parse --abbrev-ref HEAD | grep -Eo '^(\w+/)?(\w+[-_])[0-9]+' | grep -Eo '(\w+[-])[0-9]+' | tr "[:lower:]" "[:upper:]"):
if [[ $TICKET == ":" || "$MESSAGE" == "$TICKET"* ]];then
exit 0;
fi
echo "$TICKET $MESSAGE" > $COMMIT_MSG_FILE
#/opt/bb/bin/perl5.16 -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
# case "$COMMIT_SOURCE,$SHA1" in
# ,|template,)
# /opt/bb/bin/perl5.16 -i.bak -pe '
# print "\n" . `git diff --cached --name-status -r`
# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
# *) ;;
# esac
# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
# if test -z "$COMMIT_SOURCE"
# then
# /opt/bb/bin/perl5.16 -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
# fi