From 44a16327c72de12634b825e5dbccb5f589bf09fd Mon Sep 17 00:00:00 2001 From: Russel Waters Date: Mon, 15 Jun 2020 10:38:23 -0400 Subject: [PATCH] update changelog logic, callout caveats (#2805) --- util/changelog.py | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/util/changelog.py b/util/changelog.py index 9f84252e..556519c3 100644 --- a/util/changelog.py +++ b/util/changelog.py @@ -1,6 +1,14 @@ import argparse import copy +""" +Changelog generation script, requires PAT see https://github.com/settings/tokens +Caveats V20 and prior release tags are tips on their respective release branches +If you try to use a start tag with one of these a full changelog will be generated +since the commit wont appear in your iterations + +""" + try: from github import Github from mdutils import MdUtils @@ -110,7 +118,7 @@ class cliArgs(): "and ending with {2}".format(self.repo, self.start, self.end) -class changelogRepo: +class generateTree: def __init__(self, args): github = Github(args.pat) self.repo = github.get_repo(args.repo) @@ -124,21 +132,24 @@ class changelogRepo: self.endCommit = self.repo.get_commit(args.end) except BaseException: exit("Error finding commit for " + args.end) - self.tree = self.repo.compare(self.start, self.end).commits + commits = self.repo.get_commits(sha=self.endCommit.sha) self.commits = {} - for commit in self.tree: - for pull in commit.get_pulls(): - labels = [] - for label in pull.labels: - labels.append(label.name) - self.commits[pull.number] = { - "Title": pull.title, - "Url": pull.html_url, - "labels": labels - } + for commit in commits: + if commit.sha == self.startCommit.sha: + break + else: + for pull in commit.get_pulls(): + labels = [] + for label in pull.labels: + labels.append(label.name) + self.commits[pull.number] = { + "Title": pull.title, + "Url": pull.html_url, + "labels": labels + } def __repr__(self): - return "