allow github projects with "." in their name

This commit is contained in:
phaer 2023-10-26 14:54:01 +02:00 committed by Mic92
parent eac9acc041
commit 2edf6860b0
2 changed files with 8 additions and 4 deletions

View file

@ -25,6 +25,7 @@ from .github_projects import ( # noqa: E402
create_project_hook, create_project_hook,
load_projects, load_projects,
refresh_projects, refresh_projects,
slugify_project_name
) )
from twisted.internet import defer, threads from twisted.internet import defer, threads
from twisted.python.failure import Failure from twisted.python.failure import Failure
@ -63,7 +64,7 @@ class BuildTrigger(Trigger):
"github.base.repo.full_name", "github.base.repo.full_name",
build_props.getProperty("github.repository.full_name"), build_props.getProperty("github.repository.full_name"),
) )
project_id = repo_name.replace("/", "-") project_id = slugify_project_name(repo_name)
source = f"nix-eval-{project_id}" source = f"nix-eval-{project_id}"
sch = self.schedulerNames[0] sch = self.schedulerNames[0]
@ -151,7 +152,7 @@ class NixEvalCommand(buildstep.ShellMixin, steps.BuildStep):
"github.base.repo.full_name", "github.base.repo.full_name",
build_props.getProperty("github.repository.full_name"), build_props.getProperty("github.repository.full_name"),
) )
project_id = repo_name.replace("/", "-") project_id = slugify_project_name(repo_name)
scheduler = f"{project_id}-nix-build" scheduler = f"{project_id}-nix-build"
filtered_jobs = [] filtered_jobs = []
for job in jobs: for job in jobs:

View file

@ -69,6 +69,10 @@ def paginated_github_request(url: str, token: str) -> list[dict[str, Any]]:
return items return items
def slugify_project_name(name: str) -> str:
return name.replace(".", "-").replace("/", "-")
class GithubProject: class GithubProject:
def __init__(self, data: dict[str, Any]) -> None: def __init__(self, data: dict[str, Any]) -> None:
self.data = data self.data = data
@ -91,8 +95,7 @@ class GithubProject:
@property @property
def id(self) -> str: def id(self) -> str:
n = self.data["full_name"] return slugify_project_name(self.data["full_name"])
return n.replace("/", "-")
@property @property
def default_branch(self) -> str: def default_branch(self) -> str: