From 1699c98fea12dc7af6d74ad8e0617cad66497d17 Mon Sep 17 00:00:00 2001 From: tiawl Date: Sun, 10 Mar 2024 03:57:48 +0100 Subject: [PATCH] [progress #146] commit-msg hook --- .gitmodules | 0 TODO | 13 ---------- hooks/commit-msg | 64 ++++++++++++++++++++++++++++++++++-------------- 3 files changed, 45 insertions(+), 32 deletions(-) delete mode 100644 .gitmodules delete mode 100644 TODO diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29b..00000000 diff --git a/TODO b/TODO deleted file mode 100644 index e23d67f7..00000000 --- a/TODO +++ /dev/null @@ -1,13 +0,0 @@ -- check every payload capture => use pointer if necessary -- check ziggit doc for tips -- context module for each component -- use pointers into functions parameters -- use Uppercase for structs/enums/unions -- remove custom errors -- layers management: binding -> wrapper -> module -- change function names: convert_error () => convertError () -- avoid relative path into @import: @import ("../log.zig") => @import ("log") -- change wrapper/module functions: destroy () -> deinit () -- use std.fs.createFileAbsolute () instead of std.fs.cwd (). -- usage () and parse_options () should be Logger methods -- replace == by std.mem.eql () for string diff --git a/hooks/commit-msg b/hooks/commit-msg index 15150631..46cc5748 100755 --- a/hooks/commit-msg +++ b/hooks/commit-msg @@ -2,40 +2,41 @@ main () { - done_def='DONE - commit linked to a task and close it' - progress_def='PROGRESS - commit linked to a task and do not close it' + done_def='DONE - commit linked to an opened task and close it' + progress_def='PROGRESS - commit linked to an opened task and do not close it' fix_def='FIX - commit linked to a closed task' one_task_headers='done\|progress\|fix' - one_task_syntax='[ #] ' + one_task_syntax='[ #] ' one_task_commit='\[\('"${one_task_headers}"'\) #[0-9]\+\] .\+' - update_def='UPDATE - commit not linked to a task or linked to several tasks' - typo_def='TYPO - commit with insignificant content' - no_task_headers='update\|typo' + update_def='UPDATE - commit not linked to an opened task' + revert_def='REVERT - cancel problematic commit(s) (with ID(s) in )' + no_task_headers='update\|revert' - no_task_syntax='[] ' + no_task_syntax='[] ' no_task_commit='\[\('"${no_task_headers}"'\)\] .\+' release_def='RELEASE - commit related to a major/minor release' patch_def='PATCH - commit related to a patch' milestone_headers='release\|patch' - milestone_syntax='[] ' + milestone_syntax='[] ' milestone_commit='\[\('"${milestone_headers}"'\)\] .\+' merge_def='MERGE - solve conflicts' init_def='INIT - first commit' - special_headers='merge\|init' + typo_def='TYPO - commit with insignificant content' + specific_headers='merge\|init\|typo' - special_syntax='[]' - special_commit='\[\('"${special_headers}"'\)\]' + specific_syntax='[]' + specific_commit='\[\('"${specific_headers}"'\)\]' - warning='Commit message allows only one of those syntaxes:' + first_line='Commit message allows only one of these syntaxes:' replace_me='@@@' - message="${warning} + error="${first_line} ${replace_me} ${one_task_syntax} @@ -46,26 +47,51 @@ ${replace_me} ${no_task_syntax} ${update_def} - ${typo_def} + ${revert_def} ${replace_me} ${milestone_syntax} ${release_def} ${patch_def} ${replace_me} -${special_syntax} +${specific_syntax} ${merge_def} ${init_def} + ${typo_def} " - dashes="$(printf %"$(printf '%s' "${message}" | awk "{ print length }" | sort -n | tail -n1)"s | tr ' ' '-')" - - match="${one_task_commit}"'\|'"${no_task_commit}"'\|'"${milestone_commit}"'\|'"${special_commit}" + reset='\033[m' + bold='\033[1m' + red='\033[38;5;11m' + orange='\033[38;5;214m' + yellow='\033[38;5;9m' + apple='\033[38;5;10m' + green='\033[38;5;42m' + cyan='\033[38;5;51m' + blue='\033[38;5;69m' + navy='\033[38;5;21m' + purple='\033[38;5;129m' + pink='\033[38;5;201m' + + done_color="${apple}" + progress_color="${yellow}" + fix_color="${red}" + update_color="${orange}" + revert_color="${pink}" + release_color="${navy}" + patch_color="${purple}" + merge_color="${green}" + init_color="${cyan}" + typo_color="${blue}" + + dashes="$(printf %"$(printf '%s' "${error}" | awk "{ print length }" | sort -n | tail -n1)"s | tr ' ' '-')" + + match="${one_task_commit}"'\|'"${no_task_commit}"'\|'"${milestone_commit}"'\|'"${specific_commit}" if ! grep -q "${match}" "${1}" then - printf '%s' "${message}" | sed 's/^'"${replace_me}"'$/'"${dashes}"'/;'"$(printf 's/DONE/\033[1m\033[38;5;10mdone\033[m/;s/PROGRESS/\033[1m\033[38;5;11mprogress\033[m/;s/FIX/\033[1m\033[38;5;9mfix\033[m/;s/UPDATE/\033[1m\033[38;5;214mupdate\033[m/;s/TYPO/\033[1m\033[38;5;201mtypo\033[m/;s/RELEASE/\033[1m\033[38;5;21mrelease\033[m/;s/PATCH/\033[1m\033[38;5;129mpatch\033[m/;s/MERGE/\033[1m\033[38;5;42mmerge\033[m/;s/INIT/\033[1m\033[38;5;51minit\033[m/')" 1>&2 + printf '%s' "${error}" | sed 's/^'"${replace_me}"'$/'"${dashes}"'/;'"$(printf "s/DONE/${bold}${done_color}done${reset}/;s/PROGRESS/${bold}${progress_color}progress${reset}/;s/FIX/${bold}${fix_color}fix${reset}/;s/UPDATE/${bold}${update_color}update${reset}/;s/REVERT/${bold}${revert_color}revert${reset}/;s/RELEASE/${bold}${release_color}release${reset}/;s/PATCH/${bold}${patch_color}patch${reset}/;s/MERGE/${bold}${merge_color}merge${reset}/;s/INIT/${bold}${init_color}init${reset}/;s/TYPO/${bold}${typo_color}typo${reset}/")" 1>&2 return 1 fi }