#!/usr/bin/python # Copyright (C) 2001-2023 Artifex Software, Inc. # All Rights Reserved. # # This software is provided AS-IS with no warranty, either express or # implied. # # This software is distributed under license and may not be copied, # modified or distributed except as expressly authorized under the terms # of the license contained in the file LICENSE in this distribution. # # Refer to licensing information at http://www.artifex.com or contact # Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, # CA 94129, USA, for further information. # # noddy script to rejig the git log output into a Ghostscript html changelog import os import sys argc = len(sys.argv) if argc < 3: sys.stderr.write("Usage: gitlog2changelog.py \n") sys.stderr.write("For example: gitlog2changelog.py b246d9d 0805588\n") else: sys.stdout.write ("\n") sys.stdout.write ("\n\n\nGhostscript change history\n\n") sys.stdout.write ("\n") sys.stdout.write ("\n") sys.stdout.write ("\n") sys.stdout.write ("\n") # Create a list of commit SHA1 sums we want to log commit_list = [] cmd="git log --topo-order --pretty=oneline " + sys.argv[1] + "..." + sys.argv[2] res = os.popen(cmd, "r") line1=res.readline() while line1: line2 = line1.rstrip() commit_list.append(str.split(line2)[0]) line1=res.readline() res.close() # Now traverse that list getting the commit messages for each for csum in commit_list: # we have to use the slightly baroque syntax: git log --cc --topo-order ^... # where the "^" indicates the commit prior to the one we're processing with # cmd="git log --name-only --topo-order --date=iso -n1 " + csum + "^" + "..." + csum cmd="git log --name-only --topo-order --date=iso -n1 " + csum + "^" + "..." + csum # this leaves out the file list for each commit res = os.popen(cmd, "r") commit=res.readlines() # This assumes the order of the lines..... sys.stdout.write("

") if str.find(commit[1], "Merge:") < 0: nm = commit[1] dt = commit[2] logidx = 3 else: nm = commit[2] dt = commit[3] logidx = 4 sys.stdout.write (dt.split("Date:")[1].strip()) sys.stdout.write ("\n") auth_name=nm.split("Author: ")[1].strip() sys.stdout.write ("\n
" + auth_name.replace("<", "<").replace(">", ">") + "
\n") sys.stdout.write ("") sys.stdout.write (commit[0].split("commit ")[1].strip() + "\n") sys.stdout.write ("

\n") sys.stdout.write ("

\n") log = commit[logidx:] marked = 0 # this loop needs to skip initial blank lines for logline in log: if len(logline.strip()) == 0 and marked == 0 : continue sys.stdout.write (logline.replace("&", "&").replace("<", "<").replace(">", ">").replace("\"", """).rstrip() + "
\n") marked = 1 sys.stdout.write ("

\n") sys.stdout.write ("

\n") sys.stdout.write ("
\n") sys.stdout.write ("
\n\n\n") sys.stdout.write ("\n") sys.stdout.write ("\n")