Skip to content

Commit

Permalink
Add script to parse dependabot commits
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamboy1 committed Jan 11, 2023
1 parent 82e3ce9 commit 0c2867b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions parse_dependabot.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 0c2867b

Please sign in to comment.