Add project management and GitHub source support
Deploy production / deploy (push) Successful in 5s

This commit is contained in:
2026-08-13 17:47:26 -07:00
parent 14640faa15
commit ddf7234c9d
14 changed files with 7310 additions and 39 deletions
+51
View File
@@ -13,6 +13,7 @@ from project_sources import ( # noqa: E402
ProjectSourceError,
RepositoryNotPublicError,
append_fields,
collect_metadata,
fetch_json,
load_registry,
metadata_digest,
@@ -68,6 +69,21 @@ class ProjectSourceTests(unittest.TestCase):
with self.assertRaises(RepositoryNotPublicError):
fetch_json("https://git.example.test/api/repo", require_public=True)
def test_github_anonymous_rate_limit_is_not_reported_as_private(self) -> None:
error = HTTPError(
"https://api.github.com/repos/example/project",
403,
"Forbidden",
{"X-RateLimit-Remaining": "0"},
None,
)
with patch("project_sources.urlopen", side_effect=error):
with self.assertRaisesRegex(ProjectSourceError, "rate limit"):
fetch_json(
"https://api.github.com/repos/example/project",
require_public=True,
)
def test_unapproved_labels_remain_visible_without_becoming_tags(self) -> None:
items = taxonomy_label_items(
["TypeScript", "Unlisted Tool"], ["typescript"]
@@ -78,6 +94,41 @@ class ProjectSourceTests(unittest.TestCase):
self.assertEqual(normalize_tag_value("v0.4.0"), "v0-4-0")
self.assertEqual(normalize_tag_value("OpenAI Build Week"), "openai-build-week")
def test_github_public_metadata_is_normalized_for_project_templates(self) -> None:
source = {
"project_id": "example",
"repository": "https://github.com/example/project.git",
"web_url": "https://github.com/example/project",
"api_url": "https://api.github.com/repos/example/project",
"branch": "main",
}
responses = (
{
"private": False,
"default_branch": "main",
"open_issues_count": 7,
"stargazers_count": 42,
"forks_count": 5,
},
{"Python": 100, "JavaScript": 25},
{"tag_name": "v1.0.0", "html_url": "https://github.com/example/project/releases/tag/v1.0.0"},
)
with (
patch("project_sources.commit_metadata", return_value={"commit": "a" * 40}),
patch("project_sources.detect_license", return_value="MIT"),
patch("project_sources.fetch_json", side_effect=responses),
):
metadata, current = collect_metadata(source, Path("unused.git"), "a" * 40, None)
self.assertTrue(current)
self.assertEqual(metadata["stars"], 42)
self.assertEqual(metadata["forks"], 5)
self.assertEqual(metadata["languages"], ["Python", "JavaScript"])
self.assertEqual(
metadata["readme_url"],
"https://github.com/example/project/blob/main/README.md",
)
if __name__ == "__main__":
unittest.main()