From 30b032929e522f7b663fe41287e6cc379e44d776 Mon Sep 17 00:00:00 2001 From: Roaring <216452114+the-roaring@users.noreply.github.com> Date: Wed, 16 Jul 2025 13:32:12 -0700 Subject: [PATCH 1/3] fix dupes --- .changeset/woodoo-ultraviolet-mustang.md | 5 +++ changeset/changelog.py | 48 ++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 .changeset/woodoo-ultraviolet-mustang.md diff --git a/.changeset/woodoo-ultraviolet-mustang.md b/.changeset/woodoo-ultraviolet-mustang.md new file mode 100644 index 0000000..6b21c78 --- /dev/null +++ b/.changeset/woodoo-ultraviolet-mustang.md @@ -0,0 +1,5 @@ +--- +"changeset": patch +--- + +fix dupes diff --git a/changeset/changelog.py b/changeset/changelog.py index 8695454..f106e1b 100755 --- a/changeset/changelog.py +++ b/changeset/changelog.py @@ -167,6 +167,34 @@ def get_changeset_metadata(changeset_path: Path) -> dict: f"{metadata['pr_author']}" ) + # Also try to get PR author's full info for better deduplication + pr_author_info = {} + if metadata.get("pr_author") and metadata.get("pr_author_is_username"): + try: + cmd = [ + "gh", + "api", + f"users/{metadata['pr_author']}", + ] + user_result = subprocess.run( + cmd, + capture_output=True, + text=True, + check=True, + env=env, + ) + if user_result.stdout.strip(): + import json + user_data = json.loads(user_result.stdout) + pr_author_info = { + 'login': metadata['pr_author'], + 'name': user_data.get('name', ''), + 'email': user_data.get('email', '') + } + metadata["pr_author_info"] = pr_author_info + except Exception: + pass + # Also try to get co-authors from PR commits try: # Get all commits in the PR with full author info @@ -185,8 +213,6 @@ def get_changeset_metadata(changeset_path: Path) -> dict: env=env, ) if commits_result.stdout.strip(): - import json - commits_data = json.loads(commits_result.stdout) # Build a map of GitHub usernames to their info @@ -241,6 +267,8 @@ def get_changeset_metadata(changeset_path: Path) -> dict: # Extract co-authors from commit message co_authors_from_commits = [] + pr_author_info = metadata.get("pr_author_info", {}) + for line in commit_msg.split("\n"): co_author_match = re.match( r"^Co-authored-by:\s*(.+?)\s*<(.+?)>$", line.strip() @@ -248,7 +276,21 @@ def get_changeset_metadata(changeset_path: Path) -> dict: if co_author_match: co_author_name = co_author_match.group(1).strip() co_author_email = co_author_match.group(2).strip() - if co_author_name and co_author_name != metadata.get("pr_author"): + + # Check if this co-author is actually the PR author + is_pr_author = False + + # Direct username match + if co_author_name == metadata.get("pr_author"): + is_pr_author = True + # Check by email + elif pr_author_info and co_author_email == pr_author_info.get("email", ""): + is_pr_author = True + # Check by name + elif pr_author_info and co_author_name == pr_author_info.get("name", ""): + is_pr_author = True + + if co_author_name and not is_pr_author: co_authors_from_commits.append( {"name": co_author_name, "email": co_author_email} ) From e67bf86557762f7312ae4cadec3edad5eda7b670 Mon Sep 17 00:00:00 2001 From: Roaring <216452114+the-roaring@users.noreply.github.com> Date: Wed, 16 Jul 2025 13:32:54 -0700 Subject: [PATCH 2/3] run format --- changeset/changelog.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/changeset/changelog.py b/changeset/changelog.py index f106e1b..5453dfa 100755 --- a/changeset/changelog.py +++ b/changeset/changelog.py @@ -169,7 +169,9 @@ def get_changeset_metadata(changeset_path: Path) -> dict: # Also try to get PR author's full info for better deduplication pr_author_info = {} - if metadata.get("pr_author") and metadata.get("pr_author_is_username"): + if metadata.get("pr_author") and metadata.get( + "pr_author_is_username" + ): try: cmd = [ "gh", @@ -185,11 +187,12 @@ def get_changeset_metadata(changeset_path: Path) -> dict: ) if user_result.stdout.strip(): import json + user_data = json.loads(user_result.stdout) pr_author_info = { - 'login': metadata['pr_author'], - 'name': user_data.get('name', ''), - 'email': user_data.get('email', '') + "login": metadata["pr_author"], + "name": user_data.get("name", ""), + "email": user_data.get("email", ""), } metadata["pr_author_info"] = pr_author_info except Exception: @@ -268,7 +271,7 @@ def get_changeset_metadata(changeset_path: Path) -> dict: # Extract co-authors from commit message co_authors_from_commits = [] pr_author_info = metadata.get("pr_author_info", {}) - + for line in commit_msg.split("\n"): co_author_match = re.match( r"^Co-authored-by:\s*(.+?)\s*<(.+?)>$", line.strip() @@ -276,20 +279,24 @@ def get_changeset_metadata(changeset_path: Path) -> dict: if co_author_match: co_author_name = co_author_match.group(1).strip() co_author_email = co_author_match.group(2).strip() - + # Check if this co-author is actually the PR author is_pr_author = False - + # Direct username match if co_author_name == metadata.get("pr_author"): is_pr_author = True # Check by email - elif pr_author_info and co_author_email == pr_author_info.get("email", ""): + elif pr_author_info and co_author_email == pr_author_info.get( + "email", "" + ): is_pr_author = True # Check by name - elif pr_author_info and co_author_name == pr_author_info.get("name", ""): + elif pr_author_info and co_author_name == pr_author_info.get( + "name", "" + ): is_pr_author = True - + if co_author_name and not is_pr_author: co_authors_from_commits.append( {"name": co_author_name, "email": co_author_email} From a18a365954452cd60789b4282c553776decf297d Mon Sep 17 00:00:00 2001 From: Roaring <216452114+the-roaring@users.noreply.github.com> Date: Wed, 16 Jul 2025 13:32:57 -0700 Subject: [PATCH 3/3] update lockfile --- uv.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uv.lock b/uv.lock index c5100e3..7f67a17 100644 --- a/uv.lock +++ b/uv.lock @@ -4,7 +4,7 @@ requires-python = ">=3.13" [[package]] name = "changeset" -version = "0.2.5" +version = "0.2.7" source = { editable = "." } dependencies = [ { name = "click" },