Skip to content

Commit 153d168

Browse files
authored
fix dupes (#17)
* fix dupes * run format * update lockfile
1 parent f930f58 commit 153d168

File tree

3 files changed

+58
-4
lines changed

3 files changed

+58
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"changeset": patch
3+
---
4+
5+
fix dupes

changeset/changelog.py

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,37 @@ def get_changeset_metadata(changeset_path: Path) -> dict:
167167
f"{metadata['pr_author']}"
168168
)
169169

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+
170201
# Also try to get co-authors from PR commits
171202
try:
172203
# Get all commits in the PR with full author info
@@ -185,8 +216,6 @@ def get_changeset_metadata(changeset_path: Path) -> dict:
185216
env=env,
186217
)
187218
if commits_result.stdout.strip():
188-
import json
189-
190219
commits_data = json.loads(commits_result.stdout)
191220

192221
# Build a map of GitHub usernames to their info
@@ -241,14 +270,34 @@ def get_changeset_metadata(changeset_path: Path) -> dict:
241270

242271
# Extract co-authors from commit message
243272
co_authors_from_commits = []
273+
pr_author_info = metadata.get("pr_author_info", {})
274+
244275
for line in commit_msg.split("\n"):
245276
co_author_match = re.match(
246277
r"^Co-authored-by:\s*(.+?)\s*<(.+?)>$", line.strip()
247278
)
248279
if co_author_match:
249280
co_author_name = co_author_match.group(1).strip()
250281
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:
252301
co_authors_from_commits.append(
253302
{"name": co_author_name, "email": co_author_email}
254303
)

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)