Daniel Fütterer
26.02.21 81313f0e2721b1f7a4643a7607c264caeb5c9abd
fix: output of scopes now correct

Scopes are highlighted instead of being grouped (incorrectly)
1 files modified
38 ■■■■■ changed files
oop_changelog.py 38 ●●●●● patch | view | raw | blame | history
oop_changelog.py
@@ -66,7 +66,7 @@
    
    def setCommitType(self):
        for commitType in self.commitTypes:
            if (self.completeMessage.startswith((commitType + ": "))) or (self.completeMessage.startswith((commitType + "("))):
            if (self.completeMessage.startswith((commitType + ": "))) or (self.completeMessage.startswith((commitType + "("))) or (self.completeMessage.startswith((commitType + " ("))):
                self.commitType = commitType
                break
            else:
@@ -153,8 +153,7 @@
fileTemplate = ["# Changelog"]
for tag in taggedHistory:
    # A Dictionairy to store grouped commits
    commitsByType = {"Fixes":[], "Features":[], "Other":[], "Nonconform":[]}
    commitsByScope = {}
    commitsByType = {"fix":[], "feat":[], "Other":[], "Nonconform":[]}
    # If latest commit has no tag:
    if not tag[0]:
@@ -164,38 +163,35 @@
    # Grouping by CommitTypes
    for commit in tag[1:]:
        # Dealing with scopes
        if commit.body.scope:
            if commit.body.scope not in commitsByScope:
                commitsByScope[commit.body.scope] = [commit]
            else:
                commitsByScope[commit.body.scope].append(commit)
            for scope in commitsByScope:
                fileTemplate.append("### Scope: " + scope)
                for commit in commitsByScope[scope]:
                    fileTemplate.append("- " + commit.body.getCommitMessageWithType() + commit.appendShortHash())
        else:
            # Sorting in predifend groups
            if commit.body.commitType == CommitBody.commitTypes[5]: # fix
                commitsByType["Fixes"].append(commit)
            commitsByType["fix"].append(commit)
            elif commit.body.commitType == CommitBody.commitTypes[4]: # feat
                commitsByType["Features"].append(commit)
            commitsByType["feat"].append(commit)
            elif commit.body.commitType == "nonconform":
                commitsByType["Nonconform"].append(commit)
            else:
                commitsByType["Other"].append(commit)
    
    if len(commitsByType["Features"]) != 0:
    if len(commitsByType["feat"]) != 0:
        fileTemplate.append("### Features")
        for feature in commitsByType["Features"]:
        for feature in commitsByType["feat"]:
            if feature.body.scope:
                fileTemplate.append("- **" + feature.body.scope + "**: " + feature.body.subject + feature.appendShortHash())
            else:
            fileTemplate.append("- " + feature.body.subject + feature.appendShortHash())
    if len(commitsByType["Fixes"]) != 0:
    if len(commitsByType["fix"]) != 0:
        fileTemplate.append("### Fixes")
        for fix in commitsByType["Fixes"]:
        for fix in commitsByType["fix"]:
            if fix.body.scope:
                fileTemplate.append("- **" + fix.body.scope  + "**: " + fix.body.scope + fix.appendShortHash())
            else:
            fileTemplate.append("- " + fix.body.subject + fix.appendShortHash())
    if len(commitsByType["Other"]) != 0:
        fileTemplate.append("### Other")
        for other in commitsByType["Other"]:
            if other.body.scope:
                fileTemplate.append("- **" + other.body.scope + "**: " +  other.body.getCommitMessageWithType() + other.appendShortHash())
            else:
            fileTemplate.append("- " + other.body.getCommitMessageWithType() + other.appendShortHash())
    if len(commitsByType["Nonconform"]) != 0:
        fileTemplate.append("### Non-conventional")