mirror of
https://codeberg.org/fediverse/fep.git
synced 2026-08-05 19:55:46 +00:00
e4683fbcda
### Preview version https://helge.codeberg.page/fep/ click there to judge ### Tasks done - [x] Add a proper index.md instead of final.md .... needs me to filter the readme.md - [x] search is broken --> will resolve itself when all feps are part of it - [x] Update https://codeberg.org/fediverse/fep/src/branch/main/fep/7d8c/fep-7d8c.md - [x] The admonition format (according to copilot I can blame this format on Microsoft https://learn.microsoft.com/en-us/contribute/content/markdown-reference#alerts-note-important-tip-warning-caution) ``` >[!NOTE] >ActivityPub [requires][ActivityPub-Collections] ordered collections to be presented in reverse chronological order. However, an [erratum][ActivityPub-Errata] was proposed to relax this requirement. ``` is not the one supported by python, see https://python-markdown.github.io/extensions/admonition/ . One can probably resolve this by adapting the code https://github.com/Python-Markdown/markdown/blob/f39cf84a24124526c1a0efbe52219fa9950774f6/markdown/extensions/admonition.py - [x] FEPs miss meta information .... - [x] Meta information for tracking issue and discussion to link should be formatted - [x] copy script has problems with contained directories - [x] add codeberg link to meta, e.g. https://helge.codeberg.page/fep/fep/1b12/ - [x] include implementation counts -> https://codeberg.org/fediverse/fep/issues/686 Co-authored-by: silverpill <silverpill@firemail.cc> Reviewed-on: https://codeberg.org/fediverse/fep/pulls/673 Reviewed-by: silverpill <silverpill@noreply.codeberg.org> Co-authored-by: Helge <helge.krueger@gmail.com> Co-committed-by: Helge <helge.krueger@gmail.com>
106 lines
3.1 KiB
Python
106 lines
3.1 KiB
Python
from datetime import timedelta, date
|
|
from urllib.request import Request, urlopen
|
|
import json
|
|
|
|
from .fep_file import FepFile
|
|
|
|
DRAFT_FEP_LABEL = 149758
|
|
|
|
|
|
def create_body(filename: str, date_received: date):
|
|
date1 = date_received.isoformat()
|
|
date2 = (date_received + timedelta(days=365 * 2)).isoformat()
|
|
|
|
body = f"""
|
|
The [proposal](https://codeberg.org/fediverse/fep/src/branch/main/{filename}) 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`: {date1}
|
|
|
|
If no further actions are taken, the proposal will be set by the facilitators to `WITHDRAWN` on {date2} (in 2 years).
|
|
"""
|
|
|
|
return body
|
|
|
|
|
|
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")
|
|
|
|
response = perform_post_request(
|
|
f"https://codeberg.org/api/v1/repos/{owner}/{repo}/issues", token, request_body
|
|
)
|
|
|
|
issue_url = response["html_url"]
|
|
issue_id = response["number"]
|
|
|
|
return issue_url, issue_id
|
|
|
|
|
|
def parse_and_update_date_received(input_date: str) -> date:
|
|
try:
|
|
parsed = date.fromisoformat(input_date)
|
|
|
|
if parsed < date.today() - timedelta(days=30):
|
|
return date.today()
|
|
|
|
return parsed
|
|
except Exception:
|
|
return date.today()
|
|
|
|
|
|
def update_fep_file_with_date_received(fep_file: FepFile, date_received: date):
|
|
fep_file.frontmatter = [
|
|
x for x in fep_file.frontmatter if not x.startswith("dateReceived")
|
|
]
|
|
fep_file.frontmatter.append(f"dateReceived: {date_received.isoformat()}")
|
|
|
|
|
|
def create_issue(owner: str, repo: str, token: str, slug: str):
|
|
fep_file = FepFile(slug)
|
|
|
|
if "trackingIssue" in fep_file.parsed_frontmatter:
|
|
print("File already has trackingIssue")
|
|
exit(1)
|
|
|
|
title = f"[TRACKING] FEP-{slug}: {fep_file.title}"
|
|
|
|
date_received = parse_and_update_date_received(
|
|
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)
|
|
|
|
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}")
|
|
|
|
fep_file.write()
|
|
|
|
print(f"Issue url: {issue_url} for {title}")
|