diff --git a/release-scripts/create_log.py b/release-scripts/create_log.py index 36208a38a7..83bb86391e 100755 --- a/release-scripts/create_log.py +++ b/release-scripts/create_log.py @@ -1,135 +1,139 @@ #!/usr/bin/env python3 # stolen from releaseme/plasma, which was stolen from release-tools Applications/15.04 branch # ported to Python 3 and fixed the worst issues + removed Plasma-related bits --Kevin from __future__ import print_function import argparse import os import subprocess import sys import cgi -def createLog(repositoryName, fromVersion, toVersion): - p = subprocess.Popen('git fetch', shell=True, +def createLog(workingDir, fromVersion, toVersion, repositoryName=None): + if not repositoryName: + # use cwd name as repository name + repositoryName = os.path.split(workingDir)[1] + + p = subprocess.Popen('git fetch', shell=True, cwd=workingDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) if p.wait() != 0: raise NameError('git fetch failed') - p = subprocess.Popen('git rev-parse ' + fromVersion + ' ' + toVersion, shell=True, + p = subprocess.Popen('git rev-parse ' + fromVersion + ' ' + toVersion, shell=True, cwd=workingDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) if p.wait() != 0: raise NameError("git rev-parse failed -- correct to/from version?") - p = subprocess.Popen('git log ' + fromVersion + '...' + toVersion, shell=True, + p = subprocess.Popen('git log ' + fromVersion + '...' + toVersion, shell=True, cwd=workingDir, stdout=subprocess.PIPE, universal_newlines=True) commit = [] commits = [] for line in p.stdout: if line.startswith("commit"): if len(commit) > 1 and not ignoreCommit: commits.append(commit) commitHash = line[7:].strip() ignoreCommit = False commit = [commitHash] elif line.startswith("Author"): pass elif line.startswith("Date"): pass elif line.startswith("Merge"): pass else: line = line.strip() if line.startswith("Merge remote-tracking branch"): ignoreCommit = True elif line.startswith("SVN_SILENT"): ignoreCommit = True elif line.startswith("GIT_SILENT"): ignoreCommit = True elif line.startswith("Merge branch"): ignoreCommit = True elif line.startswith("Update version number for"): ignoreCommit = True elif line: commit.append(line) # Add the last commit if len(commit) > 1 and not ignoreCommit: commits.append(commit) if len(commits): print("

" + repositoryName + "

") print("\n\n") if p.wait() != 0: raise NameError('git log failed', repositoryName, fromVersion, toVersion) if __name__ == "__main__": parser = argparse.ArgumentParser(description='Create HTML log based on Git history in the current working directory') - parser.add_argument('--repositoryName', type=str, help='The path to the Git repositoryNamesitory (default: name of current working dir', default=os.path.split(os.getcwd())[1]) + parser.add_argument('--repositoryName', type=str, help='The path to the Git repositoryNamesitory (default: name of current working dir', default=None) parser.add_argument('from_version', type=str, help='The start of the revision range (e.g. "v5.0.0")') parser.add_argument('to_version', type=str, help='The end of the revision range (e.g. "v5.0.1"') args = parser.parse_args() - createLog(args.repositoryName, args.from_version, args.to_version) + createLog(os.getcwd(), args.repositoryName, args.from_version, args.to_version)