From 0d53612520622307cbf6a7b9d783de18c373cb15 Mon Sep 17 00:00:00 2001
From: df89 <df89@me.com>
Date: Tue, 08 Jun 2021 11:35:25 +0200
Subject: [PATCH] fix: Correct order of Types

---
 oop_changelog_scope.py |   40 ++++++++++++++++++++++------------------
 1 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/oop_changelog_scope.py b/oop_changelog_scope.py
index 9594c58..23b57c1 100644
--- a/oop_changelog_scope.py
+++ b/oop_changelog_scope.py
@@ -167,40 +167,44 @@
 
 
     # Grouping by Type
-    commitsByType = {"Other":[], "Fixes":[], "Features":[]}
+    featType = ["Features"]
+    fixType = ["Fixes"]
+    otherType = ["Other"]
     nonconformCommits = []
+    
     for commit in tag[1:]:
         if commit.body.commitType == CommitBody.commitTypes[5]: # fix
-            commitsByType["Fixes"].append(commit)
+            fixType.append(commit)
         elif commit.body.commitType == CommitBody.commitTypes[4]: # feat
-            commitsByType["Features"].append(commit)
+            featType.append(commit)
         elif commit.body.commitType == "nonconform":
             nonconformCommits.append(commit)
         else:
-            commitsByType["Other"].append(commit)
+            otherType.append(commit)
 
     # Sub-Grouping by Scopes within Types    
-    while len(commitsByType) > 0:
-        commitsByScope = {}
-        commitType, commits = commitsByType.popitem()
-        noScope = []
-        if len(commits) == 0:
+    commitlistByType = [featType, fixType, otherType]
+    for commitsByType in commitlistByType:
+        if len(commitsByType) == 1:
             continue
-
-        for commit in commits:
+        commitlistByScope = {}
+        noScope = []
+        for commit in commitsByType:
+            if type(commit) == str:
+                continue
             if commit.body.scope == None:
                 noScope.append(commit)
-            elif commit.body.scope in commitsByScope:
-                commitsByScope[commit.body.scope].append(commit)
+            elif commit.body.scope in commitlistByScope:
+                commitlistByScope[commit.body.scope].append(commit)
             else:
-                commitsByScope[commit.body.scope] = [commit]
+                commitlistByScope[commit.body.scope] = [commit]
         
-        fileTemplate.append("\n### " + str(commitType))
-        while len(commitsByScope) > 0:
-            scope, commits = commitsByScope.popitem()
+        fileTemplate.append("\n### " + commitsByType[0])
+        while len(commitlistByScope) > 0:
+            scope, commits = commitlistByScope.popitem()
             fileTemplate.append("- *" + str(scope) + "*")
             for commit in commits:
-                if commitType == "Other":
+                if commitsByType[0] == "Other":
                     fileTemplate.append("    - (" + commit.body.commitType + ") " + commit.body.subject + commit.appendShortHash())
                 else:
                     fileTemplate.append("    - " + commit.body.subject + commit.appendShortHash())

--
Gitblit v1.9.1