Skip to content

Commit

Permalink
add a script to print releases timeline in RST format; also show a di…
Browse files Browse the repository at this point in the history
…ff between versions in the timeline section of the doc
  • Loading branch information
giampaolo committed May 10, 2017
1 parent 80f43ab commit 959bddc
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions scripts/internal/print_timeline.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 959bddc

Please sign in to comment.