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

Catch problems early on if --github-user is not specified for --new-pr & co #3644

Merged
merged 5 commits into from
Apr 10, 2021
Merged
Changes from 2 commits
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
33 changes: 19 additions & 14 deletions easybuild/tools/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,10 @@ def setup_repo_from(git_repo, github_url, target_account, branch_name, silent=Fa
# git fetch
# can't use --depth to only fetch a shallow copy, since pushing to another repo from a shallow copy doesn't work
print_msg("fetching branch '%s' from %s..." % (branch_name, github_url), silent=silent)
res = None
try:
res = origin.fetch()
if target_account is not None:
res = origin.fetch()
except GitCommandError as err:
raise EasyBuildError("Failed to fetch branch '%s' from %s: %s", branch_name, github_url, err)
if res:
Expand Down Expand Up @@ -971,21 +973,24 @@ def push_branch_to_github(git_repo, target_account, target_repo, branch):
if dry_run:
print_msg(push_branch_msg + ' [DRY RUN]', log=_log)
else:
print_msg(push_branch_msg, log=_log)
try:
res = remote.push(branch)
except GitCommandError as err:
raise EasyBuildError("Failed to push branch '%s' to GitHub (%s): %s", branch, github_url, err)
if target_account is None:
raise EasyBuildError("No valid GitHub username (--github-user) given, pushing branch will fail!")
ocaisa marked this conversation as resolved.
Show resolved Hide resolved
else:
print_msg(push_branch_msg, log=_log)
try:
res = remote.push(branch)
except GitCommandError as err:
raise EasyBuildError("Failed to push branch '%s' to GitHub (%s): %s", branch, github_url, err)

if res:
if res[0].ERROR & res[0].flags:
raise EasyBuildError("Pushing branch '%s' to remote %s (%s) failed: %s",
branch, remote, github_url, res[0].summary)
if res:
if res[0].ERROR & res[0].flags:
raise EasyBuildError("Pushing branch '%s' to remote %s (%s) failed: %s",
branch, remote, github_url, res[0].summary)
else:
_log.debug("Pushed branch %s to remote %s (%s): %s", branch, remote, github_url, res[0].summary)
else:
_log.debug("Pushed branch %s to remote %s (%s): %s", branch, remote, github_url, res[0].summary)
else:
raise EasyBuildError("Pushing branch '%s' to remote %s (%s) failed: empty result",
branch, remote, github_url)
raise EasyBuildError("Pushing branch '%s' to remote %s (%s) failed: empty result",
branch, remote, github_url)


def is_patch_for(patch_name, ec):
Expand Down