Instead of skipping patch delegation when there are no Patchwork users associated with the email of the first maintainer, try to delegate to other tree maintainers. Suggested-by: David Marchand <david.marchand@redhat.com> Signed-off-by: Ali Alnubani <alialnu@nvidia.com> --- tools/pw_maintainers_cli.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tools/pw_maintainers_cli.py b/tools/pw_maintainers_cli.py index fd69081..ad51e3d 100755 --- a/tools/pw_maintainers_cli.py +++ b/tools/pw_maintainers_cli.py @@ -112,6 +112,7 @@ class GitPW(object): patch['id'], users[0]['email'])) _ = api.update( 'patches', patch['id'], [('delegate', users[0]['id'])]) + return users[0].get('email') class Diff(object): @@ -366,16 +367,18 @@ if __name__ == '__main__': print(*maintainer_list, sep='\n') elif command == 'set-pw-delegate': if len(maintainer_list) > 0: - # Get the email of the first maintainer in the list. - try: - delegate = re.match( - r".*\<(?P<email>.*)\>", - maintainer_list[0]).group('email') - except AttributeError: - print("Unexpected format: '{}'".format(maintainer_list[0])) - sys.exit(1) - _git_pw.set_delegate( - patch_list, delegate, - skip_delegated=skip_delegated) + for maintainer in maintainer_list: + # Get the maintainer's email + try: + maintainer_email = re.match( + r".*\<(?P<email>.*)\>", + maintainer).group('email') + except AttributeError: + print("Unexpected format: '{}'".format(maintainer)) + delegate = _git_pw.set_delegate( + patch_list, maintainer_email, + skip_delegated=skip_delegated) + if delegate != None: + break else: print('No maintainers found. Not setting a delegate.') -- 2.25.1
Redirect error messages to stderr instead of stdout and reword 2 of them. Signed-off-by: Ali Alnubani <alialnu@nvidia.com> --- tools/pw_maintainers_cli.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/pw_maintainers_cli.py b/tools/pw_maintainers_cli.py index ad51e3d..a1d7d8e 100755 --- a/tools/pw_maintainers_cli.py +++ b/tools/pw_maintainers_cli.py @@ -56,7 +56,7 @@ Or if you want to use inside other scripts: MAINTAINERS_FILE_PATH = os.environ.get('MAINTAINERS_FILE_PATH') if not MAINTAINERS_FILE_PATH: - print('MAINTAINERS_FILE_PATH is not set.') + print('MAINTAINERS_FILE_PATH is not set.', file=sys.stderr) sys.exit(1) @@ -70,8 +70,7 @@ class GitPW(object): for key in conf_keys: value = conf_obj.get('pw_{}'.format(key)) if not value: - print('--pw_{} is a required git-pw configuration'.format(key)) - sys.exit(1) + sys.exit('--pw_{} is a required git-pw configuration'.format(key)) else: setattr(self.CONF, key, value) @@ -97,8 +96,8 @@ class GitPW(object): users = api.index('users', [('q', delegate)]) if len(users) != 1: # Zero or multiple users found - print('Cannot choose a Patchwork user to delegate to from ' - 'user list ({}). Skipping..'.format(users)) + print('Cannot choose a Patchwork user associated with {} to ' + 'delegate to.'.format(delegate, users), file=sys.stderr) return for patch in patch_list: if patch['delegate'] != None and \ @@ -374,11 +373,13 @@ if __name__ == '__main__': r".*\<(?P<email>.*)\>", maintainer).group('email') except AttributeError: - print("Unexpected format: '{}'".format(maintainer)) + print("Unexpected format: '{}'".format(maintainer), + file=sys.stderr) delegate = _git_pw.set_delegate( patch_list, maintainer_email, skip_delegated=skip_delegated) if delegate != None: break else: - print('No maintainers found. Not setting a delegate.') + print('No maintainers matched. Not setting a delegate.', + file=sys.stderr) -- 2.25.1
Ali Alnubani <alialnu@nvidia.com> writes:
> Instead of skipping patch delegation when there are no Patchwork
> users associated with the email of the first maintainer, try to
> delegate to other tree maintainers.
>
> Suggested-by: David Marchand <david.marchand@redhat.com>
> Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
> ---
Acked-by: Aaron Conole <aconole@redhat.com>
Ali Alnubani <alialnu@nvidia.com> writes:
> Redirect error messages to stderr instead of stdout and
> reword 2 of them.
>
> Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
> ---
I don't see how this is related to previous patch, but it makes sense,
so:
Acked-by: Aaron Conole <aconole@redhat.com>
> -----Original Message-----
> From: Aaron Conole <aconole@redhat.com>
> Sent: Monday, April 25, 2022 8:19 PM
> To: Ali Alnubani <alialnu@nvidia.com>
> Cc: ci@dpdk.org
> Subject: Re: [PATCH 2/2] pw_maintainers_cli: write errors to stderr
>
> Ali Alnubani <alialnu@nvidia.com> writes:
>
> > Redirect error messages to stderr instead of stdout and
> > reword 2 of them.
> >
> > Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
> > ---
>
> I don't see how this is related to previous patch, but it makes sense,
> so:
>
> Acked-by: Aaron Conole <aconole@redhat.com>
They aren't related, I should have sent them unnumbered.
Thanks,
Ali
> > Instead of skipping patch delegation when there are no Patchwork
> > users associated with the email of the first maintainer, try to
> > delegate to other tree maintainers.
> >
> > Suggested-by: David Marchand <david.marchand@redhat.com>
> > Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
>
> Acked-by: Aaron Conole <aconole@redhat.com>
Series applied, thanks.