-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit.sh
More file actions
executable file
·30 lines (26 loc) · 906 Bytes
/
commit.sh
File metadata and controls
executable file
·30 lines (26 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# usage:
# commit.sh summary of this change, none of this needs to be quoted
# OR
# commit.sh
# and you will be prompted for the summary of this change (using `gum`)
# NOTE: This assumes your branch is in the format your-name/ticket-123/some-description
# If this is not the case, no ticket number will be prepended to the commit message
# you can also set this as a git alias with:
# git config --global alias.c '!bash /path/to/commit.sh'
# which will allow you to use it like `git c summary of change`
if [ $# -eq 0 ]; then
msg=$(gum input --placeholder 'Summary of this change')
else
msg="$*"
fi
branch="$(git rev-parse --abbrev-ref HEAD)"
if [[ $branch =~ .*/.*/.* ]]; then
ticket="$(echo "$branch" | cut -d '/' -f 2 | tr '[:lower:]' '[:upper:]')"
if [ "$ticket" != "CHORE" ]; then
ticket="[$ticket] "
else
ticket=""
fi
fi
gt cm -m "$ticket$msg"