From 225c30e469ea1b38c707e5508018cffca32ef71e Mon Sep 17 00:00:00 2001 From: ghasem shirdel Date: Fri, 7 Jan 2022 13:12:52 +0330 Subject: [PATCH 01/13] feat(git-commit-template): add plugin file This plugin use for git commit template. --- .../git-commit-template.plugin.zsh | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 plugins/git-commit-template/git-commit-template.plugin.zsh diff --git a/plugins/git-commit-template/git-commit-template.plugin.zsh b/plugins/git-commit-template/git-commit-template.plugin.zsh new file mode 100644 index 000000000..3ddf033d9 --- /dev/null +++ b/plugins/git-commit-template/git-commit-template.plugin.zsh @@ -0,0 +1,113 @@ +function git_commit_template() { + # Check in this directory git exist + if [ ! -d .git ]; then + exit 1 + fi + + # Color formatting + RED="\033[0;31m" + GREEN="\033[0;32m" + BLUE="\033[1;34m" + CYAN="\033[0;36m" + RESET="\033[0m" + + # Valid types + TYPES=("feat" "fix" "docs" "style" "refactor" "pref" "test" "build" "ci" "chore" "revert") + NUMBERS=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11") + + # Type section + printf "${BLUE}>>> Type of change (name or number)?${RESET}\n\n" + + printf "${CYAN}1. feat${RESET} - A new feature.\n" + printf "${CYAN}2. fix${RESET} - A bug fix.\n" + printf "${CYAN}3. docs${RESET} - Documentation only changes.\n" + printf "${CYAN}4. style${RESET} - Changes that do notaffect the meaning of the code (white-space, formatting, missing semi-colons, etc).\n" + printf "${CYAN}5. refactor${RESET} - A Code change that neither fixes a bug nor adds a feature.\n" + printf "${CYAN}6. pref${RESET} - A code change that improves performance.\n" + printf "${CYAN}7. test${RESET} - Adding missing tests or correcting existing tests.\n" + printf "${CYAN}8. build${RESET} - Changes that effect the build system or external dependencies (example scopes: glup, broccoli, npm).\n" + printf "${CYAN}9. ci${RESET} - Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs).\n" + printf "${CYAN}10. chore${RESET} - Other changes that don't modify src or test files.\n" + printf "${CYAN}11. revert${RESET} - Reverts a previous commit.\n\n" + + while :; do + read -e TYPE + # To lower case + TYPE=${TYPE,,} + # When input type is valid loop break + if [[ " ${NUMBERS[*]} " =~ " ${TYPE} " ]]; then + TYPE="${TYPES[TYPE - 1]}" + break + elif [[ " ${TYPES[*]} " =~ " ${TYPE} " ]]; then + break + else + printf "${RED}❌ Please select a valid type.${RESET}\n" + fi + done + + # Scppe section + printf "\n${BLUE}>>> Scope of this change (optional)?${RESET}\n" + printf "The scope could be anything specifying place of the commit change e.g a file name, function name, class name, component name etc.\n\n" + read -e SCOPE + + # Subject section + printf "\n${BLUE}>>> Short description?${RESET}\n" + printf "The short description contains succinct description of the change:\n" + printf ' • use the imperative, present tense: "change" not "changed" nor "changes"\n' + printf " • don't capitalize first letter\n" + printf " • no dot (.) at the end\n\n" + + while :; do + read -e SHORT_DESC + if [ -z "$SHORT_DESC" ]; then + printf "${RED}❌ Short description can not be empty.${RESET}\n" + else + break + fi + done + + # Description section + printf "\n${BLUE}>>> Long description (optional)?${RESET}\n" + printf "The body should include the motivation for the change and contrast this with previous behavior.\n\n" + read -e LONG_DESC + + # Breaking changes section + printf "\n${BLUE}>>> Breaking changes (optional)?${RESET}\n" + printf "note the reason for a breaking change within the commit.\n\n" + read -e BREAKING_CHANGES + + # Closed issues section + printf "\n${BLUE}>>> Closed issues (optional)?${RESET}\n" + printf "The syntax for closing keywords depends on whether the issue is in the same repository as the pull request.\n" + printf " • Issue in the same repository -> Closes #10\n" + printf " • Issue in a different repository -> Fixes octo-org/octo-repo#100\n" + printf " • Multiple issues -> Resolves #10, resolves #123, resolves octo-org/octo-repo#100\n\n" + read -e CLOSED_ISSUES + + # Result section + if [ ! -z "$SCOPE" ]; then + SCOPE="(${SCOPE})" + fi + + if [ ! -z "$BREAKING_CHANGES" ]; then + BREAKING_CHANGES="BREAKING CHANGE: ${BREAKING_CHANGES}" + fi + + printf "\n ${GREEN}${TYPE}${SCOPE}: ${SHORT_DESC} + ${LONG_DESC} + ${BREAKING_CHANGES} + ${CLOSED_ISSUES}${RESET}\n\n" + + # Git commit + RESULT_CODE=$? + if [ "$RESULT_CODE" = 0 ]; then + git commit -m "${TYPE}${SCOPE}: ${SHORT_DESC} +${LONG_DESC} +${BREAKING_CHANGES} +${CLOSED_ISSUES}" + else + printf "\n${RED}❌ An error occurred. Please try again.${RESET}\n" + fi +} + +alias gct='git_commit_template' From cb81849cfe518da19e10992a705b3de6ce8c63ca Mon Sep 17 00:00:00 2001 From: ghasem shirdel Date: Fri, 7 Jan 2022 13:13:58 +0330 Subject: [PATCH 02/13] doc(REDAME.md): create documentation --- plugins/git-commit-template/README.md | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 plugins/git-commit-template/README.md diff --git a/plugins/git-commit-template/README.md b/plugins/git-commit-template/README.md new file mode 100644 index 000000000..766ef6ab1 --- /dev/null +++ b/plugins/git-commit-template/README.md @@ -0,0 +1,29 @@ +# git-commit-template plugin + +To better write git commit messages, we can use template to specify the desired description and type of message. + +To use it, add `git-commit-template` to the plugins array in your zshrc file: + +```zsh +plugins=(... git-commit-template) +``` + +## Learn This Articles + +- #### [How to Write Better Git Commit Messages](https://www.freecodecamp.org/news/how-to-write-better-git-commit-messages/) + +- #### [Epower Git Template](https://github.com/epowerng/git-template) + +## Usage + +All you have to do is call the `gct` command and fill in the items that are not optional at each step to prepare the message format. + +![gct](https://raw.githubusercontent.com/ghasemdev/git-commit-template/master/images/1.png) + +![result](https://raw.githubusercontent.com/ghasemdev/git-commit-template/master/images/2.png) + +With the `git log` command, we can see the message that we committed. + +![git log](https://raw.githubusercontent.com/ghasemdev/git-commit-template/master/images/3.png) + +### Tanks For Supporting [📌 Source](https://github.com/ghasemdev/git-commit-template) From 06059baa1f053e8c2345a54afd0dcd81da89c7d9 Mon Sep 17 00:00:00 2001 From: ghasem shirdel Date: Fri, 7 Jan 2022 14:12:50 +0330 Subject: [PATCH 03/13] style: break long lines --- plugins/git-commit-template/README.md | 9 +- .../git-commit-template.plugin.zsh | 89 +++++++++++-------- 2 files changed, 57 insertions(+), 41 deletions(-) diff --git a/plugins/git-commit-template/README.md b/plugins/git-commit-template/README.md index 766ef6ab1..d393000f3 100644 --- a/plugins/git-commit-template/README.md +++ b/plugins/git-commit-template/README.md @@ -1,8 +1,10 @@ # git-commit-template plugin -To better write git commit messages, we can use template to specify the desired description and type of message. +To better write git commit messages, we can use template to specify the +desired description and type of message. -To use it, add `git-commit-template` to the plugins array in your zshrc file: +To use it, add `git-commit-template` to the plugins array in your zshrc +file: ```zsh plugins=(... git-commit-template) @@ -16,7 +18,8 @@ plugins=(... git-commit-template) ## Usage -All you have to do is call the `gct` command and fill in the items that are not optional at each step to prepare the message format. +All you have to do is call the `gct` command and fill in the items that +are not optional at each step to prepare the message format. ![gct](https://raw.githubusercontent.com/ghasemdev/git-commit-template/master/images/1.png) diff --git a/plugins/git-commit-template/git-commit-template.plugin.zsh b/plugins/git-commit-template/git-commit-template.plugin.zsh index 3ddf033d9..9c6856f61 100644 --- a/plugins/git-commit-template/git-commit-template.plugin.zsh +++ b/plugins/git-commit-template/git-commit-template.plugin.zsh @@ -1,4 +1,4 @@ -function git_commit_template() { +git_commit_template() { # Check in this directory git exist if [ ! -d .git ]; then exit 1 @@ -12,7 +12,9 @@ function git_commit_template() { RESET="\033[0m" # Valid types - TYPES=("feat" "fix" "docs" "style" "refactor" "pref" "test" "build" "ci" "chore" "revert") + TYPES=("feat" "fix" "docs" "style" "refactor" + "pref" "test" "build" "ci" "chore" "revert") + NUMBERS=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11") # Type section @@ -21,24 +23,30 @@ function git_commit_template() { printf "${CYAN}1. feat${RESET} - A new feature.\n" printf "${CYAN}2. fix${RESET} - A bug fix.\n" printf "${CYAN}3. docs${RESET} - Documentation only changes.\n" - printf "${CYAN}4. style${RESET} - Changes that do notaffect the meaning of the code (white-space, formatting, missing semi-colons, etc).\n" - printf "${CYAN}5. refactor${RESET} - A Code change that neither fixes a bug nor adds a feature.\n" + printf "${CYAN}4. style${RESET} - Changes that do notaffect the meaning of \ +the code (white-space, formatting, missing semi-colons, etc).\n" + printf "${CYAN}5. refactor${RESET} - A Code change that neither fixes a bug \ +nor adds a feature.\n" printf "${CYAN}6. pref${RESET} - A code change that improves performance.\n" - printf "${CYAN}7. test${RESET} - Adding missing tests or correcting existing tests.\n" - printf "${CYAN}8. build${RESET} - Changes that effect the build system or external dependencies (example scopes: glup, broccoli, npm).\n" - printf "${CYAN}9. ci${RESET} - Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs).\n" - printf "${CYAN}10. chore${RESET} - Other changes that don't modify src or test files.\n" + printf "${CYAN}7. test${RESET} - Adding missing tests or correcting existing \ +tests.\n" + printf "${CYAN}8. build${RESET} - Changes that effect the build system or \ +external dependencies (example scopes: glup, broccoli, npm).\n" + printf "${CYAN}9. ci${RESET} - Changes to our CI configuration files and \ +scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs).\n" + printf "${CYAN}10. chore${RESET} - Other changes that don't modify src or test \ +files.\n" printf "${CYAN}11. revert${RESET} - Reverts a previous commit.\n\n" while :; do - read -e TYPE + read -e type_var # To lower case - TYPE=${TYPE,,} + type_var=${type_var,,} # When input type is valid loop break - if [[ " ${NUMBERS[*]} " =~ " ${TYPE} " ]]; then - TYPE="${TYPES[TYPE - 1]}" + if [[ " ${NUMBERS[*]} " =~ " ${type_var} " ]]; then + type_var="${TYPES[type_var - 1]}" break - elif [[ " ${TYPES[*]} " =~ " ${TYPE} " ]]; then + elif [[ " ${TYPES[*]} " =~ " ${type_var} " ]]; then break else printf "${RED}❌ Please select a valid type.${RESET}\n" @@ -47,19 +55,21 @@ function git_commit_template() { # Scppe section printf "\n${BLUE}>>> Scope of this change (optional)?${RESET}\n" - printf "The scope could be anything specifying place of the commit change e.g a file name, function name, class name, component name etc.\n\n" - read -e SCOPE + printf "The scope could be anything specifying place of the commit change e.g \ +a file name, function name, class name, component name etc.\n\n" + read -e scope # Subject section printf "\n${BLUE}>>> Short description?${RESET}\n" printf "The short description contains succinct description of the change:\n" - printf ' • use the imperative, present tense: "change" not "changed" nor "changes"\n' + printf " • use the imperative, present tense: 'change' not 'changed' nor \ +'changes'\n" printf " • don't capitalize first letter\n" printf " • no dot (.) at the end\n\n" while :; do - read -e SHORT_DESC - if [ -z "$SHORT_DESC" ]; then + read -e short_desc + if [ -z "$short_desc" ]; then printf "${RED}❌ Short description can not be empty.${RESET}\n" else break @@ -68,43 +78,46 @@ function git_commit_template() { # Description section printf "\n${BLUE}>>> Long description (optional)?${RESET}\n" - printf "The body should include the motivation for the change and contrast this with previous behavior.\n\n" - read -e LONG_DESC + printf "The body should include the motivation for the change and contrast \ +this with previous behavior.\n\n" + read -e long_desc # Breaking changes section printf "\n${BLUE}>>> Breaking changes (optional)?${RESET}\n" printf "note the reason for a breaking change within the commit.\n\n" - read -e BREAKING_CHANGES + read -e breaking_changes # Closed issues section printf "\n${BLUE}>>> Closed issues (optional)?${RESET}\n" - printf "The syntax for closing keywords depends on whether the issue is in the same repository as the pull request.\n" + printf "The syntax for closing keywords depends on whether the issue is in \ +the same repository as the pull request.\n" printf " • Issue in the same repository -> Closes #10\n" printf " • Issue in a different repository -> Fixes octo-org/octo-repo#100\n" - printf " • Multiple issues -> Resolves #10, resolves #123, resolves octo-org/octo-repo#100\n\n" - read -e CLOSED_ISSUES + printf " • Multiple issues -> Resolves #10, resolves #123, resolves \ +octo-org/octo-repo#100\n\n" + read -e closed_issues # Result section - if [ ! -z "$SCOPE" ]; then - SCOPE="(${SCOPE})" + if [ ! -z "$scope" ]; then + scope="(${scope})" fi - if [ ! -z "$BREAKING_CHANGES" ]; then - BREAKING_CHANGES="BREAKING CHANGE: ${BREAKING_CHANGES}" + if [ ! -z "$breaking_changes" ]; then + breaking_changes="BREAKING CHANGE: ${breaking_changes}" fi - printf "\n ${GREEN}${TYPE}${SCOPE}: ${SHORT_DESC} - ${LONG_DESC} - ${BREAKING_CHANGES} - ${CLOSED_ISSUES}${RESET}\n\n" + printf "\n ${GREEN}${type_var}${scope}: ${short_desc} + ${long_desc} + ${breaking_changes} + ${closed_issues}${RESET}\n\n" # Git commit - RESULT_CODE=$? - if [ "$RESULT_CODE" = 0 ]; then - git commit -m "${TYPE}${SCOPE}: ${SHORT_DESC} -${LONG_DESC} -${BREAKING_CHANGES} -${CLOSED_ISSUES}" + result_code=$? + if [ "$result_code" = 0 ]; then + git commit -m "${type_var}${scope}: ${short_desc} +${long_desc} +${breaking_changes} +${closed_issues}" else printf "\n${RED}❌ An error occurred. Please try again.${RESET}\n" fi From 51f6a87435681ea4bedad0816f78bc5b07d135f8 Mon Sep 17 00:00:00 2001 From: ghasem shirdel Date: Fri, 7 Jan 2022 14:20:00 +0330 Subject: [PATCH 04/13] fix(git-commit-template): fix error details exit 1 when a git commit error occurs. --- plugins/git-commit-template/git-commit-template.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/git-commit-template/git-commit-template.plugin.zsh b/plugins/git-commit-template/git-commit-template.plugin.zsh index 9c6856f61..06f7bd829 100644 --- a/plugins/git-commit-template/git-commit-template.plugin.zsh +++ b/plugins/git-commit-template/git-commit-template.plugin.zsh @@ -120,6 +120,7 @@ ${breaking_changes} ${closed_issues}" else printf "\n${RED}❌ An error occurred. Please try again.${RESET}\n" + exit 1 fi } From 0e1841b6d608f8fdaac8920ace878f5a0fd355a1 Mon Sep 17 00:00:00 2001 From: ghasem shirdel Date: Mon, 10 Jan 2022 09:22:24 +0330 Subject: [PATCH 05/13] fix(template.sh): fix decription for non git directory When we are in a non-git folder, if we use the 'gct' command, we will also see the reason for the error. --- plugins/git-commit-template/git-commit-template.plugin.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/git-commit-template/git-commit-template.plugin.zsh b/plugins/git-commit-template/git-commit-template.plugin.zsh index 06f7bd829..6baf38e92 100644 --- a/plugins/git-commit-template/git-commit-template.plugin.zsh +++ b/plugins/git-commit-template/git-commit-template.plugin.zsh @@ -1,6 +1,7 @@ git_commit_template() { # Check in this directory git exist if [ ! -d .git ]; then + echo "fatal: not a git repository (or any of the parent directories): .git" exit 1 fi @@ -107,6 +108,7 @@ octo-org/octo-repo#100\n\n" fi printf "\n ${GREEN}${type_var}${scope}: ${short_desc} + ${long_desc} ${breaking_changes} ${closed_issues}${RESET}\n\n" @@ -115,6 +117,7 @@ octo-org/octo-repo#100\n\n" result_code=$? if [ "$result_code" = 0 ]; then git commit -m "${type_var}${scope}: ${short_desc} + ${long_desc} ${breaking_changes} ${closed_issues}" From 882c1d52ce6637cfd4ef58d6a275775f912bd92d Mon Sep 17 00:00:00 2001 From: ghasem shirdel Date: Mon, 10 Jan 2022 09:25:00 +0330 Subject: [PATCH 06/13] feat(template.sh): add limit counter for short desc Limit character for short descriptions is 50. --- plugins/git-commit-template/git-commit-template.plugin.zsh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/git-commit-template/git-commit-template.plugin.zsh b/plugins/git-commit-template/git-commit-template.plugin.zsh index 6baf38e92..d4fa3f845 100644 --- a/plugins/git-commit-template/git-commit-template.plugin.zsh +++ b/plugins/git-commit-template/git-commit-template.plugin.zsh @@ -70,8 +70,12 @@ a file name, function name, class name, component name etc.\n\n" while :; do read -e short_desc + limit_counter=${#short_desc} if [ -z "$short_desc" ]; then printf "${RED}❌ Short description can not be empty.${RESET}\n" + elif [[ $limit_counter > 50 ]]; then + printf "${RED}❌ The maximum character for header is 50, Please\ + provide details in long descriptions.${RESET}\n" else break fi From 0c54b565f459996b940cfee9c9cfc2f65614bccf Mon Sep 17 00:00:00 2001 From: Ghasem Shirdel Date: Mon, 17 Jan 2022 20:58:50 +0330 Subject: [PATCH 07/13] fix(template.sh): fix limit counter bug --- .../git-commit-template/git-commit-template.plugin.zsh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/plugins/git-commit-template/git-commit-template.plugin.zsh b/plugins/git-commit-template/git-commit-template.plugin.zsh index d4fa3f845..ef224f816 100644 --- a/plugins/git-commit-template/git-commit-template.plugin.zsh +++ b/plugins/git-commit-template/git-commit-template.plugin.zsh @@ -1,9 +1,4 @@ git_commit_template() { - # Check in this directory git exist - if [ ! -d .git ]; then - echo "fatal: not a git repository (or any of the parent directories): .git" - exit 1 - fi # Color formatting RED="\033[0;31m" @@ -70,10 +65,9 @@ a file name, function name, class name, component name etc.\n\n" while :; do read -e short_desc - limit_counter=${#short_desc} if [ -z "$short_desc" ]; then printf "${RED}❌ Short description can not be empty.${RESET}\n" - elif [[ $limit_counter > 50 ]]; then + elif [[ ${#limit_counter} -gt 50 ]]; then printf "${RED}❌ The maximum character for header is 50, Please\ provide details in long descriptions.${RESET}\n" else From 66ffeacafd3daf67b4eb442ba75c80b949741cfc Mon Sep 17 00:00:00 2001 From: Ghasem Shirdel Date: Tue, 18 Jan 2022 12:05:19 +0330 Subject: [PATCH 08/13] 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=$? From b1ee81f4f0f3f5803dc848a13c40633bcfc65293 Mon Sep 17 00:00:00 2001 From: Ghasem Shirdel Date: Sun, 23 Jan 2022 10:12:44 +0330 Subject: [PATCH 09/13] 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 From 299323aff2f9cc4097b94a6c49a845b1f7f7a9a7 Mon Sep 17 00:00:00 2001 From: Ghasem Shirdel Date: Sun, 23 Jan 2022 10:13:57 +0330 Subject: [PATCH 10/13] doc(README.md): update README.md --- plugins/git-commit-template/README.md | 54 ++++++++++++++++++++------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/plugins/git-commit-template/README.md b/plugins/git-commit-template/README.md index d393000f3..43b3a6aa2 100644 --- a/plugins/git-commit-template/README.md +++ b/plugins/git-commit-template/README.md @@ -1,14 +1,10 @@ -# git-commit-template plugin +[![Version](https://shields.io/badge/VERSION-1.2.0-blue?style=for-the-badge)](https://github.com/ghasemdev/git-commit-template/releases/tag/v1.1.0) +[![License Apache-2.0](https://shields.io/badge/LICENSE-APACHE--2.0-orange?style=for-the-badge)](https://opensource.org/licenses/MIT) + +# git-commit-template To better write git commit messages, we can use template to specify the -desired description and type of message. - -To use it, add `git-commit-template` to the plugins array in your zshrc -file: - -```zsh -plugins=(... git-commit-template) -``` +desired description and type of message. This file is prepared for use in zsh. ## Learn This Articles @@ -16,17 +12,49 @@ plugins=(... git-commit-template) - #### [Epower Git Template](https://github.com/epowerng/git-template) +- #### [چگونه یک پیغام گیت با معنا بنویسیم؟](https://virgool.io/@mmdsharifi/how-to-semantic-git-commit-messages-gvmmqatf6acg) + +## Installation + +In the first step, in the home directory (zshrc directory) clone git-commit-template. + +```bash +➜ ~ git clone https://github.com/ghasemdev/git-commit-template.git +``` + +Then we have to run this command to install. + +```bash +➜ ~ chmod +x git-commit-template/installer.sh +➜ ~ git-commit-template/installer.sh +``` + +In the last command we refresh oh-my-zsh source. + +```bash +➜ ~ source ~/.zshrc +``` + ## Usage All you have to do is call the `gct` command and fill in the items that are not optional at each step to prepare the message format. -![gct](https://raw.githubusercontent.com/ghasemdev/git-commit-template/master/images/1.png) +![gct](images/1.png) -![result](https://raw.githubusercontent.com/ghasemdev/git-commit-template/master/images/2.png) +![result](images/2.png) With the `git log` command, we can see the message that we committed. -![git log](https://raw.githubusercontent.com/ghasemdev/git-commit-template/master/images/3.png) +![git log](images/3.png) -### Tanks For Supporting [📌 Source](https://github.com/ghasemdev/git-commit-template) +### signature + +You can use `-s` or `sign` to add a signature to the gct. + +```bash +➜ gct -s +➜ gct sign +``` + +## Tanks For Supporting 🐯 From 30a451b2134d4c2e6af6dca10fe452afb1a7d280 Mon Sep 17 00:00:00 2001 From: Ghasem Shirdel Date: Sun, 23 Jan 2022 10:23:54 +0330 Subject: [PATCH 11/13] doc(README.md): update README.md --- plugins/git-commit-template/README.md | 43 +++++++-------------------- 1 file changed, 11 insertions(+), 32 deletions(-) diff --git a/plugins/git-commit-template/README.md b/plugins/git-commit-template/README.md index 43b3a6aa2..a3ea263f7 100644 --- a/plugins/git-commit-template/README.md +++ b/plugins/git-commit-template/README.md @@ -1,10 +1,12 @@ -[![Version](https://shields.io/badge/VERSION-1.2.0-blue?style=for-the-badge)](https://github.com/ghasemdev/git-commit-template/releases/tag/v1.1.0) -[![License Apache-2.0](https://shields.io/badge/LICENSE-APACHE--2.0-orange?style=for-the-badge)](https://opensource.org/licenses/MIT) +# git-commit-template plugin -# git-commit-template +To better write git commit messages, we can use template to specify the desired description and type of message. -To better write git commit messages, we can use template to specify the -desired description and type of message. This file is prepared for use in zsh. +To use it, add `git-commit-template` to the plugins array in your zshrc file: + +```bash +plugins=(... git-commit-template) +``` ## Learn This Articles @@ -12,41 +14,18 @@ desired description and type of message. This file is prepared for use in zsh. - #### [Epower Git Template](https://github.com/epowerng/git-template) -- #### [چگونه یک پیغام گیت با معنا بنویسیم؟](https://virgool.io/@mmdsharifi/how-to-semantic-git-commit-messages-gvmmqatf6acg) - -## Installation - -In the first step, in the home directory (zshrc directory) clone git-commit-template. - -```bash -➜ ~ git clone https://github.com/ghasemdev/git-commit-template.git -``` - -Then we have to run this command to install. - -```bash -➜ ~ chmod +x git-commit-template/installer.sh -➜ ~ git-commit-template/installer.sh -``` - -In the last command we refresh oh-my-zsh source. - -```bash -➜ ~ source ~/.zshrc -``` - ## Usage All you have to do is call the `gct` command and fill in the items that are not optional at each step to prepare the message format. -![gct](images/1.png) +![gct](https://raw.githubusercontent.com/ghasemdev/git-commit-template/master/images/1.png) -![result](images/2.png) +![result](https://raw.githubusercontent.com/ghasemdev/git-commit-template/master/images/2.png) With the `git log` command, we can see the message that we committed. -![git log](images/3.png) +![git log](https://raw.githubusercontent.com/ghasemdev/git-commit-template/master/images/3.png) ### signature @@ -57,4 +36,4 @@ You can use `-s` or `sign` to add a signature to the gct. ➜ gct sign ``` -## Tanks For Supporting 🐯 +## Tanks For Supporting 📌 [Source](https://github.com/ghasemdev/git-commit-template) From 80ec398a5c2c81e97182f6fde9e656373d272125 Mon Sep 17 00:00:00 2001 From: Ghasem Shirdel Date: Mon, 24 Jan 2022 11:43:05 +0330 Subject: [PATCH 12/13] refactor(template.sh): some refactoring --- .../git-commit-template.plugin.zsh | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/plugins/git-commit-template/git-commit-template.plugin.zsh b/plugins/git-commit-template/git-commit-template.plugin.zsh index 07cbe57a1..95fef2dae 100644 --- a/plugins/git-commit-template/git-commit-template.plugin.zsh +++ b/plugins/git-commit-template/git-commit-template.plugin.zsh @@ -1,3 +1,10 @@ +# Color formatting +RED="\033[0;31m" +GREEN="\033[0;32m" +BLUE="\033[1;34m" +CYAN="\033[0;36m" +RESET="\033[0m" + git_commit_template() { # Check the current folder is a git repository @@ -6,13 +13,6 @@ git_commit_template() { exit 1 fi - # Color formatting - RED="\033[0;31m" - GREEN="\033[0;32m" - BLUE="\033[1;34m" - CYAN="\033[0;36m" - RESET="\033[0m" - # Valid types TYPES=("feat" "fix" "docs" "style" "refactor" "pref" "test" "build" "ci" "chore" "revert") @@ -118,11 +118,11 @@ octo-org/octo-repo#100\n\n" fi if [ ! -z "$breaking_changes" ]; then - massage="${massage} BREAKING CHANGE: ${breaking_changes}\n" + massage="${massage}\n BREAKING CHANGE: ${breaking_changes}\n" fi if [ ! -z "$closed_issues" ]; then - massage="${massage} ${closed_issues}\n" + massage="${massage}\n ${closed_issues}\n" fi printf "${massage}\n${RESET}" @@ -133,13 +133,17 @@ octo-org/octo-repo#100\n\n" 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 From 304a75c652181bf83f6799313ad0b0533e1d4d41 Mon Sep 17 00:00:00 2001 From: Ghasem Shirdel Date: Fri, 11 Feb 2022 10:22:50 +0330 Subject: [PATCH 13/13] fix(git-commit-template): modify the keyword perf --- plugins/git-commit-template/git-commit-template.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/git-commit-template/git-commit-template.plugin.zsh b/plugins/git-commit-template/git-commit-template.plugin.zsh index 95fef2dae..95fe73ead 100644 --- a/plugins/git-commit-template/git-commit-template.plugin.zsh +++ b/plugins/git-commit-template/git-commit-template.plugin.zsh @@ -15,7 +15,7 @@ git_commit_template() { # Valid types TYPES=("feat" "fix" "docs" "style" "refactor" - "pref" "test" "build" "ci" "chore" "revert") + "perf" "test" "build" "ci" "chore" "revert") NUMBERS=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11") @@ -29,7 +29,7 @@ git_commit_template() { the code (white-space, formatting, missing semi-colons, etc).\n" printf "${CYAN}5. refactor${RESET} - A Code change that neither fixes a bug \ nor adds a feature.\n" - printf "${CYAN}6. pref${RESET} - A code change that improves performance.\n" + printf "${CYAN}6. perf${RESET} - A code change that improves performance.\n" printf "${CYAN}7. test${RESET} - Adding missing tests or correcting existing \ tests.\n" printf "${CYAN}8. build${RESET} - Changes that effect the build system or \