Skip to content

Commit b9c70d8

Browse files
authored
Merge pull request #4640 from Flamefire/error-new-pr
improve error message for `--new-pr` when missing commit message
2 parents 3d29b0a + cf03257 commit b9c70d8

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

easybuild/tools/github.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,15 @@ def _easyconfigs_pr_common(paths, ecs, start_branch=None, pr_branch=None, start_
10371037
elif pr_target_repo == GITHUB_EASYBLOCKS_REPO and all(file_info['new']):
10381038
commit_msg = "adding easyblocks: %s" % ', '.join(os.path.basename(p) for p in file_info['paths_in_repo'])
10391039
else:
1040+
msg = ''
1041+
modified_files = [os.path.basename(p) for new, p in zip(file_info['new'], file_info['paths_in_repo'])
1042+
if not new]
1043+
if modified_files:
1044+
msg += '\nModified: ' + ', '.join(modified_files)
1045+
if paths['files_to_delete']:
1046+
msg += '\nDeleted: ' + ', '.join(paths['files_to_delete'])
10401047
raise EasyBuildError("A meaningful commit message must be specified via --pr-commit-msg when "
1041-
"modifying/deleting files or targeting the framework repo.")
1048+
"modifying/deleting files or targeting the framework repo." + msg)
10421049

10431050
# figure out to which software name patches relate, and copy them to the right place
10441051
if paths['patch_files']:
@@ -1078,8 +1085,8 @@ def _easyconfigs_pr_common(paths, ecs, start_branch=None, pr_branch=None, start_
10781085
# only consider new easyconfig files for dependencies (not updated ones)
10791086
for idx in range(len(all_dep_info['ecs'])):
10801087
if all_dep_info['new'][idx]:
1081-
for key in dep_info:
1082-
dep_info[key].append(all_dep_info[key][idx])
1088+
for key, info in dep_info.items():
1089+
info.append(all_dep_info[key][idx])
10831090

10841091
# checkout target branch
10851092
if pr_branch is None:
@@ -1692,7 +1699,7 @@ def post_pr_labels(pr, labels):
16921699

16931700
pr_url = g.repos[pr_target_account][pr_target_repo].issues[pr]
16941701
try:
1695-
status, data = pr_url.labels.post(body=labels)
1702+
status, _ = pr_url.labels.post(body=labels)
16961703
if status == HTTP_STATUS_OK:
16971704
print_msg("Added labels %s to PR#%s" % (', '.join(labels), pr), log=_log, prefix=False)
16981705
return True
@@ -1991,9 +1998,9 @@ def new_pr(paths, ecs, title=None, descr=None, commit_msg=None):
19911998
patch = patch[0]
19921999
elif isinstance(patch, dict):
19932000
patch_info = {}
1994-
for key in patch.keys():
1995-
patch_info[key] = patch[key]
1996-
if 'name' not in patch_info.keys():
2001+
for key, cur_patch in patch.items():
2002+
patch_info[key] = cur_patch
2003+
if 'name' not in patch_info:
19972004
raise EasyBuildError("Wrong patch spec '%s', when using a dict 'name' entry must be supplied",
19982005
str(patch))
19992006
patch = patch_info['name']

test/framework/options.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4599,7 +4599,7 @@ def test_github_new_update_pr(self):
45994599
'--git-working-dirs-path=%s' % git_working_dir,
46004600
':bzip2-1.0.6.eb',
46014601
])
4602-
error_msg = "A meaningful commit message must be specified via --pr-commit-msg"
4602+
error_msg = "A meaningful commit message must be specified via --pr-commit-msg.*\nDeleted: bzip2-1.0.6.eb"
46034603

46044604
self.mock_stdout(True)
46054605
self.assertErrorRegex(EasyBuildError, error_msg, self.eb_main, args, raise_error=True, testing=False)
@@ -4678,7 +4678,8 @@ def test_github_new_update_pr(self):
46784678
gcc_ec,
46794679
'-D',
46804680
]
4681-
error_msg = "A meaningful commit message must be specified via --pr-commit-msg"
4681+
error_msg = "A meaningful commit message must be specified via --pr-commit-msg.*\n"
4682+
error_msg += "Modified: " + os.path.basename(gcc_ec)
46824683
self.mock_stdout(True)
46834684
self.assertErrorRegex(EasyBuildError, error_msg, self.eb_main, args, raise_error=True)
46844685
self.mock_stdout(False)

0 commit comments

Comments
 (0)