From 0c2867b78fb8e491044f5b835e53fa08f1e4f1ee Mon Sep 17 00:00:00 2001 From: Philip Dolbel Date: Thu, 12 Jan 2023 12:06:10 +1300 Subject: [PATCH] Add script to parse dependabot commits --- parse_dependabot.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 parse_dependabot.py diff --git a/parse_dependabot.py b/parse_dependabot.py new file mode 100755 index 00000000..6a131faa --- /dev/null +++ b/parse_dependabot.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + +import re +import sys + +import subprocess + +if len(sys.argv) <= 1: + print("Please supply the ref as the first parameter") + sys.exit(1) + +proc = subprocess.run(f'git log {sys.argv[1]}..HEAD --author="dependabot\[bot\]" --grep="^Bump" --oneline --no-decorate', shell=True, stdout=subprocess.PIPE, text=True) +lines = sorted(proc.stdout.splitlines()) + +warnings = [] +output = [] + +p = re.compile(r"Bump ([a-zA-Z\/\-\_0-9]+) from ([0-9\.]+) to ([0-9\.]+)") +for (line, match) in map(lambda line: (line, p.search(line)), lines): + if not match: + warnings.append(line) + + name, old, new = match.group(1,2,3) + output.append(f"- Update {name} from {old} to {new}.") + +print(*sorted(set(output)), sep="\n") + +if warnings: + print("Could not parse these lines") + print(*warnings, sep="\n")