From 1092d6b890a93bcfd21010a1392034c6d6de2de1 Mon Sep 17 00:00:00 2001 From: Daniel Fütterer <df89@outlook.com> Date: Sun, 24 Jan 2021 15:31:42 +0100 Subject: [PATCH] fix: no tag in latest commit required --- changelog_generator.py | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/changelog_generator.py b/changelog_generator.py index 40e877d..00d8d9f 100644 --- a/changelog_generator.py +++ b/changelog_generator.py @@ -4,7 +4,6 @@ ##### To Do ##### # - handle different keywords/types (what to process/ignore?) # - scopes -# - at the moment the script requires a tag in the latest commit to work properly # the processing ang recognizing of the commit components should be improved import os @@ -57,18 +56,28 @@ # Grouping History using tags -for commit in commitHistory: # latest commit must have a tag +for commit in commitHistory: # Look if commit has a tag if (len(commit) == 3) and ("tag: v" in commit[2]): taggedHistory.append([commit[2][(commit[2].rfind(": v")+3):-1],commit[0:2]]) else: - taggedHistory[-1].append(commit) + # Check if latest commit has a tag + if len(taggedHistory)==0: + # If there is no tag, create empty string instead + taggedHistory.append(["", commit]) + else: + taggedHistory[-1].append(commit) # Construction of the changelog-file fileTemplate = ["# Changelog"] for tag in taggedHistory: - fileTemplate.append("\n## Version " + tag[0]) + if tag[0] == "": + fileTemplate.append("\n## No version number yet ") + else: + fileTemplate.append("\n## Version " + tag[0]) + + for commit in tag[1:]: fileTemplate.append("\t- " + commit[0] + " (" + commit[1] + ")") # write into changelog -- Gitblit v1.9.1