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 de1f661 Augment the Project type and fix some project related bugs
de1f661 is described below
commit de1f661cc990878668bfc453a52fb5b45ad55871
Author: Sean B. Palmer <[email protected]>
AuthorDate: Thu Apr 10 16:54:50 2025 +0100
Augment the Project type and fix some project related bugs
- Adds Project.created and Project.created_by for provenance.
- Fixes a problem getting remote project data.
- Fixes overly strict validation of project names before rsync.
---
atr/datasources/apache.py | 4 ++--
atr/db/models.py | 3 +++
atr/routes/projects.py | 8 +++++---
atr/ssh.py | 4 ++--
4 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/atr/datasources/apache.py b/atr/datasources/apache.py
index 0051f61..7ad6112 100644
--- a/atr/datasources/apache.py
+++ b/atr/datasources/apache.py
@@ -79,7 +79,7 @@ class Committee(pydantic.BaseModel):
name: str
display_name: str
site: str | None
- description: str
+ description: str | None
mail_list: str
established: str | None
report: list[str]
@@ -99,7 +99,7 @@ class RetiredCommittee(pydantic.BaseModel):
name: str
display_name: str
retired: str
- description: str
+ description: str | None
class PodlingStatus(pydantic.BaseModel):
diff --git a/atr/db/models.py b/atr/db/models.py
index 9e9f187..7e2a656 100644
--- a/atr/db/models.py
+++ b/atr/db/models.py
@@ -175,6 +175,9 @@ class Project(sqlmodel.SQLModel, table=True):
cascade_delete=True, sa_relationship_kwargs={"cascade": "all,
delete-orphan", "single_parent": True}
)
+ created: datetime.datetime = sqlmodel.Field(default_factory=lambda:
datetime.datetime.now(datetime.UTC))
+ created_by: str | None = sqlmodel.Field(default=None)
+
@property
def display_name(self) -> str:
"""Get the display name for the Project."""
diff --git a/atr/routes/projects.py b/atr/routes/projects.py
index e9032c7..4d8740b 100644
--- a/atr/routes/projects.py
+++ b/atr/routes/projects.py
@@ -17,6 +17,7 @@
"""project.py"""
+import datetime
import http.client
import re
from typing import Protocol
@@ -62,12 +63,12 @@ async def add(session: routes.CommitterSession) ->
response.Response | str:
form = await AddForm.create_form()
if await form.validate_on_submit():
- return await _add_project(form)
+ return await _add_project(form, session.uid)
return await quart.render_template("project-add.html", form=form)
-async def _add_project(form: AddFormProtocol) -> response.Response:
+async def _add_project(form: AddFormProtocol, asf_id: str) ->
response.Response:
base_project_name = str(form.project_name.data)
derived_project_name = str(form.derived_project_name.data).strip()
@@ -122,7 +123,8 @@ async def _add_project(form: AddFormProtocol) ->
response.Response:
programming_languages=base_project.programming_languages,
committee_id=base_project.committee_id,
vote_policy_id=base_project.vote_policy_id,
- # TODO: Add "created" and "created_by" to models.Project perhaps?
+ created=datetime.datetime.now(datetime.UTC),
+ created_by=asf_id,
)
data.add(project)
diff --git a/atr/ssh.py b/atr/ssh.py
index dc007d6..2d7c769 100644
--- a/atr/ssh.py
+++ b/atr/ssh.py
@@ -148,9 +148,9 @@ def _command_path_validate(path: str) -> tuple[str, str] |
str:
return "The fifth argument should be a /PROJECT/VERSION/ directory
path"
path_project, path_version = path.strip("/").split("/", 1)
- alphanum = set(string.ascii_letters + string.digits)
+ alphanum = set(string.ascii_letters + string.digits + "-")
if not all(c in alphanum for c in path_project):
- return "The project name should contain only alphanumeric characters"
+ return "The project name should contain only alphanumeric characters
or hyphens"
# From a survey of version numbers we find that only . and - are used
# We also allow + which is in common use
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]