Skip to content
Permalink
Browse files

Add option to display long commit id

usage: changelog.py [-h] [-c COMMITS] [-v]

optional arguments:
  -h, --help            show this help message and exit
  -c COMMITS, --commits COMMITS
                        commits boundary. ex : 2.0..HEAD
  -v, --verbose         add long commit id
  • Loading branch information...
arnaudveron committed Jul 18, 2019
1 parent e89a9f9 commit 794bd2c29d7589a93910214c518414f9dd8e38dc
Showing with 12 additions and 8 deletions.
  1. +12 −8 bin/pkg/changelog.py
@@ -1,23 +1,24 @@
#!/usr/bin/python

from __future__ import print_function
import argparse
import sys
from subprocess import *
from distutils.version import LooseVersion

try:
arg = sys.argv[1]
except:
arg = "HEAD"
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--commits", type=str, default="HEAD", help="commits boundary. ex : 2.0..HEAD ")
parser.add_argument("-v", "--verbose", action="store_true", help="add long commit id")
args = parser.parse_args()

def get_commits():
cmd = ["git", "log", "--oneline", arg]
cmd = ["git", "log", '--pretty=format:%h %H %s', args.commits]
proc = Popen(cmd, stdout=PIPE)
out, _ = proc.communicate()
commits = {}
for line in out.decode().splitlines():
cid, desc = line.split(" ", 1)
commits[cid] = [cid, desc]
cid, lcid, desc = line.split(" ", 2)
commits[cid] = [cid, lcid, desc]
return commits

def get_versions(cids):
@@ -34,7 +35,10 @@ def main():
for i, cid in enumerate(cids):
commits[cid].insert(0, versions[i])
for commit in sorted(commits.values(), key=lambda x: LooseVersion(x[0]), reverse=True):
print("%-18s %s" % (commit[0], commit[2]))
if args.verbose:
print("%-18s %s %s" % (commit[0], commit[2], commit[3]))
else:
print("%-18s %s" % (commit[0], commit[3]))

try:
main()

0 comments on commit 794bd2c

Please sign in to comment.
You can’t perform that action at this time.