asf-tooling commented on issue #1227:
URL: 
https://github.com/apache/tooling-trusted-releases/issues/1227#issuecomment-4409645674

   <!-- gofannon-issue-triage-bot v2 -->
   
   **Automated triage** — analyzed at `main@2da7807a`
   
   **Type:** `new_feature`  •  **Classification:** `actionable`  •  
**Confidence:** `high`
   **Application domain(s):** `shared_infrastructure`, `voting`, 
`announcement_publishing`
   
   ### Summary
   The issue requests a new `{{PROJECT_KEY}}` (or `{{PROJECT_LABEL}}`) template 
variable for vote and announce email templates, resolving to the project's key 
value (e.g., `maven-apache-parent`). @slawekjaranowski clarified the value 
should be the same as the API `project_key`. @sbp confirmed 'we can certainly 
do this.' @dave2wave noted related metadata work in #913 and #139 but did not 
block this. The change is straightforward since `project_key` is already 
available in all relevant substitution functions.
   
   ### Where this lives in the code today
   
   #### `atr/construct.py` — `checklist_body` (lines 148-173)
   _needs modification_
   Substitution logic for checklist templates; needs PROJECT_KEY substitution 
added.
   
   ```python
   def checklist_body(
       markdown: str,
       project: sql.Project,
       version_key: safe.VersionKey,
       committee: sql.Committee,
       revision: sql.Revision | None,
   ) -> str:
       import atr.get.vote as vote
   
       try:
           host = quart.request.host
       except RuntimeError:
           host = config.get().APP_HOST
   
       revision_number = revision.number if revision else ""
       revision_tag = revision.tag if (revision and revision.tag) else ""
       review_path = util.as_url(vote.selected, project_key=project.key, 
version_key=version_key)
       review_url = f"https://{host}{review_path}";
   
       markdown = markdown.replace("{{COMMITTEE}}", committee.display_name)
       markdown = markdown.replace("{{PROJECT}}", project.short_display_name)
       markdown = markdown.replace("{{REVIEW_URL}}", review_url)
       markdown = markdown.replace("{{REVISION}}", revision_number)
       markdown = markdown.replace("{{TAG}}", revision_tag)
       markdown = markdown.replace("{{VERSION}}", str(version_key))
       return markdown
   ```
   
   ### Proposed approach
   Add a new `PROJECT_KEY` entry to `TEMPLATE_VARIABLES` with the description 
'Project key (label)' available in all contexts where `PROJECT` is currently 
available (announce, announce_subject, checklist, vote, vote_subject). Then add 
`{{PROJECT_KEY}}` substitution in all three substitution functions: 
`announce_release_subject_and_body`, `start_vote_subject_and_body`, and 
`checklist_body`. The value is simply `str(options.project_key)` or 
`project.key`, which is already available in each function's scope.
   
   This is a minimal, self-contained change that gives users the ability to 
construct URLs like 
`https://github.com/apache/{{PROJECT_KEY}}/issues?q=milestone%3A{{VERSION}}` in 
their vote and announce templates.
   
   ### Suggested patches
   
   #### `atr/construct.py`
   Add PROJECT_KEY to the TEMPLATE_VARIABLES list and implement substitution in 
all template expansion functions.
   
   ````diff
   --- a/atr/construct.py
   +++ b/atr/construct.py
   @@ -35,6 +35,7 @@
    TEMPLATE_VARIABLES: list[tuple[str, str, set[Context]]] = [
        ("CHECKLIST_URL", "URL to the release checklist", {"vote"}),
        ("COMMITTEE", "Committee display name", {"announce", "checklist", 
"vote", "vote_subject"}),
        ("DISCLAIMER", "Podling incubation disclaimer", {"announce"}),
        ("DOWNLOAD_URL", "URL to download the release", {"announce"}),
        ("DURATION", "Vote duration in hours", {"vote"}),
        ("KEYS_FILE", "URL to the KEYS file", {"vote"}),
        ("PROJECT", "Project display name", {"announce", "announce_subject", 
"checklist", "vote", "vote_subject"}),
   +    ("PROJECT_KEY", "Project key (label)", {"announce", "announce_subject", 
"checklist", "vote", "vote_subject"}),
        ("RELEASE_CHECKLIST", "Release checklist content", {"vote"}),
        ("REVIEW_URL", "URL to review the release", {"checklist", "vote"}),
        ("REVISION", "Revision number", {"announce", "checklist", "vote", 
"vote_subject"}),
   @@ -107,10 +108,12 @@
        # Perform substitutions in the subject
        subject = subject.replace("{{PROJECT}}", project_display_name)
   +    subject = subject.replace("{{PROJECT_KEY}}", str(options.project_key))
        subject = subject.replace("{{VERSION}}", str(options.version_key))
    
        # Perform substitutions in the body
        body = body.replace("{{COMMITTEE}}", committee.display_name)
        body = body.replace("{{DISCLAIMER}}", 
_podling_disclaimer(release.project, committee))
        body = body.replace("{{DOWNLOAD_URL}}", download_url)
        body = body.replace("{{PROJECT}}", project_display_name)
   +    body = body.replace("{{PROJECT_KEY}}", str(options.project_key))
        body = body.replace("{{REVISION}}", revision_number)
        body = body.replace("{{TAG}}", revision_tag)
   @@ -157,6 +160,7 @@
    
        markdown = markdown.replace("{{COMMITTEE}}", committee.display_name)
        markdown = markdown.replace("{{PROJECT}}", project.short_display_name)
   +    markdown = markdown.replace("{{PROJECT_KEY}}", project.key)
        markdown = markdown.replace("{{REVIEW_URL}}", review_url)
        markdown = markdown.replace("{{REVISION}}", revision_number)
        markdown = markdown.replace("{{TAG}}", revision_tag)
   @@ -218,6 +222,7 @@
        # Perform substitutions in the subject
        subject = subject.replace("{{COMMITTEE}}", committee.display_name)
        subject = subject.replace("{{PROJECT}}", str(project_display_name))
   +    subject = subject.replace("{{PROJECT_KEY}}", str(options.project_key))
        subject = subject.replace("{{REVISION}}", revision_number)
        subject = subject.replace("{{TAG}}", revision_tag)
        subject = subject.replace("{{VERSION}}", str(options.version_key))
   @@ -229,6 +234,7 @@
        body = body.replace("{{COMMITTEE}}", committee.display_name)
        body = body.replace("{{DURATION}}", str(options.vote_duration))
        body = body.replace("{{KEYS_FILE}}", keys_file or "(Sorry, the KEYS 
file is missing!)")
        body = body.replace("{{PROJECT}}", str(project_display_name))
   +    body = body.replace("{{PROJECT_KEY}}", str(options.project_key))
        body = body.replace("{{RELEASE_CHECKLIST}}", checklist_content)
        body = body.replace("{{REVIEW_URL}}", review_url)
        body = body.replace("{{REVISION}}", revision_number)
   ````
   
   ### Open questions
   - Should the variable be named `PROJECT_KEY` or `PROJECT_LABEL`? The issue 
title says `PROJECT_LABEL` but @slawekjaranowski used both names 
interchangeably. `PROJECT_KEY` is more aligned with the API naming.
   - @dave2wave mentioned related issues #913 (metadata) and #139 (.asf.yaml 
integration) — should this be deferred until that broader metadata system 
lands, or is this simple enough to do immediately as a standalone change?
   
   ### Files examined
   - `atr/construct.py`
   - `atr/models/sql.py`
   - `atr/db/__init__.py`
   - `atr/db/interaction.py`
   - `atr/get/voting.py`
   - `atr/post/voting.py`
   - `atr/shared/voting.py`
   - `atr/get/announce.py`
   
   ### Related issues
   This issue appears related to: #1228.
   
   _Both address handling of project names with 'Apache' prefix in templates 
and vote pages_
   
   ---
   *Draft from a triage agent. A human reviewer should validate before merging 
any change. The agent did not run tests or verify diffs apply.*


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to