-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a script to print releases timeline in RST format; also show a di…
…ff between versions in the timeline section of the doc
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |