Skip to content

Commit

Permalink
fix: support creating a repo with auto_init disabled and gh_pages_bui…
Browse files Browse the repository at this point in the history
…ld_type disabled as well
  • Loading branch information
netomi committed Oct 1, 2024
1 parent ed7ef5c commit 428b79a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

### Fixed

- Creating a repo with `auto_init: false` and `gh_pages_build_type: "disabled"` is now supported.
- Avoided unnecessary GitHub API calls when getting the `default_branch` or `id` of a repository.
- Detect errors during an automatic `apply` operation and add a corresponding comment to the pull request.
- Support showing dialog windows when using operation `web-login`.
Expand Down
4 changes: 4 additions & 0 deletions otterdog/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,10 @@ async def get_mapping_to_provider(
if len(gh_pages_mapping) > 0:
mapping["gh_pages"] = gh_pages_mapping

for prop in ["gh_pages_source_branch", "gh_pages_source_path"]:
if prop in mapping:
mapping.pop(prop)

# code scanning default setup
code_scanning_mapping = {}
if "code_scanning_default_setup_enabled" in data:
Expand Down
8 changes: 8 additions & 0 deletions otterdog/providers/github/rest/repo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ async def add_repo(
# whether the repo should be initialized with an empty README
data["auto_init"] = auto_init_repo

# if the repo does not get initialized and gh pages are disabled,
# do not try to update the config as it will fail
if auto_init_repo is False and "gh_pages" in update_data:
gh_pages = update_data.get("gh_pages", {})
build_type = gh_pages.get("build_type")
if build_type == "disabled":
update_data.pop("gh_pages")

try:
result = await self.requester.request_json("POST", f"/orgs/{org_id}/repos", data)
print_debug(f"created repo with name '{repo_name}'")
Expand Down

0 comments on commit 428b79a

Please sign in to comment.