-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathlog
executable file
·180 lines (151 loc) · 4.2 KB
/
log
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
#!/bin/bash
#############################################################################
# Copyright (c) 2004-2006,2008,2009 Novell, Inc.
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, contact Novell, Inc.
#
# To contact Novell about this file by physical or electronic mail,
# you may find current contact information at www.novell.com
#############################################################################
if test -x "${0}2" -a ! -e kernel-source.changes; then
# hand over to scripts/log2
exec "${0}2" "$@"
fi
# Construct a changes entry and commit log from a patch.
. ${0%/*}/wd-functions.sh
if ! $using_git; then
echo "ERROR: not in a git working directory."
exit 1
fi
scripts/check-cvs-add || exit 1
CHANGES=kernel-source.changes
trap 'rm -rf "$tmpdir"' EXIT
tmpdir=$(mktemp -d /tmp/${0##*/}.XXXXXX)
message=$tmpdir/message
log_entry() {
local entry=$1
echo "$entry" \
| fmt --width 65 \
| sed -e '1s/^/- /' -e '2,$s/^/ /' \
>> $message
}
patch_meta() {
local patch=$1
subject=$(formail -c -x Subject < "$patch" \
| sed -e 's, *\[[#/ A-Za-z0-9-]*\],,')
subject=${subject## }
subject=${subject%.}
set -- $(formail -c -x References -x Reference < "$patch")
references="$*"
}
patch_log_entry() {
local patch=$1 subject references old_subj old_ref old_patch="$tmpdir/old"
git show "HEAD:$patch" >"$old_patch" 2>/dev/null
patch_meta "$old_patch"
old_subj="$subject"
old_ref="$references"
patch_meta "$patch"
local msg
if test -z "$subject" -o "$subject" != "$old_subj"; then
msg="$subject${references:+ ($references)}"
elif test "$references" != "$old_ref"; then
if test -n "$references"; then
msg="Update references ($references)"
fi
else
msg="Refresh"
fi
log_entry "$patch: $msg${msg:+.}"
}
for file in "$@" $(scripts/cvs-touched-files); do
[ "${file:(-8)}" = ".changes" ] && continue
files[${#files[@]}]=$file
done
if [ ${#files[@]} -eq 0 ]; then
echo "No modified files" >&2
exit 1
fi
for file in "${files[@]}"; do
if [ "${file:0:1}" = - ]; then
log_entry "${file:1}: Delete."
else
case "$file" in
config/*)
if [ -z "$configs_updated" ]; then
log_entry "Update config files."
configs_updated=1
fi
;;
patches.*)
patch_log_entry "$file"
;;
kabi/*/symvers-* | kabi/*/symtypes-* | kabi/*/symsets-* )
if [ -z "$symvers_updated" ]; then
log_entry "Update reference module symbol versions."
symvers_updated=1
fi
;;
series.conf)
# don't log changes in there
;;
*)
log_entry "$file: "
;;
esac
fi
done
if [ ! -s $message ]; then
echo "- " >> $message
fi
if [ -z "$VC" ]; then
VC=vc
for search in $HOME/bin /work/src/bin scripts; do
if [ -x $search/$VC ]; then
VC=$search/$VC
break
fi
done
fi
if $VC $CHANGES $message; then
entry=$(sed -ne '1,2d' -e '/^--*$/!p' -e '/^--*$/q' $CHANGES)
entry=${entry##$'\n'}
entry=${entry%%$'\n'}
echo "$entry" > $message
while :; do
echo
sed -e 's:^:| :' $message
echo
echo -n "Commit with the above changelog entry: ([y]es), [n]o, [e]dit? "
read yesno && \
case "$yesno" in
"" | [yY] | yes)
git add $CHANGES
# XXX don't commit -a?
git commit -a -F $message || exit
# branch= "master"
# case "$branch" in
# master | preload | slert* | SL*_BRANCH | openSUSE-??.? | \
# SLE?? | SLE??-SP? )
echo "after testing your changes, run"
echo " git push..."
# esac
break ;;
[nN] | no)
break ;;
[eE] | edit)
${EDITOR:-vi} $message
;;
esac
done
fi