-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdiffmsg
executable file
·174 lines (155 loc) · 4.14 KB
/
diffmsg
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/awk -f
# create release message for MMG-CI releases
# feeds on git diff --raw
BEGIN {
# map uncommon apk names to conventional names for translation
delete appmap
appmap["GoogleBackupTransport"] = "Google sync adapters"
appmap["GoogleCalendarSyncAdapter"] = "Google sync adapters"
appmap["GoogleContactsSyncAdapter"] = "Google sync adapters"
appmap["MicroGGMSCore"] = "MicroG"
appmap["MicroGGSFProxy"] = "GSF proxy"
appmap["MicroGUNLP"] = "UNLP"
appmap["Phonesky"] = "Playstore"
# init stateful vars
# arrays and index counters
appc = 0
binc = 0
cerc = 0
delete appv
delete binv
delete cerv
}
# git diff --raw format
# (p = number of parents of commit)
# (SP = space char)
# { ":" }*p { mode SP }*(p+1) { hash SP }*(p+1) status SP { filepath SP }*?
# 0..p modes and hashes are of parents, (p+1)ths are of the child
# IDK anything about filepaths
#
# example:
# :000000 100644 0000000 3abb859 A README.md
# ::100644 100644 100644 08576ac 08576ac c4585d8 MM system/bin/npem
# skip non-diff lines
# they don't start with colons
!/^:[:]*/ { next }
# process each line and take out useful fields
# set variables: file, action
{
# match the pattern and get number of colons
# number of colons = number of parents of commit
match($0, "^:[:]*")
parents = RLENGTH
offset = (parents + 1) * 2
# get change status and build array of filepaths
change = $(offset + 1)
filec = 0
delete filev
for (i = offset + 2; i <= NF; i++) {
filev[filec] = $i
filec += 1
}
# I have no idea what to with merges
# only supports non-merge commits for now
if (parents != 1) next
if (change ~ "C" || change ~ "R")
# for copies and renames, first filepath is src, second is dst
file = filev[1]
else
# for everything else there is only one filepath
file = filev[0]
# find action by matching status code
if (change ~ "A" || change ~ "C" || change ~ "R")
action = "added"
else if (change ~ "M")
action = "updated"
else if (change ~ "D")
action = "deleted"
else
# unknown status, skip
next
}
# match file with various paths
# add their string and action to relevant arrays
# array[i, 0] = string
# array[i, 1] = action
# string literals used as regex patterns are parsed twice by awk
# all escapes need to be doubled for simpler implementations
file ~ "^system/(priv-)?app/[^/]*/(-[^/]*-/)?[^/]*\\.apk$" {
split(file, arr, "/")
str = arr[3]
if (str in appmap)
str = appmap[str]
for (i = 0; i < appc; i++)
if (appv[i, 0] == str) next
appv[appc, 0] = str
appv[appc, 1] = action
appc += 1
next
}
file ~ "^system/(x)?bin/(-[^/]*-/)?[^/]*$" {
n = split(file, arr, "/")
str = "`" arr[n] "`"
for (i = 0; i < binc; i++)
if (binv[i, 0] == str) next
binv[binc, 0] = str
binv[binc, 1] = action
binc += 1
next
}
file ~ "^system/framework/(-[^/]*-/)?com\\.google\\.android\\.maps\\.jar$" {
str = "MicroG maps API v1"
for (i = 0; i < binc; i++)
if (binv[i, 0] == str) next
binv[binc, 0] = str
binv[binc, 1] = "updated"
binc += 1
next
}
file ~ "^util/certs/repo/[^/]*\\.cer$" {
split(file, arr, "/")
repo = substr(arr[4], 1, length(arr[4]) - length(".cer"))
str = "cert for repo" " " repo
for (i = 0; i < cerc; i++)
if (cerv[i, 0] == str) next
cerv[cerc, 0] = str
cerv[cerc, 1] = "changed"
cerc += 1
next
}
file ~ "^util/certs/system/(priv-)?app/[^/]*/(-[^/]*-/)?[^/]*\\.cer$" {
split(file, arr, "/")
str = "cert for app" " " arr[5]
for (i = 0; i < cerc; i++)
if (cerv[i, 0] == str) next
cerv[cerc, 0] = str
cerv[cerc, 1] = "changed"
cerc += 1
next
}
END {
# printf fmt string
fmt = " - %s %s\n"
# loop through all non-empty lists and print elements
if (appc) {
print("- Apps changed:")
for (i = 0; i < appc; i++) {
printf(fmt, appv[i, 1], appv[i, 0])
}
print("")
}
if (binc) {
print("- Binaries changed:")
for (i = 0; i < binc; i++) {
printf(fmt, binv[i, 1], binv[i, 0])
}
print("")
}
if (cerc) {
print("- Certs changed:")
for (i = 0; i < cerc; i++) {
printf(fmt, cerv[i, 1], cerv[i, 0])
}
print("")
}
}