Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Ignore the 'default_branch' option #52

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion plugins/module_utils/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,12 @@
error_data[key] = info[key]

error_data["response"] = response or "no response"
error_data["body"] = body or "no body"
error_data["response_body"] = body or "no body"
error_data["request_url"] = url

Check warning on line 228 in plugins/module_utils/github.py

View check run for this annotation

otc-zuul / eco/check

plugins/module_utils/github.py#L228

pep8: E222 multiple spaces after operator
error_data["request_method"] = method

Check warning on line 229 in plugins/module_utils/github.py

View check run for this annotation

otc-zuul / eco/check

plugins/module_utils/github.py#L229

pep8: E222 multiple spaces after operator
if 'json' in kwargs:
error_data["request_body"] = kwargs['json'] or 'no body'

Check warning on line 231 in plugins/module_utils/github.py

View check run for this annotation

otc-zuul / eco/check

plugins/module_utils/github.py#L231

pep8: E222 multiple spaces after operator

self.save_error(f"request failed {error_msg}: {error_data}")
elif status == 404 and ignore_missing:
return None
Expand Down Expand Up @@ -1126,7 +1131,16 @@
owner = kwargs.pop('owner')
repo_name = kwargs.pop('name')
current_repo = current if current else self.get_repo(owner, repo_name, ignore_missing=True)

# When specifying a default branch on a repository which is still empty, the execution
# fails with the following error message:
# 'Cannot update default branch for an empty repository. Please init the repository and push first'
# Therefore we remove this option in that case.
if current_repo['size'] == 0:
del kwargs['default_branch']
scoopex marked this conversation as resolved.
Show resolved Hide resolved


if not current_repo:

Check warning on line 1143 in plugins/module_utils/github.py

View check run for this annotation

otc-zuul / eco/check

plugins/module_utils/github.py#L1143

pep8: E303 too many blank lines (2)
changed = True
if not check_mode:
current_repo = self.create_repo(
Expand Down