|
|
|
@@ -3,6 +3,7 @@ import os |
|
|
|
import requests |
|
|
|
import json |
|
|
|
import os |
|
|
|
import subprocess |
|
|
|
|
|
|
|
from datetime import datetime |
|
|
|
|
|
|
|
@@ -23,23 +24,25 @@ def grab(url): |
|
|
|
|
|
|
|
url = "https://git.crux.best/api/v1/repos/chemicalcrux/{0}/releases".format(sys.argv[1]) |
|
|
|
|
|
|
|
tag = grab(url)[0]["tag_name"] |
|
|
|
data = grab(url) |
|
|
|
|
|
|
|
url = "https://git.crux.best/api/v1/repos/chemicalcrux/{0}/commits?sha={1}".format(sys.argv[1], tag) |
|
|
|
if data: |
|
|
|
spec = data[0]["tag_name"] + "..master" |
|
|
|
else: |
|
|
|
spec = "master" |
|
|
|
|
|
|
|
data = grab(url)[1:] |
|
|
|
output = subprocess.check_output(["git", "log", r"--pretty=format:%aI%x00%s%x00%b%x00", spec]).decode("utf-8").split("\x00") |
|
|
|
|
|
|
|
results = [] |
|
|
|
for commit in data: |
|
|
|
result = {} |
|
|
|
lines = commit["commit"]["message"].split("\n") |
|
|
|
subject = lines[0] |
|
|
|
body = "\n".join(lines[2:]) |
|
|
|
data = [] |
|
|
|
|
|
|
|
result["date"] = datetime.fromisoformat(commit["commit"]["author"]["date"]).strftime("%B %d") |
|
|
|
result["subject"] = subject |
|
|
|
result["body"] = body |
|
|
|
results.append(result) |
|
|
|
# last item is an empty string |
|
|
|
for i in range(0, len(output)-1, 3): |
|
|
|
entry = {} |
|
|
|
entry["date"] = output[i].strip() |
|
|
|
entry["date"] = datetime.fromisoformat(entry["date"]).strftime("%B %d") |
|
|
|
entry["subject"] = output[i+1].strip() |
|
|
|
entry["body"] = output[i+2].strip() |
|
|
|
data.append(entry) |
|
|
|
|
|
|
|
with open(sys.argv[2], "w", encoding="utf-8") as file: |
|
|
|
json.dump(results[::-1], file) |
|
|
|
json.dump(data, file) |