Compare commits
1
Commits
f2613b0b3a
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81f155105b |
No files matched your search
@@ -44,6 +44,7 @@ Options:
|
|||||||
-t, --template Optional GitHub template repository ('[owner/]template-name')
|
-t, --template Optional GitHub template repository ('[owner/]template-name')
|
||||||
-M, --no-mirror Disable automatic homelab pull mirroring to Gitea
|
-M, --no-mirror Disable automatic homelab pull mirroring to Gitea
|
||||||
--no-clone Skip cloning the repository locally after creation
|
--no-clone Skip cloning the repository locally after creation
|
||||||
|
--empty Create an empty GitHub repository with auto_init=False (no initial commit)
|
||||||
--as PERSONA Persona / login identity to provision as (e.g. anneux)
|
--as PERSONA Persona / login identity to provision as (e.g. anneux)
|
||||||
-h, --help Show help message and exit
|
-h, --help Show help message and exit
|
||||||
```
|
```
|
||||||
|
|||||||
+13
-5
@@ -1086,6 +1086,12 @@ def parse_args() -> argparse.Namespace:
|
|||||||
default=False,
|
default=False,
|
||||||
help="Skip cloning the repository locally after creation",
|
help="Skip cloning the repository locally after creation",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--empty",
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
help="Create an empty GitHub repository with auto_init=False (no initial README or license commit)",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--as",
|
"--as",
|
||||||
dest="as_persona",
|
dest="as_persona",
|
||||||
@@ -1240,19 +1246,21 @@ def main() -> None:
|
|||||||
print(f" Mode: Greenfield creation at '{target_dir}'")
|
print(f" Mode: Greenfield creation at '{target_dir}'")
|
||||||
|
|
||||||
# 2. Provision GitHub Primary Repository
|
# 2. Provision GitHub Primary Repository
|
||||||
|
if args.empty and args.template:
|
||||||
|
print("❌ Error: --empty cannot be combined with --template.", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
github_html_url: str
|
github_html_url: str
|
||||||
github_ssh_url: str
|
github_ssh_url: str
|
||||||
try:
|
try:
|
||||||
if is_existing_git:
|
if is_existing_git or args.empty:
|
||||||
print(
|
print(
|
||||||
"🏗️ Creating empty primary repository on GitHub (preserving local history)..."
|
"🏗️ Creating empty primary repository on GitHub (auto_init=False)..."
|
||||||
)
|
)
|
||||||
res = github_client.create_repo(
|
res = github_client.create_empty_repo(
|
||||||
name=repo_name,
|
name=repo_name,
|
||||||
private=is_private,
|
private=is_private,
|
||||||
description=args.description,
|
description=args.description,
|
||||||
auto_init=False,
|
|
||||||
license_template="",
|
|
||||||
org=target_org,
|
org=target_org,
|
||||||
)
|
)
|
||||||
elif args.template:
|
elif args.template:
|
||||||
|
|||||||
@@ -43,9 +43,19 @@ class TestArgParsing(unittest.TestCase):
|
|||||||
self.assertIsNone(args.template)
|
self.assertIsNone(args.template)
|
||||||
self.assertFalse(args.no_mirror)
|
self.assertFalse(args.no_mirror)
|
||||||
self.assertFalse(args.no_clone)
|
self.assertFalse(args.no_clone)
|
||||||
|
self.assertFalse(args.empty)
|
||||||
self.assertIsNone(args.as_persona)
|
self.assertIsNone(args.as_persona)
|
||||||
self.assertIsNone(args.gitea_mirror)
|
self.assertIsNone(args.gitea_mirror)
|
||||||
|
|
||||||
|
def test_empty_argument(self) -> None:
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.argv = ["new-repo", "sample-project", "--empty", "--no-mirror", "--no-clone"]
|
||||||
|
args = parse_args()
|
||||||
|
self.assertTrue(args.empty)
|
||||||
|
self.assertTrue(args.no_mirror)
|
||||||
|
self.assertTrue(args.no_clone)
|
||||||
|
|
||||||
def test_as_persona_argument(self) -> None:
|
def test_as_persona_argument(self) -> None:
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user