blob: 8775ea48d99ed88b24df103433e074de2cffee58 [file] [log] [blame]
Chris Lukeaaeb3412017-05-23 11:46:52 -04001#!/bin/sh
2
3# Read coverity email on stdin
4# whenever we find a filename & line number reference, go git-blame it
5
6file=
7start=
8end=
9
10while read line; do
11 if echo "$line" | grep -q '^/.*: '; then
12 echo "$line"
13 file=$(echo "$line" | cut -d: -f1)
14 elif echo "$line" | grep -q '^[*]'; then
15 echo "$line"
16 file=
17 start=
18 end=
19 elif echo "$line" | grep -q '^[0-9][0-9]*'; then
20 num=$(echo "$line" | awk '{print $1}')
21 [ -z "$start" ] && start=$num
22 #git blame -L "$num,+1" ".$file" | cat
23 elif [ -z "$line" ]; then
24 if [ "$start" -a "$num" -a "$file" ]; then
25 end=$num
26 git blame --date=short -L "$start,$end" ".$file" | cat
27 start=
28 end=
29 num=
30 else
31 echo "$line"
32 fi
33 else
34 echo "$line"
35 fi
36done