Skip to content

Commit 49577d5

Browse files
committed
improve error message when missing commit message for --new-pr
When creating a PR it might be accidental to update an existing file. Include the name of the updated file in the error message. For consistency also show the deleted files.
1 parent f7035e9 commit 49577d5

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

easybuild/tools/github.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,14 @@ 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']) if not new]
1042+
if modified_files:
1043+
msg += '\nModified: ' + ', '.join(modified_files)
1044+
if paths['files_to_delete']:
1045+
msg += '\nDeleted: ' + ', '.join(paths['files_to_delete'])
10401046
raise EasyBuildError("A meaningful commit message must be specified via --pr-commit-msg when "
1041-
"modifying/deleting files or targeting the framework repo.")
1047+
"modifying/deleting files or targeting the framework repo." + msg)
10421048

10431049
# figure out to which software name patches relate, and copy them to the right place
10441050
if paths['patch_files']:

test/framework/options.py

Lines changed: 2 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.*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,7 @@ 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.*" + os.path.basename(gcc_ec)
46824682
self.mock_stdout(True)
46834683
self.assertErrorRegex(EasyBuildError, error_msg, self.eb_main, args, raise_error=True)
46844684
self.mock_stdout(False)

0 commit comments

Comments
 (0)