@@ -776,10 +776,7 @@ func (gp *GerritProject) processMutation(gm *maintpb.GerritMutation) {
776
776
777
777
if clv .Version == 0 { // is a meta commit
778
778
gp .noteDirtyCL (cl ) // needs processing at end of sync
779
- cl .Meta = & GerritMeta {
780
- Commit : gc ,
781
- CL : cl ,
782
- }
779
+ cl .Meta = newGerritMeta (gc , cl )
783
780
} else {
784
781
cl .Commit = gc
785
782
cl .Version = clv .Version
@@ -837,10 +834,7 @@ func (gp *GerritProject) finishProcessingCL(cl *GerritCL) {
837
834
cl .Private = true
838
835
}
839
836
if gc .GerritMeta == nil {
840
- gc .GerritMeta = & GerritMeta {
841
- Commit : gc ,
842
- CL : cl ,
843
- }
837
+ gc .GerritMeta = newGerritMeta (gc , cl )
844
838
}
845
839
if foundStatus == "" {
846
840
foundStatus = getGerritStatus (gc )
@@ -1280,6 +1274,24 @@ type GerritMeta struct {
1280
1274
1281
1275
// CL is the Gerrit CL this metadata is for.
1282
1276
CL * GerritCL
1277
+
1278
+ flags gerritMetaFlags
1279
+ }
1280
+
1281
+ type gerritMetaFlags uint8
1282
+
1283
+ const (
1284
+ // metaFlagHashtagEdit indicates that the meta commit edits the hashtags on the commit.
1285
+ metaFlagHashtagEdit gerritMetaFlags = 1 << iota
1286
+ )
1287
+
1288
+ func newGerritMeta (gc * GitCommit , cl * GerritCL ) * GerritMeta {
1289
+ m := & GerritMeta {Commit : gc , CL : cl }
1290
+
1291
+ if msg := m .Commit .Msg ; strings .Contains (msg , "autogenerated:gerrit:setHashtag" ) && m .ActionTag () == "autogenerated:gerrit:setHashtag" {
1292
+ m .flags |= metaFlagHashtagEdit
1293
+ }
1294
+ return m
1283
1295
}
1284
1296
1285
1297
// Footer returns the "key: value" lines at the base of the commit.
@@ -1307,16 +1319,13 @@ func (m *GerritMeta) ActionTag() string {
1307
1319
// HashtagEdits returns the hashtags added and removed by this meta commit,
1308
1320
// and whether this meta commit actually modified hashtags.
1309
1321
func (m * GerritMeta ) HashtagEdits () (added , removed GerritHashtags , ok bool ) {
1310
- msg := m .Commit .Msg
1311
- // Fast path to return early on the majority of non-hashtag-mutating commits:
1312
- if ! strings .Contains (msg , "autogenerated:gerrit:setHashtag" ) {
1313
- return
1314
- }
1315
- // Parse it more properly.
1316
- if m .ActionTag () != "autogenerated:gerrit:setHashtag" {
1322
+ // Return early for the majority of meta commits that don't edit hashtags.
1323
+ if m .flags & metaFlagHashtagEdit == 0 {
1317
1324
return
1318
1325
}
1319
1326
1327
+ msg := m .Commit .Msg
1328
+
1320
1329
// Parse lines of form:
1321
1330
//
1322
1331
// Hashtag removed: bar
0 commit comments