From 3e58361eac557d18c668e649e8643a5cd16705c4 Mon Sep 17 00:00:00 2001 From: Dmitry Fisenko Date: Wed, 30 Nov 2022 16:23:58 -0500 Subject: [PATCH] chore: git aliases --- bootstrap/aliases/git.aliases.sh | 52 +-------------------------- bootstrap/functions/git.functions.sh | 53 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 51 deletions(-) create mode 100644 bootstrap/functions/git.functions.sh diff --git a/bootstrap/aliases/git.aliases.sh b/bootstrap/aliases/git.aliases.sh index 9d3ede5..1fcda94 100644 --- a/bootstrap/aliases/git.aliases.sh +++ b/bootstrap/aliases/git.aliases.sh @@ -29,54 +29,4 @@ alias guns="git reset HEAD --" alias gstl="git stash list --pretty=format:'%C(blue)%gd%C(reset): %<(100,trunc)%s %C(green)(%cr)%C(reset)'" -function conventional_commit_usage() { - echo "Makes a conventional commit." - echo - echo "Syntax: $0 -t -s -m " - echo "options:" - echo "-t|--type Type of the change, e.g. fix, chore, feat, docs, style, refactor, test, ci, build." - echo "-b|--break Flag whether the commit has breaking changes or not." - echo "-s|--scope Scope of the change, e.g. api, ui, docs." - echo "-m|--message Message describes the change." - echo "-h|--help Get this help." - echo -} - -function conventional_commit() { - help=0 - type= - breaking_change=0 - scope= - message= - - while getopts "t:bs:m:h" opt; do - case "${opt}" in - t) type="$OPTARG" ;; - b) breaking_change=1 ;; - s) scope="$OPTARG" ;; - m) message="$OPTARG" ;; - h) help=1 ;; - esac - done - - if [ $help -eq 1 ]; then - conventional_commit_usage - fi - - commit_message="" - if [ ! -z $type ]; then - commit_message+="$type" - - if [ ! -z $scope ]; then - commit_message+="($scope)" - fi - if [ $breaking_change -eq 1 ]; then - commit_message+='!' - fi - commit_message+=": " - fi - commit_message+="$message" - - git add --all - git commit -am "$commit_message" -} +alias ccmt="conventional_commit" diff --git a/bootstrap/functions/git.functions.sh b/bootstrap/functions/git.functions.sh new file mode 100644 index 0000000..a7b7607 --- /dev/null +++ b/bootstrap/functions/git.functions.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +function conventional_commit_usage() { + echo "Makes a conventional commit." + echo + echo "Syntax: $0 -t -s -m " + echo "options:" + echo "-t|--type Type of the change, e.g. fix, chore, feat, docs, style, refactor, test, ci, build." + echo "-b|--break Flag whether the commit has breaking changes or not." + echo "-s|--scope Scope of the change, e.g. api, ui, docs." + echo "-m|--message Message describes the change." + echo "-h|--help Get this help." + echo +} + +function conventional_commit() { + help=0 + type= + breaking_change=0 + scope= + message= + + while getopts "t:bs:m:h" opt; do + case "${opt}" in + t) type="$OPTARG" ;; + b) breaking_change=1 ;; + s) scope="$OPTARG" ;; + m) message="$OPTARG" ;; + h) help=1 ;; + esac + done + + if [ $help -eq 1 ]; then + conventional_commit_usage + fi + + commit_message="" + if [ ! -z $type ]; then + commit_message+="$type" + + if [ ! -z $scope ]; then + commit_message+="($scope)" + fi + if [ $breaking_change -eq 1 ]; then + commit_message+='!' + fi + commit_message+=": " + fi + commit_message+="$message" + + git add --all + git commit -am "$commit_message" +}