File tree 3 files changed +108
-0
lines changed
3 files changed +108
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
chmod +x ~ /git-commit-template/commit-template.sh
4
4
echo alias gct=~ /git-commit-template/commit-template.sh > ~/git-commit-template/zsh_gct
5
+ echo alias gtt=~ /git-commit-template/tag-template.sh > ~/git-commit-template/zsh_gct
5
6
echo source ~ /git-commit-template/zsh_gct >> .zshrc
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Check the current folder is a git repository
4
+ $( git -C $PWD rev-parse)
5
+ if [[ $? != 0 ]]; then
6
+ exit 1
7
+ fi
8
+
9
+ # Color formatting
10
+ RED=" \033[0;31m"
11
+ GREEN=" \033[0;32m"
12
+ BLUE=" \033[1;34m"
13
+ CYAN=" \033[0;36m"
14
+ RESET=" \033[0m"
15
+
16
+ REGEX_VERSION=" ^[0-9]*\.[0-9]*\.[0-9]*$"
17
+
18
+ # Version section
19
+ printf " ${CYAN} >>> Version number (MAJOR.Minor.patch)?${RESET} \n"
20
+ while : ; do
21
+ read -e version
22
+ # When input type is valid loop break
23
+ if [[ $version =~ $REGEX_VERSION ]]; then
24
+ break
25
+ else
26
+ printf " ${RED} ❌ Version format does not correct.${RESET} \n"
27
+ fi
28
+ done
29
+
30
+ # Question section
31
+ COMMENT_FLAG=' '
32
+
33
+ printf " \n${CYAN} >>> Do you want add comment for tag (y/n)? ${RESET} "
34
+ while true ; do
35
+ read -e yn
36
+ case $yn in
37
+ [Yy]* )
38
+ COMMENT_FLAG=' .'
39
+ break
40
+ ;;
41
+ [Nn]* ) break ;;
42
+ esac
43
+ done
44
+
45
+ # Commit message section
46
+ massage=" "
47
+ if [ ! -z " $COMMENT_FLAG " ]; then
48
+
49
+ printf " \n${CYAN} >>> What new 🚀 features have been added ?${RESET} \n"
50
+ read -e features
51
+ if [ ! -z " $features " ]; then
52
+ massage="
53
+ 🚀 Features
54
+ ${features}
55
+ "
56
+ fi
57
+
58
+ printf " \n${CYAN} >>> Which 🐛 bugs have been fixed ?${RESET} \n"
59
+ read -e fixes
60
+ if [ ! -z " $fixes " ]; then
61
+ massage=" ${massage}
62
+ 🐛 Fixes
63
+ ${fixes}
64
+ "
65
+ fi
66
+
67
+ printf " \n${CYAN} >>> What 🧪 tests have been added ?${RESET} \n"
68
+ read -e tests
69
+ if [ ! -z " $tests " ]; then
70
+ massage=" ${massage}
71
+ 🧪 Tests
72
+ ${tests}
73
+ "
74
+ fi
75
+
76
+ printf " \n${CYAN} >>> 💭 Other explanations you want to add.${RESET} \n"
77
+ read -e others
78
+ if [ ! -z " $others " ]; then
79
+ massage=" ${massage}
80
+ 💭 Others
81
+ ${others}
82
+ "
83
+ fi
84
+ fi
85
+
86
+ printf " \n${GREEN} v${version} \n${massage} \n${RESET} "
87
+
88
+ # Git tag
89
+ if [ $? == 0 ]; then
90
+ if [[ $1 == " -s" ]] || [[ $1 == " sign" ]]; then
91
+ if [ ! -z " $COMMENT_FLAG " ]; then
92
+ git tag -s " v$version " -m " $massage "
93
+ else
94
+ git tag -s " v$version "
95
+ fi
96
+ else
97
+ if [ ! -z " $COMMENT_FLAG " ]; then
98
+ git tag " v$version " -m " $massage "
99
+ else
100
+ git tag " v$version "
101
+ fi
102
+ fi
103
+ else
104
+ printf " \n${RED} ❌ An error occurred. Please try again.${RESET} \n"
105
+ exit 1
106
+ fi
Original file line number Diff line number Diff line change 1
1
alias gct=/home/jakode/git-commit-template/commit-template.sh
2
+ alias gtt=/home/jakode/git-commit-template/tag-template.sh
You can’t perform that action at this time.
0 commit comments