Skip to content

Commit

Permalink
chore: git aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
fisenkodv authored Nov 30, 2022
1 parent 3449946 commit 3e58361
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 51 deletions.
52 changes: 1 addition & 51 deletions bootstrap/aliases/git.aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <type> -s <scope> -m <message>"
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"
53 changes: 53 additions & 0 deletions bootstrap/functions/git.functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

function conventional_commit_usage() {
echo "Makes a conventional commit."
echo
echo "Syntax: $0 -t <type> -s <scope> -m <message>"
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"
}

0 comments on commit 3e58361

Please # to comment.