-
Notifications
You must be signed in to change notification settings - Fork 1
/
gpt
executable file
·103 lines (97 loc) · 2.4 KB
/
gpt
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# Programmer:Harold.Duan
# Date:20200107
# Reason:Installing giprote scripts.
version_info() {
# sh $(cd $(dirname $0); pwd -P)/copyright.sh "giprote"
sh $giprote_dir/scripts/copyright.sh "giprote"
cd $giprote_dir
git branch | grep -E "[0-9].[0-9].[0-9]"
}
help_info() {
echo "
Usage:
gpt -h|--help Show help message
gpt -v|--version Print out the installed version of gpt
gpt init Init repo
--commit Init repo commit
--local-branch Init repo local branch
gpt gen Generate source
--prof Generate source project folders
--readme Generate source README.md
--ignore Generate source .gitignore
gpt -u|--upgrade Upgrade to the latest version.
Example:
gpt init --commit Init current repo commit
gpt init --local-branch Init current repo local branch
gpt gen --prof Generate source project folders
gpt gen --readme Generate source README.md
Note:
If you have some problems,you can pull iusses to this repo:
https://github.com/EDITeam/giprote.commandline.git
"
}
upgrade() {
cd $giprote_dir
echo "Upgrading..."
remotes=$(git branch -r | grep -v "\->" | grep -E "[0-9].[0-9].[0-9]")
# echo $remotes
for remote in $remotes
do
# echo "$remote"
git branch --track "${remote#origin/}" "$remote"
max="0.0.0"
temp="${remote#origin/}"
# echo "$temp"
if [ $temp \> $max ];then
max=$temp
# echo "$max"
fi
done
git fetch --all
git pull --all
git checkout $max
git branch | grep -E "[0-9].[0-9].[0-9]"
}
# echo $0
# echo $1
# echo $2
# echo "$@"
cur_path=$PWD
if [[ -z "$@}" ]]
then
# echo `giprote -h`
version_info
help_info
else
case "$@" in
"-v"|"--version")
version_info
;;
"-h"|"--help")
help_info
;;
"init --commit")
#echo $PWD
sh $giprote_dir/scripts/initicomit.sh
;;
"init --local-branch")
sh $giprote_dir/scripts/initilobra.sh
;;
"gen --prof")
sh $giprote_dir/scripts/genprof.sh
;;
"gen --readme")
sh $giprote_dir/scripts/generademe.sh
;;
"gen --ignore")
sh $giprote_dir/scripts/genignore.sh
;;
"-u"|"--upgrade")
upgrade
;;
*)
help_info
esac
fi
cd $cur_path