| | |
| | | # -*- coding: utf-8 -*- |
| | | |
| | | ##### To Do ##### |
| | | # - handle different keywords/types (what to process/ignore?) |
| | | # - handle further keywords/types other than "feat" and "fix" |
| | | # - scopes |
| | | # the processing ang recognizing of the commit components should be improved |
| | | |
| | |
| | | |
| | | # put commit into list |
| | | commitHistory.append(commit) |
| | | |
| | | # handle commit types (work in progress) |
| | | # variant a |
| | | #if commit[0].startswith("feat"): |
| | | # print("Feature recognized!") |
| | | #elif commit[0].startswith("chore"): |
| | | # print("Chore recognized!") |
| | | # variant b |
| | | #for i in keywords: |
| | | # if commit[0].startswith(i): |
| | | # print(i) |
| | | # pass |
| | | |
| | | |
| | | # Grouping History using tags |
| | |
| | | # Construction of the changelog-file |
| | | fileTemplate = ["# Changelog"] |
| | | for tag in taggedHistory: |
| | | # A Dictionairy to store grouped commits |
| | | commitsByType = {"Fixes":[],"Features":[]} |
| | | |
| | | # If latest commit has no tag: |
| | | if tag[0] == "": |
| | | fileTemplate.append("\n## No version number yet ") |
| | | else: |
| | | fileTemplate.append("\n## Version " + tag[0]) |
| | | |
| | | |
| | | |
| | | # Grouping by type "feat" and "fix" |
| | | for commit in tag[1:]: |
| | | fileTemplate.append("\t- " + commit[0] + " (" + commit[1] + ")") |
| | | if commit[0].startswith("fix: "): |
| | | commitsByType["Fixes"].append(commit) |
| | | elif commit[0].startswith("feat: "): |
| | | commitsByType["Features"].append(commit) |
| | | |
| | | # Creating grouped output |
| | | if len(commitsByType["Features"]) != 0: |
| | | fileTemplate.append("### Features") |
| | | for feature in commitsByType["Features"]: |
| | | fileTemplate.append("- " + feature[0][5:] + " (" + commit[1] + ")") |
| | | if len(commitsByType["Fixes"]) != 0: |
| | | fileTemplate.append("### Fixes") |
| | | for fix in commitsByType["Fixes"]: |
| | | fileTemplate.append("- " + fix[0][4:] + " (" + commit[1] + ")") |
| | | |
| | | # write into changelog |
| | | with open("changelog.md", "w") as file: |
| | | for line in fileTemplate: |