From 1730cf6f663003a11a7d2411632556e29a5427c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Benjara?= Date: Thu, 8 Aug 2024 19:40:39 +0300 Subject: [PATCH] Add Git configuration files --- .git-template/hooks/commit-msg | 15 ++++++++++++++ .gitconfig | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 .git-template/hooks/commit-msg create mode 100644 .gitconfig diff --git a/.git-template/hooks/commit-msg b/.git-template/hooks/commit-msg new file mode 100755 index 0000000..594e7f4 --- /dev/null +++ b/.git-template/hooks/commit-msg @@ -0,0 +1,15 @@ +#!/bin/bash + +# Regex to validate the type pattern +REGEX="^((Merge[ a-z-]* branch.*)|(Revert*)|((build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?!?: .*))" + +FILE=`cat $1` # File containing the commit message + +echo "Commit Message: ${FILE}" + +if ! [[ $FILE =~ $REGEX ]]; then + echo >&2 "ERROR: Commit aborted for not following the Conventional Commit standard.​" + exit 1 +else + echo >&2 "Valid commit message." +fi diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 0000000..3af4d56 --- /dev/null +++ b/.gitconfig @@ -0,0 +1,37 @@ +[user] + name = Ismaël Benjara + email = 0xcezelot@gmail.com +[init] + defaultBranch = main + templatedir = /home/deckard/.git-template +[alias] + br = branch + ci = commit + cl = clone + co = checkout + cp = cherry-pick + dc = diff --cached + diff = diff --word-diff + diffr = "!f() { git diff "$1"^.."$1"; }; f" + dl = "!git ll -1" + dlc = diff --cached HEAD^ + dr = "!f() { git diff "$1"^.."$1"; }; f" + f = "!git ls-files | grep -i" + filelog = log -u + fl = log -u + gr = grep -Ii + gra = "!f() { A=$(pwd) && TOPLEVEL=$(git rev-parse --show-toplevel) && cd $TOPLEVEL && git grep --full-name -In $1 | xargs -I{} echo $TOPLEVEL/{} && cd $A; }; f" + grep = grep -Ii + la = "!git config -l | grep alias | cut -c 7-" + lasttag = describe --tags --abbrev=0 + lc = "!f() { git ll "$1"^.."$1"; }; f" + ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative + lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short + le = log --oneline --decorate + ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat + lnc = log --pretty=format:"%h\\ %s\\ [%cn]" + ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate + lt = describe --tags --abbrev=0 + st = status -s +[core] + hooksPath = /home/deckard/.git-template/hooks -- 2.45.2