From: Simon Glass <simon.glass@canonical.com>
Some patchwork instances return project names with trailing whitespace,
which causes the exact string match to fail. Strip whitespace before
comparing.
Also add debug logging to show the projects being checked and which
one matches, to help diagnose future issues.
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
tools/patman/control.py | 2 +-
tools/patman/cseries.py | 13 +++++++++----
tools/patman/test_cseries.py | 8 ++++----
3 files changed, 14 insertions(+), 9 deletions(-)
@@ -273,7 +273,7 @@ def patchwork(args, test_db=None, pwork=None):
if not info:
raise ValueError("Project has not been set; use 'patman patchwork set-project'")
name, pwid, link_name = info
- print(f"Project '{name}' patchwork-ID {pwid} link-name {link_name}")
+ print(f"Project '{name}' patchwork-ID {pwid} link-name '{link_name}'")
else:
raise ValueError(f"Unknown patchwork subcommand '{args.subcmd}'")
finally:
@@ -634,20 +634,25 @@ class Cseries(cser_helper.CseriesHelper):
name (str): Name of the project to use in patchwork
quiet (bool): True to skip writing the message
"""
+ tout.detail(f"Patchwork URL '{pwork.url}': finding name '{name}'")
res = self.loop.run_until_complete(pwork.get_projects())
proj_id = None
link_name = None
for proj in res:
- if proj['name'] == name:
- proj_id = proj['id']
+ pid, pname = proj['id'], proj['name']
+ ok = pname.strip() == name
+ tout.detail(f"{pid:3} '{pname}'")
+ if ok:
+ proj_id = pid
link_name = proj['link_name']
+ tout.detail(f'Name match: ID {proj_id}')
if not proj_id:
raise ValueError(f"Unknown project name '{name}'")
self.db.settings_update(name, proj_id, link_name)
self.commit()
if not quiet:
- tout.info(f"Project '{name}' patchwork-ID {proj_id} "
- f'link-name {link_name}')
+ tout.notice(f"Project '{name}' patchwork-ID {proj_id} "
+ f"link-name '{link_name}'")
def project_get(self):
"""Get the details of the project
@@ -2389,7 +2389,7 @@ Tested-by: Mary Smith <msmith@wibble.com> # yak
with terminal.capture() as (out, _):
cser.project_set(pwork, 'U-Boot')
self.assertEqual(
- f"Project 'U-Boot' patchwork-ID {self.PROJ_ID} link-name uboot",
+ f"Project 'U-Boot' patchwork-ID {self.PROJ_ID} link-name 'uboot'",
out.getvalue().strip())
def test_patchwork_project_get(self):
@@ -2400,7 +2400,7 @@ Tested-by: Mary Smith <msmith@wibble.com> # yak
with terminal.capture() as (out, _):
cser.project_set(pwork, 'U-Boot')
self.assertEqual(
- f"Project 'U-Boot' patchwork-ID {self.PROJ_ID} link-name uboot",
+ f"Project 'U-Boot' patchwork-ID {self.PROJ_ID} link-name 'uboot'",
out.getvalue().strip())
name, pwid, link_name = cser.project_get()
@@ -2419,7 +2419,7 @@ Tested-by: Mary Smith <msmith@wibble.com> # yak
self.run_args('-P', 'https://url', 'patchwork', 'set-project',
'U-Boot', pwork=pwork)
self.assertEqual(
- f"Project 'U-Boot' patchwork-ID {self.PROJ_ID} link-name uboot",
+ f"Project 'U-Boot' patchwork-ID {self.PROJ_ID} link-name 'uboot'",
out.getvalue().strip())
name, pwid, link_name = cser.project_get()
@@ -2430,7 +2430,7 @@ Tested-by: Mary Smith <msmith@wibble.com> # yak
with terminal.capture() as (out, _):
self.run_args('-P', 'https://url', 'patchwork', 'get-project')
self.assertEqual(
- f"Project 'U-Boot' patchwork-ID {self.PROJ_ID} link-name uboot",
+ f"Project 'U-Boot' patchwork-ID {self.PROJ_ID} link-name 'uboot'",
out.getvalue().strip())
def check_series_list_patches(self):