From 959bddc9da20c7d35e154c9eabc746b202dc0ec7 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Wed, 10 May 2017 22:19:26 +0200 Subject: [PATCH] add a script to print releases timeline in RST format; also show a diff between versions in the timeline section of the doc --- scripts/internal/print_timeline.py | 53 ++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 scripts/internal/print_timeline.py diff --git a/scripts/internal/print_timeline.py b/scripts/internal/print_timeline.py new file mode 100644 index 000000000..ffcb8fe85 --- /dev/null +++ b/scripts/internal/print_timeline.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Prints releases' timeline in RST format. +""" + +import subprocess + + +entry = """\ +- {date}: + `{ver} `__ - + `what's new `__ - + `diff `__""" # NOQA + + +def sh(cmd): + return subprocess.check_output( + cmd, shell=True, universal_newlines=True).strip() + + +def get_tag_date(tag): + out = sh(r"git log -1 --format=%ai {}".format(tag)) + return out.split(' ')[0] + + +def main(): + releases = [] + out = sh("git tags") + for line in out.split('\n'): + tag = line.split(' ')[0] + ver = tag.replace('release-', '') + nodotver = ver.replace('.', '') + date = get_tag_date(tag) + releases.append((tag, ver, nodotver, date)) + releases.sort(reverse=True) + + for i, rel in enumerate(releases): + tag, ver, nodotver, date = rel + try: + prevtag = releases[i + 1][0] + except IndexError: + # get first commit + prevtag = sh("git rev-list --max-parents=0 HEAD") + print(entry.format(**locals())) + + +if __name__ == '__main__': + main()