updated release script to add --start-tag option

This commit is contained in:
Lex Berezhny 2019-06-25 12:50:13 -04:00
parent 18e19213f4
commit b1982a81dc

View file

@ -77,8 +77,8 @@ def get_release_text(desc: str):
def get_previous_final(repo, current_release): def get_previous_final(repo, current_release):
assert current_release.rc is not None, "Need an rc to find the previous final release." assert current_release.rc is not None, "Need an rc to find the previous final release."
previous = None previous = None
for release in repo.releases(current_release.rc + 1): for tag in repo.tags(current_release.rc+1):
previous = release previous = tag
return previous return previous
@ -143,13 +143,15 @@ def release(args):
print(f'Current Version: {current_version}') print(f'Current Version: {current_version}')
new_version = current_version.increment(args.action) new_version = current_version.increment(args.action)
print(f' New Version: {new_version}') print(f' New Version: {new_version}')
print()
if args.action == '*-rc': if args.action == '*-rc':
previous_release = get_previous_final(repo, current_version) previous_release = repo.release_from_tag(args.start_tag or get_previous_final(repo, current_version))
else: else:
previous_release = repo.release_from_tag(current_version.tag) previous_release = repo.release_from_tag(current_version.tag)
print(f' Changelog From: {previous_release.tag_name} ({previous_release.created_at})')
print()
incompats = [] incompats = []
release_texts = [] release_texts = []
unlabeled = [] unlabeled = []
@ -263,6 +265,7 @@ def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("--test", default=False, action="store_true", help="run unit tests") parser.add_argument("--test", default=False, action="store_true", help="run unit tests")
parser.add_argument("--dry-run", default=False, action="store_true", help="show what will be done") parser.add_argument("--dry-run", default=False, action="store_true", help="show what will be done")
parser.add_argument("--start-tag", help="custom starting tag for changelog generation")
parser.add_argument("action", nargs="?", choices=['major+rc', 'minor+rc', 'micro+rc', '*+rc', '*-rc']) parser.add_argument("action", nargs="?", choices=['major+rc', 'minor+rc', 'micro+rc', '*+rc', '*-rc'])
args = parser.parse_args() args = parser.parse_args()
if args.test: if args.test: