Skip to content

Commit

Permalink
Merge pull request #3128 from dirkmueller/improve_error_message
Browse files Browse the repository at this point in the history
Improve decline message (openSUSE/scm-staging#51)
  • Loading branch information
dirkmueller committed Aug 6, 2024
2 parents 82c53af + 841a410 commit 376cbb3
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions check_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ def check_source_submission(
scm_sync = meta.find('scmsync')
if scm_sync is None:
# Not from proper devel project/package and not self-submission and not scmsync.
self.review_messages['declined'] = 'Expected submission from devel package %s/%s' % (
devel_project, devel_package)
self.review_messages['declined'] = f'Expected submission from devel package {devel_project}/{devel_package}'
return False

scm_pool_repository = f"https://src.opensuse.org/pool/{source_package}"
if not scm_sync.text.startswith(scm_pool_repository):
# devel project uses scm sync not from the trusted src location
self.review_messages['declined'] = f"Expected a devel project scm sync from {scm_pool_repository}"
self.review_messages['declined'] = (
f"devel project scmsync setting is {scm_sync.text}. Must be {scm_pool_repository} instead.")
return False
if not self.source_is_scm_staging_submission(source_project):
# Not a submission coming from the scm-sync bot
Expand All @@ -192,9 +192,9 @@ def check_source_submission(
# which indicates that the project has already been used as devel.
if not self.is_devel_project(source_project, target_project):
self.review_messages['declined'] = (
'%s is not a devel project of %s, submit the package to a devel project first. '
f'{source_project} is not a devel project of {target_project}, submit the package to a devel project first. '
'See https://en.opensuse.org/openSUSE:How_to_contribute_to_Factory#How_to_request_a_new_devel_project for details.'
) % (source_project, target_project)
)
return False
else:
if source_project.endswith(':Update'):
Expand All @@ -213,8 +213,7 @@ def check_source_submission(
# by the scm-staging bot
if not self.source_is_scm_staging_submission(source_project) and not self.source_has_required_maintainers(source_project):
declined_msg = (
'This request cannot be accepted unless %s is a maintainer of %s.' %
(self.required_maintainer, source_project)
f'This request cannot be accepted unless {self.required_maintainer} is a maintainer of {source_project}.'
)

req = self.__ensure_add_role_request(source_project)
Expand Down Expand Up @@ -259,8 +258,8 @@ def check_source_submission(
expected_name = 'preinstallimage'
if not (filename.endswith('.kiwi') or filename == 'Dockerfile') and new_info['name'] != expected_name:
shutil.rmtree(copath)
self.review_messages['declined'] = "A package submitted as %s has to build as 'Name: %s' - found Name '%s'" % (
target_package, expected_name, new_info['name'])
self.review_messages['declined'] = (
f"A package submitted as {target_package} has to build as 'Name: {expected_name}' - found Name '{new_info['name']}'")
return False

if not self.check_service_file(target_package):
Expand Down Expand Up @@ -577,8 +576,8 @@ def check_action_delete_package(self, request, action):
matches = ET.parse(osc.core.http_GET(url)).getroot()
if int(matches.attrib['matches']) > 1:
ids = [rq.attrib['id'] for rq in matches.findall('request')]
self.review_messages['declined'] = "There is a pending request %s to %s/%s in process." % (
','.join(ids), action.tgt_project, action.tgt_package)
self.review_messages['declined'] = (
f"There is a pending request {','.join(ids)} to {action.tgt_project}/{action.tgt_package} in process.")
return False

# Decline delete requests against linked flavor package
Expand Down

0 comments on commit 376cbb3

Please sign in to comment.