diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 1848591..d1c3be2 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -23,8 +23,13 @@ jobs: with: python-version: '3.11' + - uses: astral-sh/ruff-action@v3 + - name: Ruff lint - uses: chartboost/ruff-action@v1 + run: ruff check . + + - name: Ruff fmt + run: ruff format . build: name: Build diff --git a/src/github_rest_cli/api.py b/src/github_rest_cli/api.py index 4e16de8..b42cc26 100644 --- a/src/github_rest_cli/api.py +++ b/src/github_rest_cli/api.py @@ -70,16 +70,19 @@ def get_repository(name: str, org: str = None): return None -def create_repository(name: str, visibility: str, org: str = None): +def create_repository(name: str, visibility: str, org: str = None, empty: bool = False): data = { "name": name, - "auto_init": "true", "visibility": visibility, + "auto_init": True, } if visibility == "private": data["private"] = True + if empty: + data["auto_init"] = False + owner = fetch_user() headers = get_headers() url = build_url("orgs", org, "repos") if org else build_url("user", "repos") diff --git a/src/github_rest_cli/main.py b/src/github_rest_cli/main.py index 8feea5b..4e5a4fb 100644 --- a/src/github_rest_cli/main.py +++ b/src/github_rest_cli/main.py @@ -103,6 +103,14 @@ def cli(): dest="org", help="The organization name", ) + create_repo_parser.add_argument( + "-e", + "--empty", + required=False, + action="store_true", + dest="empty", + help="Create an empty repository", + ) create_repo_parser.set_defaults(func=create_repository) # Subparser for "delete-repository" function @@ -197,7 +205,7 @@ def cli(): elif command == "list-repo": args.func(args.page, args.sort, args.role) elif command == "create-repo": - args.func(args.name, args.visibility, args.org) + args.func(args.name, args.visibility, args.org, args.empty) elif command == "delete-repo": args.func(args.name, args.org) elif command == "dependabot":