summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-05-10 22:19:26 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2017-05-10 22:19:26 +0200
commit959bddc9da20c7d35e154c9eabc746b202dc0ec7 (patch)
treee95c880b92aebcdc0302830a22283da5a1b94d98 /scripts
parent80f43ab6595c63567ed55e1b56fda640f83a122f (diff)
downloadpsutil-959bddc9da20c7d35e154c9eabc746b202dc0ec7.tar.gz
add a script to print releases timeline in RST format; also show a diff between versions in the timeline section of the doc
Diffstat (limited to 'scripts')
-rw-r--r--scripts/internal/print_timeline.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/scripts/internal/print_timeline.py b/scripts/internal/print_timeline.py
new file mode 100644
index 00000000..ffcb8fe8
--- /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} <https://pypi.python.org/pypi?name=psutil&version={ver}&:action=files>`__ -
+ `what's new <https://github.com/giampaolo/psutil/blob/master/HISTORY.rst#{nodotver}>`__ -
+ `diff <https://github.com/giampaolo/psutil/compare/{prevtag}...{tag}#files_bucket>`__""" # 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()