-
Notifications
You must be signed in to change notification settings - Fork 0
/
upstream-tracker
executable file
·175 lines (155 loc) · 4.68 KB
/
upstream-tracker
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
#!/bin/bash
# Script to track mainline progress of patches in TI vendor tree
# Based on a script provided by Tomi Valkeinen <tomi.valkeinen@ti.com>
#
# License: GNU Public License, version 2.0
# paths we're interested in. speeds up processing quite a bit to limit the commits.
#paths="drivers/mmc/host"
count=$(perl -MPOSIX -le 'print LONG_MAX')
committers='\(nsekhar@ti.com\)\|\(kishon@ti.com\)'
devbranch=ti-linux/ti-linux-4.9.y
upstreambranch=linux-next/master
base=$(git describe $devbranch | cut -d "-" -f 1)
patchidweight=50
mentionweight=40
tmpfile1=`mktemp`
tmpfile2=`mktemp`
use_fuzz=0
function cleanup {
rm -rf $tmpfile1
rm -rf $tmpfile2
}
trap cleanup EXIT
# Generate list of commits with author name, headline, patch-id and commit-id
# Arg1: commit head to fetch commits from
# Arg2: list of committers to filter by
function commitlist {
for c in $(git rev-list --max-count=$count --no-merges $1 ^$base --committer=$2 $paths)
do
git log -1 --pretty=format:"%an%x09%s%x09" $c
patchid=`git show --pretty=fuller $c | git patch-id --stable | cut -d " " -f 1`
printf "%s\t%s\n" $patchid $c
done
}
# Update an existing file with new commits
# Arg1 : name of file to update
# Arg2 : commit head to fetch commits from
# Arg3 : list of committers to filter by
function updatefile {
# Get base commit in existing file
base=`head -1 $1 | awk -F'\t' '{print $4}'`
# Get list of new commits from base
commitlist $2 $3 > $tmpfile1
# If there are new commits
if [ -n "`cat $tmpfile1`" ]
then
# save existing file
cp $1 $tmpfile2
# update file with new + old commits
cat $tmpfile1 $tmpfile2 > $1
rm -f $tmpfile2
echo "file $1 updated" 1>&2
fi
echo `wc -l $tmpfile1 | cut -d " " -f 1`
}
echo -n "development base: " 1>&2
git describe $devbranch 1>&2
echo -n "upstream base: " 1>&2
git describe $upstreambranch 1>&2
echo -n "patch base: " 1>&2
git describe $base 1>&2
# collect patch ids for commits in ti-linux
if [ -f ti-patch-id-list ]
then
echo "using existing file ti-patch-id-list" 1>&2
numcommits=`updatefile ti-patch-id-list $devbranch $committers`
echo "updated ti-patch-id-list with $numcommits commits" 1>&2
else
commitlist $devbranch $committers > ti-patch-id-list
echo "done creating ti-patch-id-list" 1>&2
fi
# collect patch ids for commits in mainline
if [ -f upstream-patch-id-list ]
then
echo "using existing file upstream-patch-id-list" 1>&2
numcommits=`updatefile upstream-patch-id-list $upstreambranch '@'`
echo "updated upstream-patch-id-list with $numcommits commits" 1>&2
else
commitlist $upstreambranch '@' > upstream-patch-id-list
echo "done creating upstream-patch-id-list" 1>&2
fi
# Find a headline with fuzz of 5 characters
# Echoes the line found, warns if multiple lines found, and returns the weight of the match (0-10)
function fuzzygrep {
weight=5
for i in `seq 0 $weight`
do
lines=`tre-agrep -k -E $i "$1" $2`
if [ -z "$lines" ]
then
count=0
else
count=`echo "$lines" | wc -l`
fi
if [ $count -gt 1 ]
then
echo "warning: multiple matches found at fuzz" $i "for headline" \""$1"\" "(using only first match)" 1>&2
echo "$lines" 1>&2
fi
if [ $count -gt 0 ]
then
weight=`expr $weight - $i`
echo "$lines" | head -1
return `expr $weight \* 2`
fi
done
}
# returns the shortened form of a commit
function shortcommit {
echo `git log -1 --format="%h" $1`
}
# combine both lists into one
printf "Author\tHeadline\tTI Commit\tPatch-id match\tHeadline match\tPatch description mention\tScore\n"
while read l; do
score=0
author=`echo "$l" | awk -F'\t' '{print $1}'`
headline=`echo "$l" | awk -F'\t' '{print $2}'`
patchid=`echo "$l" | awk -F'\t' '{print $3}'`
commitid=`echo "$l" | awk -F'\t' '{print $4}'`
foundline=`grep -m 1 $patchid upstream-patch-id-list`
upcommitid=`echo "$foundline" | awk -F'\t' '{print $4}'`
if [ -z $upcommitid ]
then
upcommitid="NA"
else
upcommitid=$(shortcommit $upcommitid)
score=`expr $score + $patchidweight`
fi
printf "%s\t%s\t%s\t%s\t" "$author" "$headline" $(shortcommit $commitid) $upcommitid
if [ $use_fuzz -eq 1 ]
then
foundline="$(fuzzygrep "$headline" upstream-patch-id-list)"
grepweight=$?
else
foundline=`grep "$headline" upstream-patch-id-list | head -1`
grepweight=10
fi
upcommitid=`echo "$foundline" | awk -F'\t' '{print $4}'`
if [ -z $upcommitid ]
then
upcommitid="NA"
else
upcommitid=$(shortcommit $upcommitid)
score=`expr $score + $grepweight`
fi
printf "%s\t" $upcommitid
upcommitid=`git show --pretty=fuller $commitid | grep -E "commit [[:alnum:]]{40} upstream" | cut -d " " -f 6`
if [ -z $upcommitid ]
then
upcommitid="NA"
else
upcommitid=$(shortcommit $upcommitid)
score=`expr $score + $mentionweight`
fi
printf "%s\t%s\n" $upcommitid $score
done < ti-patch-id-list