]>
git.proxmox.com Git - ceph.git/blob - ceph/src/dpdk/scripts/git-log-fixes.sh
5 # Copyright 2016 6WIND S.A.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
11 # * Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in
15 # the documentation and/or other materials provided with the
17 # * Neither the name of 6WIND S.A. nor the names of its
18 # contributors may be used to endorse or promote products derived
19 # from this software without specific prior written permission.
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 echo "usage: $(basename $0) [-h] <git_range>"
43 Find fixes to backport on previous versions.
44 It looks for the word "fix" in the headline or a tag "Fixes" or "Reverts".
45 The oldest bug origin is printed as well as partially fixed versions.
49 usage_error
() # <message>
56 while getopts h ARG
; do
58 h
) print_help
; exit 0 ;;
59 ?
) print_usage
>&2 ; exit 1 ;;
62 shift $
(($OPTIND - 1))
63 [ $# -ge 1 ] || usage_error
'range argument required'
66 # get major release version of a commit
67 commit_version
() # <hash>
69 tag
=$
(git tag
-l --contains $1 |
head -n1)
70 if [ -z "$tag" ] ; then
71 # before -rc1 tag of release in progress
72 make showversion | cut
-d'.' -f-2
74 echo $tag |
sed 's,^v,,' |
sed 's,-rc.*,,'
78 # get bug origin hashes of a fix
79 origin_filter
() # <hash>
81 git log
--format='%b' -1 $1 |
82 sed -n 's,^ *\([Ff]ixes\|[Rr]everts\): *\([0-9a-f]*\).*,\2,p'
85 # get oldest major release version of bug origins
86 origin_version
() # <origin_hash> ...
90 git rev-parse
-q --verify $1 >&- ||
continue
91 # get version of this bug origin
92 local origver
=$
(commit_version
$origin)
93 local roothashes
=$
(origin_filter
$origin)
94 if [ -n "$roothashes" ] ; then
95 # look chained fix of fix recursively
96 local rootver
="$(origin_version $roothashes)"
97 [ -n "$rootver" ] ||
continue
98 echo "$rootver (partially fixed in $origver)"
102 # filter the oldest origin
103 done |
sort -uV |
head -n1
106 git log
--oneline --reverse $range |
107 while read id headline
; do
108 origins
=$
(origin_filter
$id)
109 [ -n "$origins" ] ||
echo "$headline" |
grep -q fix ||
continue
110 version
=$
(commit_version
$id)
111 if [ -n "$origins" ] ; then
112 origver
="$(origin_version $origins)"
113 [ -n "$origver" ] ||
continue
114 # ignore fix of bug introduced in the same release
115 ! echo "$origver" |
grep -q "^$version" ||
continue
119 printf '%s %7s %s (%s)\n' $version $id "$headline" "$origver"