Browse Source

git: add Jira template hook

master
Maxim Likhachev 2 years ago
parent
commit
412292a92b
  1. 16
      etc/soft/git/gitconfig
  2. 7
      etc/soft/git/hooks/common/prepare-commit-msg

16
etc/soft/git/gitconfig

@ -139,10 +139,13 @@ @@ -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 @@ @@ -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 @@ @@ -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"

7
etc/soft/git/hooks/common/prepare-commit-msg

@ -2,11 +2,12 @@ @@ -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

Loading…
Cancel
Save