From 5e495dbd9547d343951301c3d60ac89a8eaf7464 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Sun, 6 Nov 2022 11:46:04 +0100 Subject: [PATCH] Fancy up the git commit message --- lib/db_revision.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/db_revision.py b/lib/db_revision.py index 1985066..0723ee8 100644 --- a/lib/db_revision.py +++ b/lib/db_revision.py @@ -52,9 +52,27 @@ class DBRevision: return self.package < other.package return self.rev < other.rev + def request_accept_message(self): + request = Request.find(self.db, self.request_id) + msg = f"Accepting request {request.number} from {request.source_project}\n\n" + msg += self.comment.strip() + url = self.api_url.replace("api.", "build.") + msg += f"\n\nOBS-URL: {url}/request/show/{self.request_number}" + return msg + def git_commit_message(self): - # TODO: Normalize better the commit message - return f"{self.comment}\n\n{self}" + msg = "" + if self.request_id: + msg = self.request_accept_message() + else: + msg = self.comment.strip() + "\n" + url = self.api_url.replace("api.", "build.") + if self.rev == int(self.rev): + # do not link to fake revisions + msg += f"\nOBS-URL: {url}/package/show/{self.project}/{self.package}?expand=0&rev={int(self.rev)}" + else: + msg += f"\nOBS-URL: {url}/package/show/{self.project}/{self.package}?expand=0&rev={self.expanded_srcmd5}" + return msg def as_dict(self): """Return a dict we can put into YAML for test cases"""