Skip to content

Commit

Permalink
Change pull requests dates to when they are closed
Browse files Browse the repository at this point in the history
This is better than last_modified as that can be altered with milestone changes.
Also use last_modified_datetime and remove helper function
  • Loading branch information
PeterC-DLS committed Feb 9, 2024
1 parent 97326bc commit e1351c2
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions utils/create_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ def get_release_info(token, base_tag_name, head_branch_name, milestone_name):
# t.commit == commit
# t.commit.last_modified != commit.last_modified
commit = repo.get_commit(t.commit.sha)
dt = str2time(commit.last_modified)
dt = commit.last_modified_datetime
earliest = min(dt, earliest or dt)

earliest = earliest.astimezone(datetime.timezone.utc)
logger.debug(f"# tags: {len(tags)} {earliest}")

# fmt: off
Expand Down Expand Up @@ -197,18 +196,6 @@ def parse_command_line():
return parser.parse_args()


def str2time(time_string):
"""convert date/time string to datetime object
input string example: ``Tue, 20 Dec 2016 17:35:40 GMT``
"""
if time_string is None:
msg = f"need valid date/time string, not: {time_string}"
logger.error(msg)
raise ValueError(msg)
return datetime.datetime.strptime(time_string, "%a, %d %b %Y %H:%M:%S %Z")


def report(title, repo, milestone, tags, pulls, issues, commits):
print(f"## {title}")
print("")
Expand All @@ -234,7 +221,7 @@ def report(title, repo, milestone, tags, pulls, issues, commits):
print("-" * 5, " | ", "-" * 5, " | ", "-" * 5)
for k, tag in sorted(tags.items()):
commit = repo.get_commit(tag.commit.sha)
when = str2time(commit.last_modified).strftime("%Y-%m-%d")
when = commit.last_modified_datetime.strftime("%Y-%m-%d")
print(f"[{tag.commit.sha[:7]}]({tag.commit.html_url}) | {when} | {k}")
print("")
print("### Pull Requests")
Expand All @@ -246,7 +233,7 @@ def report(title, repo, milestone, tags, pulls, issues, commits):
print("-" * 5, " | ", "-" * 5, " | ", "-" * 5, " | ", "-" * 5)
for k, pull in sorted(pulls.items()):
state = {True: "merged", False: "closed"}[pull.merged]
when = str2time(pull.last_modified).strftime("%Y-%m-%d")
when = pull.closed_at.strftime("%Y-%m-%d")
# fmt: off
print(
f"[#{pull.number}]({pull.html_url})"
Expand Down

0 comments on commit e1351c2

Please sign in to comment.