From fb560a5bea9cd90c0fd371c48f1ab33b0b50e0e4 Mon Sep 17 00:00:00 2001 From: Christian Steinhaus Date: Thu, 8 Aug 2019 10:05:58 +0200 Subject: [PATCH] Commit messages are now links Each commit message links to its commit page in the Webinterface --- wmn.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wmn.py b/wmn.py index fdb467f..0518792 100644 --- a/wmn.py +++ b/wmn.py @@ -87,13 +87,15 @@ def process_gitlab_request(): return sorted(commits, key=lambda commit: commit["timestamp"]) def extract_commit_message(commit): - return shorten(next(iter_first_line(commit["message"]), "$EMPTY_COMMIT_MESSAGE - impossibruh")) + msg = shorten(next(iter_first_line(commit["message"]), "$EMPTY_COMMIT_MESSAGE - impossibruh")) + url = commit["url"] + return msg, url username = request.json["user_name"] commit_messages = list(map(extract_commit_message, sort_commits_by_time(request.json["commits"]))) project_name = request.json["project"]["name"] - html_commits = "\n".join((f"
  • {msg}
  • " for msg in commit_messages)) - text_commits = "\n".join((f"- {msg}" for msg in commit_messages)) + html_commits = "\n".join((f'
  • {msg}
  • ' for (msg, url) in commit_messages)) + text_commits = "\n".join((f"- [{msg}]({url})" for (msg, url) in commit_messages)) try: room.send_html(f"{username} pushed {len(commit_messages)} commits to {project_name}
    \n" f"\n",