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 all 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
11 changes: 11 additions & 0 deletions easybuild/tools/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,9 @@ def setup_repo_from(git_repo, github_url, target_account, branch_name, silent=Fa
"""
_log.debug("Cloning from %s", github_url)

if target_account is None:
raise EasyBuildError("target_account not specified in setup_repo_from!")

# salt to use for names of remotes/branches that are created
salt = ''.join(random.choice(ascii_letters) for _ in range(5))

Expand All @@ -688,10 +691,12 @@ 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()
except GitCommandError as err:
raise EasyBuildError("Failed to fetch branch '%s' from %s: %s", branch_name, github_url, err)

if res:
if res[0].flags & res[0].ERROR:
raise EasyBuildError("Fetching branch '%s' from remote %s failed: %s", branch_name, origin, res[0].note)
Expand Down Expand Up @@ -807,6 +812,10 @@ def _easyconfigs_pr_common(paths, ecs, start_branch=None, pr_branch=None, start_
# if start branch is not specified, we're opening a new PR
# account to use is determined by active EasyBuild configuration (--github-org or --github-user)
target_account = build_option('github_org') or build_option('github_user')

if target_account is None:
raise EasyBuildError("--github-org or --github-user must be specified!")

# if branch to start from is specified, we're updating an existing PR
start_branch = build_option('pr_target_branch')
else:
Expand Down Expand Up @@ -959,6 +968,8 @@ def push_branch_to_github(git_repo, target_account, target_repo, branch):
:param target_repo: repository name
:param branch: name of branch to push
"""
if target_account is None:
raise EasyBuildError("target_account not specified in push_branch_to_github!")

# push to GitHub
remote = create_remote(git_repo, target_account, target_repo)
Expand Down