@@ -75,7 +75,7 @@ void testJsonUpdaterBranch(TestInfo testInfo) throws IOException {
75
75
var storageFolder = tempFolder .path ().resolve ("storage" );
76
76
77
77
var updater = new JsonUpdater (jsonFolder , "12" , "team" );
78
- var notifyBot = new JNotifyBot (repo , storageFolder , "master" , tagStorage , branchStorage , List .of (updater ));
78
+ var notifyBot = new JNotifyBot (repo , storageFolder , List . of ( "master" ) , tagStorage , branchStorage , List .of (updater ));
79
79
80
80
TestBotRunner .runPeriodicItems (notifyBot );
81
81
assertEquals (List .of (), findJsonFiles (jsonFolder , "" ));
@@ -114,7 +114,7 @@ void testJsonUpdaterTag(TestInfo testInfo) throws IOException {
114
114
var storageFolder =tempFolder .path ().resolve ("storage" );
115
115
116
116
var updater = new JsonUpdater (jsonFolder , "12" , "team" );
117
- var notifyBot = new JNotifyBot (repo , storageFolder , "master" , tagStorage , branchStorage , List .of (updater ));
117
+ var notifyBot = new JNotifyBot (repo , storageFolder , List . of ( "master" ) , tagStorage , branchStorage , List .of (updater ));
118
118
119
119
TestBotRunner .runPeriodicItems (notifyBot );
120
120
assertEquals (List .of (), findJsonFiles (jsonFolder , "" ));
@@ -164,8 +164,8 @@ void testMailingList(TestInfo testInfo) throws IOException {
164
164
165
165
var sender = EmailAddress .from ("duke" , "duke@duke.duke" );
166
166
var recipient = EmailAddress .from ("list" , "list@list.list" );
167
- var updater = new MailingListUpdater (smtpServer .address (), recipient , sender );
168
- var notifyBot = new JNotifyBot (repo , storageFolder , "master" , tagStorage , branchStorage , List .of (updater ));
167
+ var updater = new MailingListUpdater (smtpServer .address (), recipient , sender , false );
168
+ var notifyBot = new JNotifyBot (repo , storageFolder , List . of ( "master" ) , tagStorage , branchStorage , List .of (updater ));
169
169
170
170
// No mail should be sent on the first run as there is no history
171
171
TestBotRunner .runPeriodicItems (notifyBot );
@@ -177,6 +177,8 @@ void testMailingList(TestInfo testInfo) throws IOException {
177
177
var email = smtpServer .receive (Duration .ofSeconds (10 ));
178
178
assertEquals (email .sender (), sender );
179
179
assertEquals (email .recipients (), List .of (recipient ));
180
+ assertTrue (email .subject ().contains (": 23456789: More fixes" ));
181
+ assertFalse (email .subject ().contains ("master" ));
180
182
assertTrue (email .body ().contains ("Changeset: " + editHash .abbreviate ()));
181
183
assertTrue (email .body ().contains ("23456789: More fixes" ));
182
184
assertFalse (email .body ().contains ("Committer" ));
@@ -202,8 +204,8 @@ void testMailingListMultiple(TestInfo testInfo) throws IOException {
202
204
203
205
var sender = EmailAddress .from ("duke" , "duke@duke.duke" );
204
206
var recipient = EmailAddress .from ("list" , "list@list.list" );
205
- var updater = new MailingListUpdater (smtpServer .address (), recipient , sender );
206
- var notifyBot = new JNotifyBot (repo , storageFolder , "master" , tagStorage , branchStorage , List .of (updater ));
207
+ var updater = new MailingListUpdater (smtpServer .address (), recipient , sender , false );
208
+ var notifyBot = new JNotifyBot (repo , storageFolder , List . of ( "master" ) , tagStorage , branchStorage , List .of (updater ));
207
209
208
210
// No mail should be sent on the first run as there is no history
209
211
TestBotRunner .runPeriodicItems (notifyBot );
@@ -218,6 +220,8 @@ void testMailingListMultiple(TestInfo testInfo) throws IOException {
218
220
var email = smtpServer .receive (Duration .ofSeconds (10 ));
219
221
assertEquals (email .sender (), sender );
220
222
assertEquals (email .recipients (), List .of (recipient ));
223
+ assertTrue (email .subject ().contains (": 2 new changesets" ));
224
+ assertFalse (email .subject ().contains ("master" ));
221
225
assertTrue (email .body ().contains ("Changeset: " + editHash1 .abbreviate ()));
222
226
assertTrue (email .body ().contains ("23456789: More fixes" ));
223
227
assertTrue (email .body ().contains ("Changeset: " + editHash2 .abbreviate ()));
@@ -244,8 +248,8 @@ void testMailingListSponsored(TestInfo testInfo) throws IOException {
244
248
245
249
var sender = EmailAddress .from ("duke" , "duke@duke.duke" );
246
250
var recipient = EmailAddress .from ("list" , "list@list.list" );
247
- var updater = new MailingListUpdater (smtpServer .address (), recipient , sender );
248
- var notifyBot = new JNotifyBot (repo , storageFolder , "master" , tagStorage , branchStorage , List .of (updater ));
251
+ var updater = new MailingListUpdater (smtpServer .address (), recipient , sender , false );
252
+ var notifyBot = new JNotifyBot (repo , storageFolder , List . of ( "master" ) , tagStorage , branchStorage , List .of (updater ));
249
253
250
254
// No mail should be sent on the first run as there is no history
251
255
TestBotRunner .runPeriodicItems (notifyBot );
@@ -267,4 +271,64 @@ void testMailingListSponsored(TestInfo testInfo) throws IOException {
267
271
}
268
272
}
269
273
274
+ @ Test
275
+ void testMailingListMultipleBranches (TestInfo testInfo ) throws IOException {
276
+ try (var smtpServer = new SMTPServer ();
277
+ var credentials = new HostCredentials (testInfo );
278
+ var tempFolder = new TemporaryDirectory ()) {
279
+ var repo = credentials .getHostedRepository ();
280
+ var repoFolder = tempFolder .path ().resolve ("repo" );
281
+ var localRepo = CheckableRepository .init (repoFolder , repo .getRepositoryType ());
282
+ var masterHash = localRepo .resolve ("master" ).orElseThrow ();
283
+ credentials .commitLock (localRepo );
284
+ var branch = localRepo .branch (masterHash , "another" );
285
+ localRepo .pushAll (repo .getUrl ());
286
+
287
+ var tagStorage = createTagStorage (repo );
288
+ var branchStorage = createBranchStorage (repo );
289
+ var storageFolder = tempFolder .path ().resolve ("storage" );
290
+
291
+ var sender = EmailAddress .from ("duke" , "duke@duke.duke" );
292
+ var recipient = EmailAddress .from ("list" , "list@list.list" );
293
+ var updater = new MailingListUpdater (smtpServer .address (), recipient , sender , true );
294
+ var notifyBot = new JNotifyBot (repo , storageFolder , List .of ("master" , "another" ), tagStorage , branchStorage , List .of (updater ));
295
+
296
+ // No mail should be sent on the first run as there is no history
297
+ TestBotRunner .runPeriodicItems (notifyBot );
298
+ assertThrows (RuntimeException .class , () -> smtpServer .receive (Duration .ofMillis (1 )));
299
+
300
+ var editHash1 = CheckableRepository .appendAndCommit (localRepo , "Another line" , "23456789: More fixes" );
301
+ localRepo .push (editHash1 , repo .getUrl (), "master" );
302
+ var editHash2 = CheckableRepository .appendAndCommit (localRepo , "Yet another line" , "3456789A: Even more fixes" );
303
+ localRepo .push (editHash2 , repo .getUrl (), "master" );
304
+
305
+ TestBotRunner .runPeriodicItems (notifyBot );
306
+ var email = smtpServer .receive (Duration .ofSeconds (10 ));
307
+ assertEquals (email .sender (), sender );
308
+ assertEquals (email .recipients (), List .of (recipient ));
309
+ assertFalse (email .subject ().contains ("another" ));
310
+ assertTrue (email .subject ().contains (": master: 2 new changesets" ));
311
+ assertTrue (email .body ().contains ("Changeset: " + editHash1 .abbreviate ()));
312
+ assertTrue (email .body ().contains ("23456789: More fixes" ));
313
+ assertTrue (email .body ().contains ("Changeset: " + editHash2 .abbreviate ()));
314
+ assertTrue (email .body ().contains ("3456789A: Even more fixes" ));
315
+ assertFalse (email .body ().contains (masterHash .abbreviate ()));
316
+ assertFalse (email .body ().contains ("456789AB: Yet more fixes" ));
317
+
318
+ localRepo .checkout (branch , true );
319
+ var editHash3 = CheckableRepository .appendAndCommit (localRepo , "Another branch" , "456789AB: Yet more fixes" );
320
+ localRepo .push (editHash3 , repo .getUrl (), "another" );
321
+
322
+ TestBotRunner .runPeriodicItems (notifyBot );
323
+ email = smtpServer .receive (Duration .ofSeconds (10 ));
324
+ assertEquals (email .sender (), sender );
325
+ assertEquals (email .recipients (), List .of (recipient ));
326
+ assertTrue (email .subject ().contains (": another: 456789AB: Yet more fixes" ));
327
+ assertFalse (email .subject ().contains ("master" ));
328
+ assertTrue (email .body ().contains ("Changeset: " + editHash3 .abbreviate ()));
329
+ assertTrue (email .body ().contains ("456789AB: Yet more fixes" ));
330
+ assertFalse (email .body ().contains ("Changeset: " + editHash2 .abbreviate ()));
331
+ assertFalse (email .body ().contains ("3456789A: Even more fixes" ));
332
+ }
333
+ }
270
334
}
0 commit comments