| | |
| | | |
| | | ##### To Do ##### |
| | | # - handle further keywords/types other than "feat" and "fix" |
| | | # - scopes |
| | | # - deal with parameters configuring the output (dev/usr; types, hash y/n, ...) |
| | | # Refactoring: rewrite using oop (-> UML) |
| | | # the processing ang recognizing of the commit components should be improved |
| | | |
| | | import os |
| | |
| | | |
| | | # Grouping by type "feat" and "fix" |
| | | for commit in tag[1:]: |
| | | if commit[0].startswith("fix: "): |
| | | commitsByType["Fixes"].append(commit) |
| | | elif commit[0].startswith("feat: "): |
| | | commitsByType["Features"].append(commit) |
| | | old = commit[0] |
| | | if commit[0].startswith(keywords[5]): # "fix" |
| | | if commit[0].startswith("fix: "): |
| | | new = old[(old.index(":")+2):] |
| | | commit[0] = new |
| | | commitsByType["Fixes"].append(commit) |
| | | else: |
| | | new = "**" + old[(old.index("(")+1):old.index(")")] + "**: " + old[(old.index(":")+2):] |
| | | commit[0] = new |
| | | commitsByType["Fixes"].append(commit) |
| | | elif commit[0].startswith(keywords[4]): # "feat" |
| | | if commit[0].startswith("feat: "): |
| | | new = old[(old.index(":")+2):] |
| | | commit[0] = new |
| | | commitsByType["Features"].append(commit) |
| | | else: |
| | | new = "**" + old[(old.index("(")+1):old.index(")")] + "**: " + old[(old.index(":")+2):] |
| | | commit[0] = new |
| | | 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] + ")") |
| | | fileTemplate.append("- " + feature[0] + " (" + commit[1][:6] + ")") |
| | | if len(commitsByType["Fixes"]) != 0: |
| | | fileTemplate.append("### Fixes") |
| | | for fix in commitsByType["Fixes"]: |
| | | fileTemplate.append("- " + fix[0][4:] + " (" + commit[1] + ")") |
| | | fileTemplate.append("- " + fix[0] + " (" + commit[1][:6] + ")") |
| | | |
| | | # write into changelog |
| | | with open("changelog.md", "w") as file: |