Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions github_activity/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@
action="store_true",
help="Include a list of opened items in the markdown output",
)
parser.add_argument(
"--include-release-notes",
default=False,
action="store_true",
help="Include the `# release notes` block of each PR in the output markdown.",
)
parser.add_argument(
"--strip-brackets",
default=False,
Expand Down Expand Up @@ -165,6 +171,7 @@ def main():
tags=tags,
include_issues=bool(args.include_issues),
include_opened=bool(args.include_opened),
include_release_notes=bool(args.include_release_notes),
strip_brackets=bool(args.strip_brackets),
branch=args.branch,
)
Expand Down
22 changes: 22 additions & 0 deletions github_activity/github_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ def generate_activity_md(
tags=None,
include_issues=False,
include_opened=False,
include_release_notes=False,
strip_brackets=False,
heading_level=1,
branch=None,
Expand Down Expand Up @@ -338,6 +339,9 @@ def generate_activity_md(
Include Issues in the markdown output. Default is False.
include_opened : bool
Include a list of opened items in the markdown output. Default is False.
include_release_notes : bool
Search PR descriptions for a `# Release Notes` block. If found, include
the contents of this block with the changelog output for the PR.
strip_brackets : bool
If True, strip any text between brackets at the beginning of the issue/PR title.
E.g., [MRG], [DOC], etc.
Expand Down Expand Up @@ -537,9 +541,27 @@ def generate_activity_md(
for irow, irowdata in items["data"].iterrows():
author = irowdata["author"]
ititle = irowdata["title"]
description = irowdata["body"]
if strip_brackets and ititle.strip().startswith("[") and "]" in ititle:
ititle = ititle.split("]", 1)[-1].strip()
this_md = f"- {ititle} [#{irowdata['number']}]({irowdata['url']}) ([@{author}](https://github.com/{author}))"

# Search the description for release notes and add them if they exist
if include_release_notes:
lines = description.split("\n")
headers = [ii.startswith("#") for ii in lines]
release_notes = [ii for ii in headers if "# release notes" in ii.lower()]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that this allows for subheadings and different capitalizations!

if release_notes:
# Find the line of the next header to know when to stop
release_notes_line = release_notes[0]
next_header_ix = headers.index(release_notes_line) + 1
next_header = headers[next_header_ix]
release_notes_start = lines.index(release_notes_line)
release_notes_stop = lines.index(next_header)

# Append the release notes to our output markdown
release_notes = "\n".join(lines[release_notes_start:release_notes_stop])
this_md += f"\n {release_notes}"
items["md"].append(this_md)

# Get functional GitHub references: any git reference or master@{YY-mm-dd}
Expand Down
1 change: 1 addition & 0 deletions github_activity/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
id
title
url
body
createdAt
updatedAt
closedAt
Expand Down