Skip to content

Ensure PRs only show up once per changelog #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/use.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ You can choose to *remove* some types of PRs from your changelog by passing the
left-most column above.
```

### Pull Requests with Multiple Matching Labels

If a pull request has multiple labels that match different categories, it will appear in **only the first matching section** based on the order of categories processed. For example, a PR labeled with both `api-change` and `enhancement` will appear only in the "API and Breaking Changes" section, not in "Enhancements made". The categories are processed in the same order as they show above.

## Include Pull Request reviewers and commenters in your changelog

By default, GitHub Activity will include anybody that _reviews_ or _comments_ in a pull request in the item for that PR. This is included in a list of authors at the end of each item. See [the JupyterHub Changelog](https://jupyterhub.readthedocs.io/en/stable/reference/changelog.html) for examples.
Expand Down
120 changes: 78 additions & 42 deletions github_activity/github_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import subprocess
import sys
import urllib
from collections import OrderedDict
from json import loads
from pathlib import Path
from subprocess import CalledProcessError
Expand All @@ -27,48 +28,74 @@


# The tags and description to use in creating subsets of PRs
TAGS_METADATA_BASE = {
"api_change": {
"tags": ["api-change", "apichange", "breaking"],
"pre": ["BREAK", "BREAKING", "BRK", "UPGRADE"],
"description": "API and Breaking Changes",
},
"new": {
"tags": ["feature", "new"],
"pre": ["NEW", "FEAT", "FEATURE"],
"description": "New features added",
},
"enhancement": {
"tags": ["enhancement", "enhancements"],
"pre": ["ENH", "ENHANCEMENT", "IMPROVE", "IMP"],
"description": "Enhancements made",
},
"bug": {
"tags": ["bug", "bugfix", "bugs"],
"pre": ["FIX", "BUG"],
"description": "Bugs fixed",
},
"maintenance": {
"tags": ["maintenance", "maint"],
"pre": ["MAINT", "MNT"],
"description": "Maintenance and upkeep improvements",
},
"documentation": {
"tags": ["documentation", "docs", "doc"],
"pre": ["DOC", "DOCS"],
"description": "Documentation improvements",
},
"ci": {
"tags": ["ci", "continuous-integration"],
"pre": ["CI"],
"description": "Continuous integration improvements",
},
"deprecate": {
"tags": ["deprecation", "deprecate"],
"pre": ["DEPRECATE", "DEPRECATION", "DEP"],
"description": "Deprecated features",
},
}
TAGS_METADATA_BASE = OrderedDict(
[
(
"api_change",
{
"tags": ["api-change", "apichange", "breaking"],
"pre": ["BREAK", "BREAKING", "BRK", "UPGRADE"],
"description": "API and Breaking Changes",
},
),
(
"new",
{
"tags": ["feature", "new"],
"pre": ["NEW", "FEAT", "FEATURE"],
"description": "New features added",
},
),
(
"deprecate",
{
"tags": ["deprecation", "deprecate"],
"pre": ["DEPRECATE", "DEPRECATION", "DEP"],
"description": "Deprecated features",
},
),
(
"enhancement",
{
"tags": ["enhancement", "enhancements"],
"pre": ["ENH", "ENHANCEMENT", "IMPROVE", "IMP"],
"description": "Enhancements made",
},
),
(
"bug",
{
"tags": ["bug", "bugfix", "bugs"],
"pre": ["FIX", "BUG"],
"description": "Bugs fixed",
},
),
(
"maintenance",
{
"tags": ["maintenance", "maint"],
"pre": ["MAINT", "MNT"],
"description": "Maintenance and upkeep improvements",
},
),
(
"documentation",
{
"tags": ["documentation", "docs", "doc"],
"pre": ["DOC", "DOCS"],
"description": "Documentation improvements",
},
),
(
"ci",
{
"tags": ["ci", "continuous-integration"],
"pre": ["CI"],
"description": "Continuous integration improvements",
},
),
]
)

# exclude known bots from contributor lists
# Also see 'ignore-contributor' flag/configuration option.
Expand Down Expand Up @@ -581,6 +608,9 @@ def filter_ignored(userlist):
)

# Separate out items by their tag types
# Track which PRs have already been assigned to prevent duplicates
assigned_prs = set()

for kind, kindmeta in tags_metadata.items():
# First find the PRs based on tag
mask = closed_prs["labels"].map(
Expand All @@ -592,9 +622,15 @@ def filter_ignored(userlist):
)
mask = mask | mask_pre

# Exclude PRs that have already been assigned to a previous category
mask = mask & ~closed_prs.index.isin(assigned_prs)

kindmeta["data"] = closed_prs.loc[mask]
kindmeta["mask"] = mask

# Add the assigned PRs to our tracking set
assigned_prs.update(closed_prs.loc[mask].index)

# All remaining PRs w/o a label go here
all_masks = np.array(
[~kindinfo["mask"].values for _, kindinfo in tags_metadata.items()]
Expand Down
5 changes: 4 additions & 1 deletion tests/test_cli/test_pr_split.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

([full changelog](https://github.com/jupyter-book/jupyter-book/compare/v0.7.1...v0.7.3))

## API and Breaking Changes

- 👌 IMPROVE: improving numbered sections [#826](https://github.com/jupyter-book/jupyter-book/pull/826) ([@choldgraf](https://github.com/choldgraf))

## New features added

- ✨ NEW: Adding - chapter entries to _toc.yml [#817](https://github.com/jupyter-book/jupyter-book/pull/817) ([@choldgraf](https://github.com/choldgraf))

## Enhancements made

- 👌 IMPROVE: improving numbered sections [#826](https://github.com/jupyter-book/jupyter-book/pull/826) ([@choldgraf](https://github.com/choldgraf))
- checking for toc modification time [#772](https://github.com/jupyter-book/jupyter-book/pull/772) ([@choldgraf](https://github.com/choldgraf), [@chrisjsewell](https://github.com/chrisjsewell))
- first pass toc directive [#757](https://github.com/jupyter-book/jupyter-book/pull/757) ([@choldgraf](https://github.com/choldgraf), [@AakashGfude](https://github.com/AakashGfude))

Expand Down