diff --git a/fep/7d8c/fep-7d8c.md b/fep/7d8c/fep-7d8c.md index 29aa1b0..99a1591 100644 --- a/fep/7d8c/fep-7d8c.md +++ b/fep/7d8c/fep-7d8c.md @@ -95,6 +95,12 @@ See [here](https://codeberg.org/fediverse/fep/settings/keys). One can add these secrets on [woodpecker](https://ci.codeberg.org/repos/12388), then selecting the settings wheel -> `secrets` -> `add secret`. The secrets only need to available for the `push` action (corresponding to a merged pull request). +The deploy_key needs to be end with a new line when pasting into the woodpecker ui. + +## Changes + +- Added discussion link to tracking issue, use table to format (@helge, 2025-03-07) + ## References - pukkamustard, [FEP-a4ed: The Fediverse Enhancement Proposal Process][a4ed], 2020 diff --git a/scripts/tools/issue.py b/scripts/tools/issue.py index afa3ffd..51ccf0d 100644 --- a/scripts/tools/issue.py +++ b/scripts/tools/issue.py @@ -1,6 +1,5 @@ from datetime import timedelta, date from urllib.request import Request, urlopen - import json from .fep_file import FepFile @@ -22,25 +21,36 @@ Please post links to relevant discussions as comments to this issue. `dateReceived`: {date1} If no further actions are taken, the proposal may be set by the facilitators to `WITHDRAWN` on {date2} (in 1 year). - """ +""" return body -def create_codeberg_issue(owner, repo, token, title, body): - request = Request(f"https://codeberg.org/api/v1/repos/{owner}/{repo}/issues") +def perform_post_request(url, token, body): + request = Request(url) request.add_header("Content-Type", "application/json; charset=utf-8") + + request.add_header("authorization", f"Bearer {token}") + request.add_header("Content-Length", str(len(body))) + request.data = body + + response = urlopen(request) + return json.loads(response.read()) + + +def create_codeberg_issue(owner, repo, token, title, body): request_body = json.dumps( {"title": title, "body": body, "labels": [DRAFT_FEP_LABEL]} ).encode("utf-8") - request.add_header("authorization", f"Bearer {token}") - request.add_header("Content-Length", len(request_body)) - request.data = request_body - response = urlopen(request) - issue_url = json.loads(response.read())["html_url"] + response = perform_post_request( + f"https://codeberg.org/api/v1/repos/{owner}/{repo}/issues", token, request_body + ) - return issue_url + issue_url = response["html_url"] + issue_id = response["number"] + + return issue_url, issue_id def parse_and_update_date_received(input_date: str) -> date: @@ -75,14 +85,20 @@ def create_issue(owner, repo, token, slug): fep_file.parsed_frontmatter["dateReceived"] ) update_fep_file_with_date_received(fep_file, date_received) + discussions_to = fep_file.parsed_frontmatter["discussionsTo"] body = create_body(fep_file.filename, date_received) + issue_url, issue_id = create_codeberg_issue(owner, repo, token, title, body) - issue_url = create_codeberg_issue(owner, repo, token, title, body) + body_comment = f"Discussions: {discussions_to}" + issue_body = json.dumps({"body": body_comment}).encode("utf-8") + perform_post_request( + f"https://codeberg.org/api/v1/repos/{owner}/{repo}/issues/{issue_id}/comments", + token, + issue_body, + ) fep_file.frontmatter.append(f"trackingIssue: {issue_url}") - if "discussionsTo" not in fep_file.parsed_frontmatter: - fep_file.frontmatter.append(f"discussionsTo: {issue_url}") fep_file.write() diff --git a/scripts/tools/test_issue.py b/scripts/tools/test_issue.py index 4b01657..6d26baf 100644 --- a/scripts/tools/test_issue.py +++ b/scripts/tools/test_issue.py @@ -1,6 +1,6 @@ from datetime import date, timedelta -from .issue import parse_and_update_date_received +from .issue import parse_and_update_date_received, create_body def test_parse_and_update_date_received(): @@ -22,3 +22,22 @@ def test_parse_and_update_date_received_outdated(): result = parse_and_update_date_received((today - timedelta(days=60)).isoformat()) assert result == today + + +def test_create_body(): + result = create_body("fep-0000.md", date(2025, 2, 8)) + + assert ( + result + == """ +The [proposal](https://codeberg.org/fediverse/fep/src/branch/main/fep-0000.md) has been received. Thank you! + +This issue tracks discussions and updates to the proposal during the `DRAFT` period. + +Please post links to relevant discussions as comments to this issue. + +`dateReceived`: 2025-02-08 + +If no further actions are taken, the proposal may be set by the facilitators to `WITHDRAWN` on 2026-02-08 (in 1 year). +""" + )