@@ -167,6 +167,37 @@ def get_changeset_metadata(changeset_path: Path) -> dict:
167
167
f"{ metadata ['pr_author' ]} "
168
168
)
169
169
170
+ # Also try to get PR author's full info for better deduplication
171
+ pr_author_info = {}
172
+ if metadata .get ("pr_author" ) and metadata .get (
173
+ "pr_author_is_username"
174
+ ):
175
+ try :
176
+ cmd = [
177
+ "gh" ,
178
+ "api" ,
179
+ f"users/{ metadata ['pr_author' ]} " ,
180
+ ]
181
+ user_result = subprocess .run (
182
+ cmd ,
183
+ capture_output = True ,
184
+ text = True ,
185
+ check = True ,
186
+ env = env ,
187
+ )
188
+ if user_result .stdout .strip ():
189
+ import json
190
+
191
+ user_data = json .loads (user_result .stdout )
192
+ pr_author_info = {
193
+ "login" : metadata ["pr_author" ],
194
+ "name" : user_data .get ("name" , "" ),
195
+ "email" : user_data .get ("email" , "" ),
196
+ }
197
+ metadata ["pr_author_info" ] = pr_author_info
198
+ except Exception :
199
+ pass
200
+
170
201
# Also try to get co-authors from PR commits
171
202
try :
172
203
# Get all commits in the PR with full author info
@@ -185,8 +216,6 @@ def get_changeset_metadata(changeset_path: Path) -> dict:
185
216
env = env ,
186
217
)
187
218
if commits_result .stdout .strip ():
188
- import json
189
-
190
219
commits_data = json .loads (commits_result .stdout )
191
220
192
221
# Build a map of GitHub usernames to their info
@@ -241,14 +270,34 @@ def get_changeset_metadata(changeset_path: Path) -> dict:
241
270
242
271
# Extract co-authors from commit message
243
272
co_authors_from_commits = []
273
+ pr_author_info = metadata .get ("pr_author_info" , {})
274
+
244
275
for line in commit_msg .split ("\n " ):
245
276
co_author_match = re .match (
246
277
r"^Co-authored-by:\s*(.+?)\s*<(.+?)>$" , line .strip ()
247
278
)
248
279
if co_author_match :
249
280
co_author_name = co_author_match .group (1 ).strip ()
250
281
co_author_email = co_author_match .group (2 ).strip ()
251
- if co_author_name and co_author_name != metadata .get ("pr_author" ):
282
+
283
+ # Check if this co-author is actually the PR author
284
+ is_pr_author = False
285
+
286
+ # Direct username match
287
+ if co_author_name == metadata .get ("pr_author" ):
288
+ is_pr_author = True
289
+ # Check by email
290
+ elif pr_author_info and co_author_email == pr_author_info .get (
291
+ "email" , ""
292
+ ):
293
+ is_pr_author = True
294
+ # Check by name
295
+ elif pr_author_info and co_author_name == pr_author_info .get (
296
+ "name" , ""
297
+ ):
298
+ is_pr_author = True
299
+
300
+ if co_author_name and not is_pr_author :
252
301
co_authors_from_commits .append (
253
302
{"name" : co_author_name , "email" : co_author_email }
254
303
)
0 commit comments