From 66ffeacafd3daf67b4eb442ba75c80b949741cfc Mon Sep 17 00:00:00 2001 From: Ghasem Shirdel Date: Tue, 18 Jan 2022 12:05:19 +0330 Subject: [PATCH] fix(template.sh): fix space issue An additional number of new lines may be printed when the final result is printed. --- .../git-commit-template.plugin.zsh | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/plugins/git-commit-template/git-commit-template.plugin.zsh b/plugins/git-commit-template/git-commit-template.plugin.zsh index ef224f816..194f87d3c 100644 --- a/plugins/git-commit-template/git-commit-template.plugin.zsh +++ b/plugins/git-commit-template/git-commit-template.plugin.zsh @@ -101,15 +101,25 @@ octo-org/octo-repo#100\n\n" scope="(${scope})" fi - if [ ! -z "$breaking_changes" ]; then - breaking_changes="BREAKING CHANGE: ${breaking_changes}" + massage="\n ${GREEN}${type_var}${scope}: ${short_desc}\n" + + if [ ! -z "$long_desc" ] || [ ! -z "$breaking_changes" ] || [ ! -z "$closed_issues" ]; then + massage="${massage}\n" fi - printf "\n ${GREEN}${type_var}${scope}: ${short_desc} + if [ ! -z "$long_desc" ]; then + massage="${massage} ${long_desc}\n" + fi - ${long_desc} - ${breaking_changes} - ${closed_issues}${RESET}\n\n" + if [ ! -z "$breaking_changes" ]; then + massage="${massage} BREAKING CHANGE: ${breaking_changes}\n" + fi + + if [ ! -z "$closed_issues" ]; then + massage="${massage} ${closed_issues}\n" + fi + + printf "${massage}\n${RESET}" # Git commit result_code=$?