From aff2098f7f7fb6c7aabba7919be0e62f6f3e7e48 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Thu, 22 Oct 2026 17:24:34 -0500 Subject: [PATCH] refactor(visibility): make repositories public by default --- README.md | 8 ++++---- docs/adr/0006-gitea-organization-binding.md | 2 +- new_repo.py | 16 ++++++++-------- test_new_repo.py | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index da89572..4f275be 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Options: -o, --org ORG Target Gitea organization to own the repository (auto-created if missing) --github-org ORG Optional GitHub organization for the offsite backup mirror (defaults to personal GITHUB_USER) --migrate [URL] Migrate an existing GitHub repo to Gitea with automated push mirroring (URL or auto-detect from local origin) - -p, --public Make repository public (default: private) + -p, --private Make repository private (default: public) -d, --description Optional repository description string -l, --license License template identifier (default: UNLICENSE, pass "" to disable) -t, --template Optional Gitea template repository ('[owner/]template-name') @@ -50,7 +50,7 @@ Options: ### Examples ```bash -# 1. Standard greenfield creation (Private Gitea + GitHub push mirror + UNLICENSE + auto-clone) +# 1. Standard greenfield creation (Public Gitea + GitHub push mirror + UNLICENSE + auto-clone) new-repo service-api # 2. Provision under a Gitea organization (via shorthand or -o/--org flag; auto-creates org if missing) @@ -67,8 +67,8 @@ new-repo web-client --template template-react-app # 5. Local-only repository (no GitHub mirror) new-repo private-notes --no-mirror -# 6. Public open-source repository with MIT license -new-repo utility-lib --public --license MIT +# 6. Private repository with MIT license +new-repo utility-lib --private --license MIT # 7. Migrate an existing GitHub repository to Gitea (personal or organization) with push mirror new-repo --migrate https://github.com/my-org/existing-service diff --git a/docs/adr/0006-gitea-organization-binding.md b/docs/adr/0006-gitea-organization-binding.md index dedf6ad..a3d5ec5 100644 --- a/docs/adr/0006-gitea-organization-binding.md +++ b/docs/adr/0006-gitea-organization-binding.md @@ -17,7 +17,7 @@ We extend `new-repo` to support binding repositories to a Gitea organization acr 2. **Automatic Organization Provisioning on Gitea**: - Before provisioning or migrating a repository under a target organization, `new-repo` checks whether the organization exists via `GET /api/v1/orgs/{org}`. - - If the organization returns `404 Not Found`, `new-repo` automatically provisions it via `POST /api/v1/orgs` with visibility matching the repository's privacy flag (`private` by default, or `public` when `--public` is passed). + - If the organization returns `404 Not Found`, `new-repo` automatically provisions it via `POST /api/v1/orgs` with visibility matching the repository's privacy flag (`public` by default, or `private` when `--private` is passed). 3. **Endpoint Routing Across Workflows**: - **Standard & Existing Git Creation**: Routes to `POST /api/v1/orgs/{org}/repos` when an organization is specified, or `POST /api/v1/user/repos` otherwise. diff --git a/new_repo.py b/new_repo.py index 5d671e3..17203d1 100755 --- a/new_repo.py +++ b/new_repo.py @@ -304,7 +304,7 @@ class GiteaClient: } return self._request("POST", "/api/v1/orgs", payload) - def ensure_org(self, org: str, private: bool = True) -> bool: + def ensure_org(self, org: str, private: bool = False) -> bool: """Ensure a Gitea organization exists, creating it if missing. Returns: @@ -325,7 +325,7 @@ class GiteaClient: def create_repo( self, name: str, - private: bool = True, + private: bool = False, description: str = "", auto_init: bool = True, license_name: str = "UNLICENSE", @@ -350,7 +350,7 @@ class GiteaClient: template_owner: str, template_name: str, name: str, - private: bool = True, + private: bool = False, description: str = "", owner: str | None = None, ) -> dict[str, Any]: @@ -393,7 +393,7 @@ class GiteaClient: clone_addr: str, repo_name: str, github_token: str, - private: bool = True, + private: bool = False, description: str = "", repo_owner: str | None = None, ) -> dict[str, Any]: @@ -448,7 +448,7 @@ class GitHubClient: def create_empty_repo( self, name: str, - private: bool = True, + private: bool = False, description: str = "", org: str | None = None, ) -> dict[str, Any]: @@ -805,10 +805,10 @@ def parse_args() -> argparse.Namespace: ) parser.add_argument( "-p", - "--public", + "--private", action="store_true", default=False, - help="Make repository public (default: private)", + help="Make repository private (default: public)", ) parser.add_argument( "-d", @@ -858,7 +858,7 @@ def parse_args() -> argparse.Namespace: def main() -> None: """Main orchestration flow.""" args = parse_args() - is_private: bool = not args.public + is_private: bool = args.private # 1. Resolve Credentials creds = SecretProvider.resolve() diff --git a/test_new_repo.py b/test_new_repo.py index 2ffde5f..f3e3dfe 100755 --- a/test_new_repo.py +++ b/test_new_repo.py @@ -32,7 +32,7 @@ class TestArgParsing(unittest.TestCase): self.assertEqual(args.name, "sample-project") self.assertIsNone(args.org) self.assertIsNone(args.github_org) - self.assertFalse(args.public) + self.assertFalse(args.private) self.assertEqual(args.license, "UNLICENSE") self.assertIsNone(args.template) self.assertFalse(args.no_mirror) @@ -67,7 +67,7 @@ class TestArgParsing(unittest.TestCase): "homelab", "--github-org", "homelab-gh", - "--public", + "--private", "-d", "My public API", "-l", @@ -81,7 +81,7 @@ class TestArgParsing(unittest.TestCase): self.assertEqual(args.name, "open-api") self.assertEqual(args.org, "homelab") self.assertEqual(args.github_org, "homelab-gh") - self.assertTrue(args.public) + self.assertTrue(args.private) self.assertEqual(args.description, "My public API") self.assertEqual(args.license, "MIT") self.assertEqual(args.template, "template-fastapi")