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

--new-pr can't be empty #1846

Merged
merged 4 commits into from
Aug 4, 2016
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions easybuild/tools/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,9 @@ def _easyconfigs_pr_common(paths, start_branch=None, pr_branch=None, target_acco
print_msg(git_repo.git.diff(cached=True) + '\n', log=_log, prefix=False)

diff_stat = git_repo.git.diff(cached=True, stat=True)
if not diff_stat:
raise EasyBuildError("No changed files found when comparing to current develop branch."
"Refused to make empty pull request.")

# commit
if commit_msg:
Expand Down
30 changes: 29 additions & 1 deletion test/framework/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
from easybuild.tools.config import DEFAULT_MODULECLASSES
from easybuild.tools.config import find_last_log, get_build_log_path, get_module_syntax, module_classes
from easybuild.tools.environment import modify_env
from easybuild.tools.filetools import mkdir, read_file, write_file
from easybuild.tools.filetools import download_file, mkdir, read_file, write_file
from easybuild.tools.github import GITHUB_RAW, GITHUB_EB_MAIN, GITHUB_EASYCONFIGS_REPO, URL_SEPARATOR
from easybuild.tools.github import fetch_github_token
from easybuild.tools.options import EasyBuildOptions, parse_external_modules_metadata, set_tmpdir
from easybuild.tools.toolchain.utilities import TC_CONST_PREFIX
Expand Down Expand Up @@ -2350,6 +2351,33 @@ def test_new_update_pr(self):
regex = re.compile(regex, re.M)
self.assertTrue(regex.search(txt), "Pattern '%s' found in: %s" % (regex.pattern, txt))

def test_empty_pr(self):
"""Test use of --new-pr (dry run only) with no changes"""
if self.github_token is None:
print "Skipping test_empty_pr, no GitHub token available?"
return

# get file from develop branch
full_url = URL_SEPARATOR.join([GITHUB_RAW, GITHUB_EB_MAIN, GITHUB_EASYCONFIGS_REPO,
'develop/easybuild/easyconfigs/z/zlib/zlib-1.2.8.eb'])
ec_fn = os.path.basename(full_url)
ec = download_file(ec_fn, full_url, path=os.path.join(self.test_prefix, ec_fn))

# try to open new pr with unchanged file
args = [
'--new-pr',
'--experimental',
ec,
'-D',
'--github-user=%s' % GITHUB_TEST_ACCOUNT,
]

self.mock_stdout(True)
error_msg = "No changed files found when comparing to current develop branch."
self.assertErrorRegex(EasyBuildError, error_msg, self.eb_main, args, do_build=True, raise_error=True)
self.mock_stdout(False)


def test_show_config(self):
""""Test --show-config and --show-full-config."""

Expand Down