From f4c8243e9cb02500716ba8b3999f890714372ffd Mon Sep 17 00:00:00 2001 From: Qubasa Date: Wed, 3 Jul 2024 19:03:39 +0200 Subject: [PATCH] matrix-bot: Better changelog --- modules/matrix-bot.nix | 2 +- pkgs/matrix-bot/matrix_bot/changelog_bot.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/matrix-bot.nix b/modules/matrix-bot.nix index 9dd6e4a..63e812b 100644 --- a/modules/matrix-bot.nix +++ b/modules/matrix-bot.nix @@ -33,7 +33,7 @@ in script = '' set -euxo pipefail - mbot + mbot --changelog-room "\!FdCwyKsRlfooNYKYzx:matrix.org" --review-room "\!tmSRJlbsVXFUKAddiM:gchq.icu" ''; }; } diff --git a/pkgs/matrix-bot/matrix_bot/changelog_bot.py b/pkgs/matrix-bot/matrix_bot/changelog_bot.py index a760757..1e8e8d3 100644 --- a/pkgs/matrix-bot/matrix_bot/changelog_bot.py +++ b/pkgs/matrix-bot/matrix_bot/changelog_bot.py @@ -2,6 +2,7 @@ import asyncio import datetime import json import logging +import shlex import subprocess from pathlib import Path @@ -65,6 +66,7 @@ def write_file_with_date_prefix( async def git_pull(repo_path: Path) -> None: cmd = ["git", "pull"] + log.debug(f"Running command: {shlex.join(cmd)}") process = await asyncio.create_subprocess_exec( *cmd, cwd=str(repo_path), @@ -81,6 +83,7 @@ async def git_log(repo_path: str, ndays: int) -> str: "--stat", "--patch", ] + log.debug(f"Running command: {shlex.join(cmd)}") process = await asyncio.create_subprocess_exec( *cmd, cwd=repo_path, @@ -160,15 +163,21 @@ async def changelog_bot( log.info(f"Generating changelog from {fromdate} to {todate}") system_prompt = f""" -Create a concise changelog for the past week from {fromdate} to {todate}, focusing on new features and summarizing bug fixes into a single entry. Follow these guidelines: +Create a concise changelog for the past week from {fromdate} to {todate}. +Follow these guidelines: -- Discard duplicate entries -- Discard uninteresting changes - Use present tense - Keep the summary brief - Follow commit message format: "scope: message (#number)" -- Link pull requests as: '{gitea.url}/{gitea.owner}/{gitea.repo}/pull/' -- Mention each feature only once +- Link pull requests as: '{gitea.url}/{gitea.owner}/{gitea.repo}/pulls/' +- Mention each scope and pull request number only once +- Have these headers in the changelog if applicable: + - New Features + - Bug Fixes + - Refactoring + - Documentation + - Removed Features + - Other Changes Changelog: ---