From b1ee81f4f0f3f5803dc848a13c40633bcfc65293 Mon Sep 17 00:00:00 2001 From: Ghasem Shirdel Date: Sun, 23 Jan 2022 10:12:44 +0330 Subject: [PATCH] feat(template.sh): add sign to gct To sign committees, just set the GPG for the git and then sign the template with `-s` or `sign` args. --- .../git-commit-template.plugin.zsh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/git-commit-template/git-commit-template.plugin.zsh b/plugins/git-commit-template/git-commit-template.plugin.zsh index 194f87d3c..07cbe57a1 100644 --- a/plugins/git-commit-template/git-commit-template.plugin.zsh +++ b/plugins/git-commit-template/git-commit-template.plugin.zsh @@ -1,5 +1,11 @@ git_commit_template() { + # Check the current folder is a git repository + $(git -C $PWD rev-parse) + if [[ $? != 0 ]]; then + exit 1 + fi + # Color formatting RED="\033[0;31m" GREEN="\033[0;32m" @@ -122,13 +128,20 @@ octo-org/octo-repo#100\n\n" printf "${massage}\n${RESET}" # Git commit - result_code=$? - if [ "$result_code" = 0 ]; then - git commit -m "${type_var}${scope}: ${short_desc} + if [ $? == 0 ]; then + if [[ $1 == "-s" ]] || [[ $1 == "sign" ]]; then + git commit -S -m "${type_var}${scope}: ${short_desc} ${long_desc} ${breaking_changes} ${closed_issues}" + else + git commit -m "${type_var}${scope}: ${short_desc} + +${long_desc} +${breaking_changes} +${closed_issues}" + fi else printf "\n${RED}❌ An error occurred. Please try again.${RESET}\n" exit 1