-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathformatUnifiedDiffOutput.awk
48 lines (41 loc) · 1.21 KB
/
formatUnifiedDiffOutput.awk
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
/@@/ {
gsub(/[+-]/, "")
old = $2
numFields = split(old, fld, ",")
oldLineNum = fld[1]
numFields == 1 ? oldSize = 1 : oldSize = fld[2]
new = $3
numFields = split(new, fld, ",")
newLineNum = fld[1]
numFields == 1 ? newSize = 1 : newSize = fld[2]
# printf("old: %-10s new: %s\n",old,new)
# printf("oldLineNum: %-6s newLineNum: %-6s\n",oldLineNum,newLineNum)
# printf("oldSize: %-6s newSize: %-6s\n",oldSize,newSize)
if (oldSize == 0) {
newSize == 1 ? pluralLines = "line" : pluralLines = "lines"
printf(\
"==> added %d %s after line %s\n", newSize, pluralLines, oldLineNum\
)
}
else if (newSize == 0) {
oldSize == 1 ? pluralLines = "line" : pluralLines = "lines"
printf(\
"==> deleted %d %s at line %s\n", oldSize, pluralLines, oldLineNum\
)
}
else {
oldSize == 1 ? pluralLines = "line" : pluralLines = "lines"
printf(\
"==> changed %d %s at line %s\n", oldSize, pluralLines, oldLineNum\
)
}
next
}
/--- / { next }
/\+\+\+ / { next }
/=HYPERLINK/ {
sub(/-.*=HYPERLINK.*;"/, "-")
sub(/\+.*=HYPERLINK.*;"/, "+")
sub(/"\)/, "")
}
{ print }