From 1e413d034f0410f675ef851913ed7c49c7936fac Mon Sep 17 00:00:00 2001 From: jLynx Date: Mon, 4 Apr 2022 08:54:43 +1200 Subject: [PATCH] WIP python --- .github/workflows/changelog.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/changelog.py diff --git a/.github/workflows/changelog.py b/.github/workflows/changelog.py new file mode 100644 index 00000000..81e5c441 --- /dev/null +++ b/.github/workflows/changelog.py @@ -0,0 +1,28 @@ +import os +import re +import sys + +raw_git = os.popen('git log next --since="5 days" --pretty=format:"- %h - {USERNAME}*+%al-%an*: %s"').read() + + +def compute_username(line): + stripped = re.search(r'(?<=\*)(.*?)(?=\*)', line).group(0) + + pattern = re.compile("[$@+&?].*[$@+&?]") + if pattern.match(stripped): + stripped = re.sub("[$@+&?].*[$@+&?]", "", stripped) + stripped = re.match(r'.+?(?=-)', stripped).group(0) + else: + stripped = re.sub(r'^.*?-', "", stripped) + return "@" + stripped + + +def compile_line(line): + username = compute_username(line) + line = re.sub(r'[*].*[*]', "", line) + line = line.replace("{USERNAME}", username) + return line + + +for row in raw_git.splitlines(): + print(compile_line(row))