From 412292a92b2021809a5054c08860bffafe1f5a9f Mon Sep 17 00:00:00 2001 From: Maxim Likhachev Date: Sat, 4 Mar 2023 13:50:29 +0500 Subject: [PATCH] git: add Jira template hook --- etc/soft/git/gitconfig | 16 +++++++++++++--- etc/soft/git/hooks/common/prepare-commit-msg | 7 ++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/etc/soft/git/gitconfig b/etc/soft/git/gitconfig index 4466bfa..44a0531 100644 --- a/etc/soft/git/gitconfig +++ b/etc/soft/git/gitconfig @@ -139,10 +139,13 @@ attributes = diffs #noindex # git push в текущий origin - u = "!echo \"# As $(git author)\n\"; echo git push origin $(git rev-parse --abbrev-ref HEAD)" + u = "!echo \"# As $(git author)\n# to $(git url)\n\"; echo git push origin $(git rev-parse --abbrev-ref HEAD)" + + # git force push в текущий origin + uf = "!echo \"# \\033[1;31m[ FORCE PUSH ]\\033[00m\n# As $(git author)\n# to $(git url)\n\"; echo git push origin $(git rev-parse --abbrev-ref HEAD) --force-with-lease" # git push во все репозитории - up = "!git remote -v | awk '{ print $1 }' | uniq | xargs -IL echo git push L $(git branch | awk '/*/ { print $2 }')" + up = "!git remote -v | awk '{ print $1 }' | uniq | xargs -IL echo git push L $(git rev-parse --abbrev-ref HEAD)" # Корневая директория репозитория root = rev-parse --show-toplevel @@ -176,7 +179,13 @@ ll = !git --no-pager log -1 HEAD && echo # Краткий список коммитов - ls = log --graph --pretty=format:'%Cred%h%Creset - %Cgreen[%cd]%Creset ::%C(yellow)%d%Creset %s %C(bold blue)<%an>%Creset' --abbrev-commit --date=short + ls = log --graph --pretty=format:'%Cred%h%Creset - %Cgreen[%cd]%Creset :: %s %C(bold blue)<%an>%Creset%C(yellow)%d%Creset' --abbrev-commit --date=short --color=always + + # Краткий список коммитов без слияний + lss = ls --no-merges + + # Краткий список коммитов с пиктограммами + li = !git lss | sed -E -e 's/Add /📗 /' -e 's/Fix /🐞 /' -e 's/(Improve|Adjust) /⚙️ /' | less # Полный журнал изменений lf = log --source --graph --stat --date=iso --pretty=medium --decorate=full @@ -245,4 +254,5 @@ # Информация о репозитории https://github.com/o2sh/onefetch card = !onefetch + change-commits = "!f() { VAR=$1; OLD=$2; NEW=$3; shift 3; git filter-branch --env-filter \"if [[ \\\"$`echo $VAR`\\\" = '$OLD' ]]; then export $VAR='$NEW'; fi\" $@; }; f" diff --git a/etc/soft/git/hooks/common/prepare-commit-msg b/etc/soft/git/hooks/common/prepare-commit-msg index b45ada7..de4289b 100755 --- a/etc/soft/git/hooks/common/prepare-commit-msg +++ b/etc/soft/git/hooks/common/prepare-commit-msg @@ -2,11 +2,12 @@ NUM_COMMITS=5 JIRA_TASK=$(git rev-parse --abbrev-ref HEAD |& grep -E -o '^[a-zA-Z]+-\d+') -COMMITS="$(git log --pretty="# %h %s [%an]" --no-merges -${NUM_COMMITS})" -HEADER="# -# ----------------------" +COMMITS=$(git log --pretty="# %h %s [%an]" --no-merges "-${NUM_COMMITS}") +USER="$(git config --get user.email)" template() { + echo "# As ${USER}" + [[ -n "${JIRA_TASK}" ]] && echo "# ${JIRA_TASK}" cat <<-EOF