This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git


The following commit(s) were added to refs/heads/main by this push:
     new ec5014b  Add release policy property accessors and use better defaults
ec5014b is described below

commit ec5014ba7af3d7c8ac0d6358ec34a616a8d501ca
Author: Sean B. Palmer <[email protected]>
AuthorDate: Thu May 29 15:02:34 2025 +0100

    Add release policy property accessors and use better defaults
---
 atr/construct.py | 59 ++++---------------------------------
 atr/db/models.py | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+), 54 deletions(-)

diff --git a/atr/construct.py b/atr/construct.py
index a41f781..7701394 100644
--- a/atr/construct.py
+++ b/atr/construct.py
@@ -85,27 +85,8 @@ async def announce_release_default(project_name: str) -> str:
         project = await data.project(name=project_name, 
_release_policy=True).demand(
             RuntimeError(f"Project {project_name} not found")
         )
-        release_policy = project.release_policy
-    if release_policy is not None:
-        # NOTE: Do not use "if release_policy.announce_release_template is 
None"
-        # We want to check for the empty string too
-        if release_policy.announce_release_template:
-            return release_policy.announce_release_template
 
-    return """\
-The Apache [COMMITTEE] project team is pleased to announce the
-release of [PROJECT] [VERSION].
-
-This is a stable release available for production use.
-
-Downloads are available from the following URL:
-
-[DOWNLOAD_URL]
-
-On behalf of the Apache [COMMITTEE] project team,
-
-[YOUR_FULL_NAME] ([YOUR_ASF_ID])
-"""
+    return project.policy_announce_release_template
 
 
 async def start_vote_body(body: str, options: StartVoteOptions) -> str:
@@ -155,38 +136,8 @@ async def start_vote_body(body: str, options: 
StartVoteOptions) -> str:
 
 async def start_vote_default(project_name: str) -> str:
     async with db.session() as data:
-        release_policy = await db.get_project_release_policy(data, 
project_name)
-
-    if release_policy is not None:
-        # NOTE: Do not use "if release_policy.announce_release_template is 
None"
-        # We want to check for the empty string too
-        if release_policy.start_vote_template:
-            return release_policy.start_vote_template
-
-    return """Hello [COMMITTEE],
-
-I'd like to call a vote on releasing the following artifacts as
-Apache [PROJECT] [VERSION].
-
-The release candidate page, including downloads, can be found at:
-
-  [REVIEW_URL]
-
-The release artifacts are signed with one or more GPG keys from:
-
-  [KEYS_FILE]
-
-Please review the release candidate and vote accordingly.
-
-[ ] +1 Release this package
-[ ] +0 Abstain
-[ ] -1 Do not release this package (please provide specific comments)
-
-You can vote on ATR at the URL above, or manually by replying to this email.
-
-This vote will remain open for [DURATION] hours.
+        project = await data.project(name=project_name, 
_release_policy=True).demand(
+            RuntimeError(f"Project {project_name} not found")
+        )
 
-[RELEASE_CHECKLIST]
-Thanks,
-[YOUR_FULL_NAME] ([YOUR_ASF_ID])
-"""
+    return project.policy_start_vote_template
diff --git a/atr/db/models.py b/atr/db/models.py
index 5b17550..e22b26a 100644
--- a/atr/db/models.py
+++ b/atr/db/models.py
@@ -266,6 +266,95 @@ class Project(sqlmodel.SQLModel, table=True):
         previews = await self.previews
         return drafts + candidates + previews
 
+    @property
+    def policy_announce_release_default(self) -> str:
+        return """\
+The Apache [COMMITTEE] project team is pleased to announce the
+release of [PROJECT] [VERSION].
+
+This is a stable release available for production use.
+
+Downloads are available from the following URL:
+
+[DOWNLOAD_URL]
+
+On behalf of the Apache [COMMITTEE] project team,
+
+[YOUR_FULL_NAME] ([YOUR_ASF_ID])
+"""
+
+    @property
+    def policy_start_vote_default(self) -> str:
+        return """Hello [COMMITTEE],
+
+I'd like to call a vote on releasing the following artifacts as
+Apache [PROJECT] [VERSION].
+
+The release candidate page, including downloads, can be found at:
+
+  [REVIEW_URL]
+
+The release artifacts are signed with one or more GPG keys from:
+
+  [KEYS_FILE]
+
+Please review the release candidate and vote accordingly.
+
+[ ] +1 Release this package
+[ ] +0 Abstain
+[ ] -1 Do not release this package (please provide specific comments)
+
+You can vote on ATR at the URL above, or manually by replying to this email.
+
+This vote will remain open for [DURATION] hours.
+
+[RELEASE_CHECKLIST]
+Thanks,
+[YOUR_FULL_NAME] ([YOUR_ASF_ID])
+"""
+
+    @property
+    def policy_announce_release_template(self) -> str:
+        if ((policy := self.release_policy) is None) or 
(policy.announce_release_template is None):
+            return self.policy_announce_release_default
+        return policy.announce_release_template
+
+    @property
+    def policy_mailto_addresses(self) -> list[str]:
+        if ((policy := self.release_policy) is None) or 
(policy.mailto_addresses is None):
+            return [f"dev@{self.name}.apache.org"]
+        return policy.mailto_addresses
+
+    @property
+    def policy_manual_vote(self) -> bool:
+        if ((policy := self.release_policy) is None) or (policy.manual_vote is 
None):
+            return False
+        return policy.manual_vote
+
+    @property
+    def policy_min_hours(self) -> int:
+        if ((policy := self.release_policy) is None) or (policy.min_hours is 
None):
+            return 72
+        return policy.min_hours
+
+    @property
+    def policy_pause_for_rm(self) -> bool:
+        if ((policy := self.release_policy) is None) or (policy.pause_for_rm 
is None):
+            return False
+        return policy.pause_for_rm
+
+    @property
+    def policy_release_checklist(self) -> str:
+        if ((policy := self.release_policy) is None) or 
(policy.release_checklist is None):
+            return ""
+        return policy.release_checklist
+
+    @property
+    def policy_start_vote_template(self) -> str:
+        if ((policy := self.release_policy) is None) or 
(policy.start_vote_template is None):
+            return self.policy_start_vote_default
+        return policy.start_vote_template
+
 
 class DistributionChannel(sqlmodel.SQLModel, table=True):
     id: int = sqlmodel.Field(default=None, primary_key=True)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to