@@ -30,7 +30,7 @@ def test_get_contributors(self, mock_contributor_stats):
3030 mock_repo .contributors .return_value = [mock_user ]
3131 mock_repo .full_name = "owner/repo"
3232
33- get_contributors (mock_repo , "2022-01-01" , "2022-12-31" , "" , False )
33+ get_contributors (mock_repo , "2022-01-01" , "2022-12-31" , "" , False , None )
3434
3535 mock_contributor_stats .assert_called_once_with (
3636 "user" ,
@@ -81,10 +81,10 @@ def test_get_all_contributors_with_organization(self, mock_get_contributors):
8181 ],
8282 )
8383 mock_get_contributors .assert_any_call (
84- "repo1" , "2022-01-01" , "2022-12-31" , ghe , False
84+ "repo1" , "2022-01-01" , "2022-12-31" , ghe , False , mock_github_connection
8585 )
8686 mock_get_contributors .assert_any_call (
87- "repo2" , "2022-01-01" , "2022-12-31" , ghe , False
87+ "repo2" , "2022-01-01" , "2022-12-31" , ghe , False , mock_github_connection
8888 )
8989
9090 @patch ("contributors.get_contributors" )
@@ -130,7 +130,7 @@ def test_get_all_contributors_with_repository(self, mock_get_contributors):
130130 ],
131131 )
132132 mock_get_contributors .assert_called_once_with (
133- "repo" , "2022-01-01" , "2022-12-31" , ghe , False
133+ "repo" , "2022-01-01" , "2022-12-31" , ghe , False , mock_github_connection
134134 )
135135
136136 @patch ("contributors.contributor_stats.ContributorStats" )
@@ -153,7 +153,7 @@ def test_get_contributors_skip_users_with_no_commits(self, mock_contributor_stat
153153 mock_repo .get_commits .side_effect = StopIteration
154154 ghe = ""
155155
156- get_contributors (mock_repo , "2022-01-01" , "2022-12-31" , ghe , False )
156+ get_contributors (mock_repo , "2022-01-01" , "2022-12-31" , ghe , False , None )
157157
158158 # Note that only user is returned and user2 is not returned here because there were no commits in the date range
159159 mock_contributor_stats .assert_called_once_with (
@@ -181,7 +181,7 @@ def test_get_contributors_skip_bot(self, mock_contributor_stats):
181181 mock_repo .get_commits .side_effect = StopIteration
182182 ghe = ""
183183
184- get_contributors (mock_repo , "2022-01-01" , "2022-12-31" , ghe , False )
184+ get_contributors (mock_repo , "2022-01-01" , "2022-12-31" , ghe , False , None )
185185
186186 # Note that only user is returned and user2 is not returned here because there were no commits in the date range
187187 mock_contributor_stats .isEmpty ()
@@ -202,7 +202,7 @@ def test_get_contributors_no_commit_end_date(self, mock_contributor_stats):
202202 mock_repo .get_commits .side_effect = StopIteration
203203 ghe = ""
204204
205- get_contributors (mock_repo , "2022-01-01" , "" , ghe , False )
205+ get_contributors (mock_repo , "2022-01-01" , "" , ghe , False , None )
206206
207207 # Note that only user is returned and user2 is not returned here because there were no commits in the date range
208208 mock_contributor_stats .assert_called_once_with (
@@ -228,7 +228,7 @@ def test_get_coauthors_from_message_with_noreply_email(self):
228228
229229Co-authored-by: John Doe <[email protected] > 230230"""
231- result = get_coauthors_from_message (message )
231+ result = get_coauthors_from_message (message , None )
232232 self .assertEqual (result , ["johndoe" ])
233233
234234 def test_get_coauthors_from_message_with_noreply_email_with_id (self ):
@@ -239,7 +239,7 @@ def test_get_coauthors_from_message_with_noreply_email_with_id(self):
239239
240240Co-authored-by: John Doe <[email protected] > 241241"""
242- result = get_coauthors_from_message (message )
242+ result = get_coauthors_from_message (message , None )
243243 self .assertEqual (result , ["johndoe" ])
244244
245245 def test_get_coauthors_from_message_multiple_coauthors (self ):
@@ -251,7 +251,7 @@ def test_get_coauthors_from_message_multiple_coauthors(self):
251251Co-authored-by: Alice <[email protected] > 252252Co-authored-by: Bob <[email protected] > 253253"""
254- result = get_coauthors_from_message (message )
254+ result = get_coauthors_from_message (message , None )
255255 self .assertEqual (result , ["alice" , "bob" ])
256256
257257 def test_get_coauthors_from_message_with_regular_email (self ):
@@ -262,7 +262,7 @@ def test_get_coauthors_from_message_with_regular_email(self):
262262
263263Co-authored-by: John Doe <[email protected] > 264264"""
265- result = get_coauthors_from_message (message )
265+ result = get_coauthors_from_message (message , None )
266266 self .
assertEqual (
result , [
"[email protected] " ])
267267
268268 def test_get_coauthors_from_message_case_insensitive (self ):
@@ -274,22 +274,22 @@ def test_get_coauthors_from_message_case_insensitive(self):
274274co-authored-by: John Doe <[email protected] > 275275CO-AUTHORED-BY: Jane Doe <[email protected] > 276276"""
277- result = get_coauthors_from_message (message )
277+ result = get_coauthors_from_message (message , None )
278278 self .assertEqual (result , ["johndoe" , "janedoe" ])
279279
280280 def test_get_coauthors_from_message_empty_message (self ):
281281 """
282282 Test extracting co-authors from an empty commit message.
283283 """
284- result = get_coauthors_from_message ("" )
284+ result = get_coauthors_from_message ("" , None )
285285 self .assertEqual (result , [])
286286
287287 def test_get_coauthors_from_message_no_coauthors (self ):
288288 """
289289 Test extracting co-authors from a commit message without co-authors.
290290 """
291291 message = "Fix bug in login system"
292- result = get_coauthors_from_message (message )
292+ result = get_coauthors_from_message (message , None )
293293 self .assertEqual (result , [])
294294
295295 def test_get_coauthors_from_message_mixed_email_types (self ):
@@ -302,7 +302,7 @@ def test_get_coauthors_from_message_mixed_email_types(self):
302302Co-authored-by: Bob <[email protected] > 303303Co-authored-by: Charlie <[email protected] > 304304"""
305- result = get_coauthors_from_message (message )
305+ result = get_coauthors_from_message (message , None )
306306 self .
assertEqual (
result , [
"alice" ,
"[email protected] " ,
"charlie" ])
307307
308308 def test_get_coauthor_contributors (self ):
@@ -327,9 +327,8 @@ def test_get_coauthor_contributors(self):
327327
328328 mock_repo .commits .return_value = [mock_commit1 , mock_commit2 ]
329329
330- existing_usernames = set ()
331330 result = get_coauthor_contributors (
332- mock_repo , "2022-01-01" , "2022-12-31" , "" , existing_usernames
331+ mock_repo , "2022-01-01" , "2022-12-31" , "" , None
333332 )
334333
335334 # Alice should have count 2, Bob should have count 1
@@ -345,9 +344,9 @@ def test_get_coauthor_contributors(self):
345344 elif contributor .username == "bob" :
346345 self .assertEqual (contributor .contribution_count , 1 )
347346
348- def test_get_coauthor_contributors_excludes_existing (self ):
347+ def test_get_coauthor_contributors_includes_all (self ):
349348 """
350- Test that get_coauthor_contributors excludes already existing contributors.
349+ Test that get_coauthor_contributors includes all co-authors, even if they are already main contributors.
351350 """
352351 mock_repo = MagicMock ()
353352 mock_repo .full_name = "owner/repo"
@@ -361,15 +360,16 @@ def test_get_coauthor_contributors_excludes_existing(self):
361360
362361 mock_repo .commits .return_value = [mock_commit ]
363362
364- # Alice is already a contributor
365- existing_usernames = {"alice" }
363+ # Alice is already a main contributor, but should still be included in co-author results
366364 result = get_coauthor_contributors (
367- mock_repo , "2022-01-01" , "2022-12-31" , "" , existing_usernames
365+ mock_repo , "2022-01-01" , "2022-12-31" , "" , None
368366 )
369367
370- # Only Bob should be in the result
371- self .assertEqual (len (result ), 1 )
372- self .assertEqual (result [0 ].username , "bob" )
368+ # Both Alice and Bob should be in the result
369+ self .assertEqual (len (result ), 2 )
370+ usernames = {c .username for c in result }
371+ self .assertIn ("alice" , usernames )
372+ self .assertIn ("bob" , usernames )
373373
374374 @patch ("contributors.get_coauthor_contributors" )
375375 def test_get_contributors_with_acknowledge_coauthors (
@@ -397,7 +397,12 @@ def test_get_contributors_with_acknowledge_coauthors(
397397 mock_get_coauthor_contributors .return_value = [mock_coauthor ]
398398
399399 result = get_contributors (
400- mock_repo , "2022-01-01" , "2022-12-31" , "" , acknowledge_coauthors = True
400+ mock_repo ,
401+ "2022-01-01" ,
402+ "2022-12-31" ,
403+ "" ,
404+ acknowledge_coauthors = True ,
405+ github_connection = None ,
401406 )
402407
403408 # Verify that get_coauthor_contributors was called
0 commit comments