forked from SHYFEM-model/shyfem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-tag
executable file
·221 lines (173 loc) · 4.36 KB
/
git-tag
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/sh
#
#------------------------------------------------------------------------
#
# Copyright (C) 1985-2018 Georg Umgiesser
#
# This file is part of SHYFEM.
#
#------------------------------------------------------------------------
#
# shell for tagging git modules in a consistent way
#########################################################
FEMDIR=${FEMDIR:-$HOME/shyfem}
export FEMDIR
version_file="VERSION"
commit_file="COMMIT"
#########################################################
ok()
{
if [ -z "$1" ]; then
question="Is this ok (y/N) : "
else
question=$1
fi
echo
echo -n "$question"
read answer
if [ x.$answer = x."y" ]; then
:
else
exit 0
fi
}
date2num()
{
# echo $1 | sed 's/\(.*\)-\(.*\)-\(.*\)/\3\2\1/'
echo $1 | sed 's/\(.*\)-\(.*\)-\(.*\)/\3\2\1/'
}
editfiles()
{
lastline=`tail -1 $version_file`
echo
echo "You can enter other files to edit before tagging."
echo "This may be used for logging the new version."
if [ -n "$lastline" ]; then
echo "Recommended files: $lastline"
fi
echo
while :
do
echo -n "Enter file name to edit ( <CR> to end ) : "
read file
if [ -n "$file" ]; then
vi $file
else
break
fi
done
}
Usage()
{
echo ""
echo "Usage: git-tag version"
echo ""
echo " (example: git-tag 6.1.7 or git-tag 6.1.7a)"
echo ""
if [ $# -ne 1 ]; then
echo "Actual version : "
echo " Version : $2"
echo " Date : $3"
echo " Tag : $4"
echo ""
fi
}
AddCommitMessage()
{
message="New version $newvers"
echo "============================================================" > log.tmp
echo "" >> log.tmp
date >> log.tmp
echo "" >> log.tmp
echo "$message" >> log.tmp
echo "" >> log.tmp
git diff --cached --stat >> log.tmp
echo "" >> log.tmp
cat log.tmp $commit_file > com.tmp
mv -f com.tmp $commit_file
rm -f log.tmp
}
#########################################################
tmpfile=tmp0.tmp
tmpfile1=tmp1.tmp
tmpfile2=tmp2.tmp
#########################################################
cd $FEMDIR
if [ ! -f $version_file ]; then
echo "No file $version_file... maybe in wrong directory"
exit 2
#echo "Creating file $version_file ..."
#touch $version_file
else
firstline=`head -1 $version_file | sed 's/ \{1,\}/ /g'`
fi
if [ $# -ne 1 ]; then
Usage $firstline
git tag
Usage $firstline
exit 1
else
newvers=$1
newvers=`echo $newvers | sed 's/^v//'`
newvers=`echo $newvers | sed 's/^VERS_//'`
fi
#########################################################
v=`echo $newvers | sed 's/\./_/g'`
newtag=VERS_$v
newdate=`date +"%d-%m-%Y"`
actvers=`echo $firstline | cut -d" " -f2`
actdate=`echo $firstline | cut -d" " -f3`
acttag=`echo $firstline | cut -d" " -f4`
comparedate=`date2num $actdate`
#########################################################
echo
echo "Actual version :"
echo $actvers " " $actdate
echo
echo "New version :"
echo $newvers " " $newdate
echo
git branch
git status
ok
#########################################################
editfiles
#########################################################
echo
echo "Checking revision log ..."
echo
files=`find . -name "*.[cfFh]"`
revisionlog.sh -after $comparedate $files > $tmpfile
if [ -f $version_file ]; then
revisionlog_adjust.pl $tmpfile $version_file > $tmpfile2
fi
cat $tmpfile2
ok
#########################################################
exec 4<&1 # save original stdout
exec > $tmpfile1
echo "version $newvers $newdate $newtag"
echo
echo -n "=========================================================="
echo " $newdate - $newvers"
echo
cat $tmpfile2
echo
echo "=========================================================="
echo
cat $version_file
exec 1<&4 # restore original stdout
vi $tmpfile1
#########################################################
echo ""
echo "new version: $newvers"
echo "new tag : $newtag"
ok "Shall I tag now ? (y/N) : "
AddCommitMessage
cp $tmpfile1 $version_file #maybe invert these two lines - done
git add -u
git commit -m "New version $newvers" --no-verify
#touch $version_file
git tag $newtag
rm -f $tmpfile $tmpfile1 $tmpfile2
#########################################################