refactor(visibility): make repositories public by default
This commit is contained in:
1 parent
06cc3254c0
commit
aff2098f7f
4 files changed
+16
-16
No files matched your search
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
+8
-8
@@ -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()
|
||||
|
||||
+3
-3
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user