Skip to content

Commit b84a88a

Browse files
committed
adding logic for pre
1 parent 36abb12 commit b84a88a

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

docs/index.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The easiest way to install this package is to do so directly from GitHub with `p
2222
pip install git+https://github.com/choldgraf/github-activity
2323
```
2424

25-
## Usage
25+
## Generate a markdown changelog
2626

2727
The easiest way to use `github-activity` to generate activity markdown is to use
2828
the command-line interface. It takes the following form:
@@ -50,6 +50,11 @@ github-activity jupyter/notebook -s 6.0.0 -u 6.0.1 -o sample_notebook_activity.m
5050

5151
You can find the [resulting markdown here](sample_notebook_activity).
5252

53+
### Splitting PRs by tags and prefixes
54+
55+
Often you wish to split your PRs into multiple categories. `github-activity`
56+
follows the [keepachangelog taxonomy of changes](https://keepachangelog.com/en/1.0.0/).
57+
5358
### Using a GitHub API token
5459

5560
`github-activity` uses the GitHub API to pull information about a repository's activity.

github_activity/github_activity.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
TAGS_METADATA_BASE = {
1717
"new": {
1818
"tags": ["feature", "new"],
19-
"pre": ["NEW"],
19+
"pre": ["NEW", "FEAT", "FEATURE"],
2020
"description": "New features added",
2121
},
2222
"enhancement": {
23-
"tags": ["enhancement", "feature", "enhancements"],
24-
"pre": ["NEW", "ENH"],
23+
"tags": ["enhancement", "enhancements"],
24+
"pre": ["NEW", "ENH", "ENHANCEMENT", "IMPROVE"],
2525
"description": "Enhancements made",
2626
},
2727
"bug": {
@@ -31,7 +31,7 @@
3131
},
3232
"maintenance": {
3333
"tags": ["maintenance", "maint"],
34-
"pre": ["MAINT"],
34+
"pre": ["MAINT", "MNT"],
3535
"description": "Maintenance and upkeep improvements",
3636
},
3737
"documentation": {
@@ -41,12 +41,12 @@
4141
},
4242
"api_change": {
4343
"tags": ["api-change", "apichange"],
44-
"tags": ["BREAK", "BREAKING", "UPGRADE"],
44+
"pre": ["BREAK", "BREAKING", "BRK", "UPGRADE"],
4545
"description": "API and Breaking Changes",
4646
},
4747
"deprecate": {
4848
"tags": ["deprecation", "deprecate"],
49-
"tags": ["DEPRECATE", "DEPRECATION"],
49+
"pre": ["DEPRECATE", "DEPRECATION", "DEP"],
5050
"description": "Deprecated features",
5151
},
5252
}
@@ -294,9 +294,16 @@ def generate_activity_md(
294294

295295
# Separate out items by their tag types
296296
for kind, kindmeta in tags_metadata.items():
297+
# First find the PRs based on tag
297298
mask = closed_prs["labels"].map(
298299
lambda a: any(ii in jj for ii in kindmeta["tags"] for jj in a)
299300
)
301+
# Now find PRs based on prefix
302+
mask_pre = closed_prs["title"].map(
303+
lambda title: any(f"{ipre}:" in title for ipre in kindmeta["pre"])
304+
)
305+
mask = mask | mask_pre
306+
300307
kindmeta["data"] = closed_prs.loc[mask]
301308
kindmeta["mask"] = mask
302309

0 commit comments

Comments
 (0)