utils/get-developers: misc cleanups and improvements
cover utils/get-developers: misc cleanups and improvements
From: "Yann E. MORIN" <[email protected]>
Hello All!
This small series brings in a few trivial cleanups and improvements to get-developers.
Regards,
Yann E. MORIN.
The following changes since commit a0ebdd5cd8318d03693ffa2bfd95b311847bbc1c
package/cloudflared: bump to version 2024.12.2 (2024-12-20 00:33:23 +0100)
are available as patches in this mail series,
for you to apply patches up to 64f9d09898aee7370ee86df702b207182e6d0cb5
utils/get-developers: add option to report Cc: lines (2024-12-20 14:28:35 +0100)
----------------------------------------------------------------
Yann E. MORIN (5):
utils/get-developers: don't offload parse_args() utils/get-developers: use parser.error rather than canned print+return utils/get-developers: read patch from stdin when it's not a tty utils/get-developers: sort reported developers utils/get-developers: add option to report Cc: lines
utils/get-developers | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
--
____________ .-----------------.--------------------: _ :------------------. | Yann E. MORIN | Real-Time Embedded | __/ ) | /"\ ASCII RIBBON | | | Software Designer | _/ - /' | \ / CAMPAIGN | | +33 638.411.245 '--------------------: (_ `--, | X AGAINST | | yann.morin (at) orange.com |_=" ,--' | / \ HTML MAIL |
'--------------------------------------:______/_____:------------------'
____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration, Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.
This message and its attachments may contain confidential or privileged information that may be protected by law; they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments. As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified. Thank you.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 1/5 utils/get-developers: don't offload parse_args()
From: "Yann E. MORIN" <[email protected]>
Offloading parser.parse_args() to a helper function does not bring much, if at all; it even is restrictive: indeed, we can't user parser.error() to report errrors and thus have to resort to a canned print+return sequence...
--- utils/get-developers | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
utils/get-developers +2 -6
@@ -5,7 +5,7 @@ import getdeveloperlib import sys -def parse_args(): +def __main__(): parser = argparse.ArgumentParser() parser.add_argument('patches', metavar='P', type=argparse.FileType('r'), nargs='*', help='list of patches (use - to read patches from stdin)')
@@ -23,11 +23,7 @@ def parse_args(): const=True, help='validate syntax of DEVELOPERS file') parser.add_argument('-d', dest='filename', action='store', default=None, help='override the default DEVELOPERS file (for debug)') - return parser.parse_args() - - -def __main__(): - args = parse_args() + args = parser.parse_args() # Check that only one action is given action = 0
Signature · 18 lines
2.34.1 ____________________________________________________________________________________________________________ Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration, Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci. This message and its attachments may contain confidential or privileged information that may be protected by law; they should not be distributed, used or copied without authorisation. If you have received this email in error, please notify the sender and delete this message and its attachments. As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified. Thank you. _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 2/5 utils/get-developers: use parser.error rather than canned print+return
In reply to [email protected]From: "Yann E. MORIN" <[email protected]>
--- utils/get-developers | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
utils/get-developers +2 -4
@@ -40,11 +40,9 @@ def __main__(): if len(args.patches) != 0: action += 1 if action > 1: - print("Cannot do more than one action") - return + parser.error("Cannot do more than one action") if action == 0: - print("No action specified") - return + parser.error("No action specified") devs = getdeveloperlib.parse_developers(args.filename) if devs is None:
Signature · 18 lines
2.34.1 ____________________________________________________________________________________________________________ Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration, Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci. This message and its attachments may contain confidential or privileged information that may be protected by law; they should not be distributed, used or copied without authorisation. If you have received this email in error, please notify the sender and delete this message and its attachments. As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified. Thank you. _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/5] utils/get-developers: use parser.error rather than canned print+return
Hi Yann,
Thanks for the patch!
Quoted 12 lines · On 20/12/2024 14:31, [email protected] wrote:
From: "Yann E. MORIN" <[email protected]>
Signed-off-by Yann E. MORIN <[email protected]>--- utils/get-developers | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)utils/get-developers +0
-0
utils/get-developers def __main__(): · line 45
Quoted 10 lines
utils/get-developers +2
-4@@ -40,11 +40,9 @@ def __main__(): if len(args.patches) != 0: action += 1 if action > 1: - print("Cannot do more than one action") - return + parser.error("Cannot do more than one action") if action == 0: - print("No action specified") - return + parser.error("No action specified")
This change breaks the get-developers runtime test. You can see the failure with the command:
utils/docker-run support/testing/run-tests \
-d dl -o output_folder \
tests.utils.test_get_developersI believe this is due to moving the error message from stdin to stderr. So this patch should also update accordingly the file:
support/testing/tests/utils/test_get_developers.py
Can you have a look to fix this test, please?
Quoted 18 lines
utils/get-developers +0
-1devs = getdeveloperlib.parse_developers(args.filename) if devs is None: --2.34.1
____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration, Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.This message and its attachments may contain confidential or privileged information that may be protected by law; they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments. As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified. Thank you.
Quoted 4 lines
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Best regards,
Julien.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 3/5 utils/get-developers: read patch from stdin when it's not a tty
In reply to [email protected]From: "Yann E. MORIN" <[email protected]>
It is very common that gt-developers be used with its stdin a pipe from git-show:
git show |./utils-get-developers -
In this case, the '-' is superfluous: we can very easilit deduce that the user wants to read stdin as the patch.
So, ifno otehr action was requested, and stdin is not a tty, use it as the source of the patch, and thus '-' is then no longer required.
--- utils/get-developers | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
utils/get-developers +3 -1
@@ -42,7 +42,9 @@ def __main__(): if action > 1: parser.error("Cannot do more than one action") if action == 0: - parser.error("No action specified") + if sys.stdin.isatty(): + parser.error("No action specified") + args.patches.append(sys.stdin) devs = getdeveloperlib.parse_developers(args.filename) if devs is None:
Signature · 18 lines
2.34.1 ____________________________________________________________________________________________________________ Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration, Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci. This message and its attachments may contain confidential or privileged information that may be protected by law; they should not be distributed, used or copied without authorisation. If you have received this email in error, please notify the sender and delete this message and its attachments. As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified. Thank you. _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 4/5 utils/get-developers: sort reported developers
In reply to [email protected]From: "Yann E. MORIN" <[email protected]>
The list of reported developers is not ordered: that may leave the impression (when receiving a patch) that a Cc is more important than another, by virtue of being earlier in the list.
Also, the ordering changes on every call.
Report the developers in an alphabetically order, so that there is no confusion anymore, and so the ordering is reproducible across calls.
--- utils/get-developers | 1 + 1 file changed, 1 insertion(+)
utils/get-developers +1 -0
@@ -98,6 +98,7 @@ def __main__(): if i in dev.infras: matching_devs.add(dev.name) + matching_devs = sorted(matching_devs) if args.email: for dev in matching_devs: print(dev)
Signature · 18 lines
2.34.1 ____________________________________________________________________________________________________________ Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration, Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci. This message and its attachments may contain confidential or privileged information that may be protected by law; they should not be distributed, used or copied without authorisation. If you have received this email in error, please notify the sender and delete this message and its attachments. As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified. Thank you. _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 5/5 utils/get-developers: add option to report Cc: lines
In reply to [email protected]From: "Yann E. MORIN" <[email protected]>
It is very common to use the output of get-developers to add cc: lines in the commit log (see below!).
Add an option so that get-developers reports Cc: lines ready to be pasted in a commit log.
--- utils/get-developers | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
utils/get-developers +4 -2
@@ -17,6 +17,8 @@ def __main__(): help='find developers in charge of these files') parser.add_argument('-c', dest='check', action='store_const', const=True, help='list files not handled by any developer') + parser.add_argument('--cc', action="store_true", + help='report developpers as CC: lines ready to be pasted in a commit log') parser.add_argument('-e', dest='email', action='store_const', const=True, help='only list affected developer email addresses') parser.add_argument('-v', dest='validate', action='store_const',
@@ -99,9 +101,9 @@ def __main__(): matching_devs.add(dev.name) matching_devs = sorted(matching_devs) - if args.email: + if args.email or args.cc: for dev in matching_devs: - print(dev) + print(f"{'Cc: ' if args.cc else ''}{dev}") else: result = "--to [email protected]" for dev in matching_devs:
Signature · 18 lines
2.34.1 ____________________________________________________________________________________________________________ Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration, Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci. This message and its attachments may contain confidential or privileged information that may be protected by law; they should not be distributed, used or copied without authorisation. If you have received this email in error, please notify the sender and delete this message and its attachments. As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified. Thank you. _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 5/5] utils/get-developers: add option to report Cc: lines
Hi Yann,
Quoted 18 lines · On 20/12/2024 14:31, [email protected] wrote:
From: "Yann E. MORIN" <[email protected]>
It is very common to use the output of get-developers to add cc: lines in the commit log (see below!).
Add an option so that get-developers reports Cc: lines ready to be pasted in a commit log.
Signed-off-by Yann E. MORIN <[email protected]>--- utils/get-developers | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)utils/get-developers +0
-0
utils/get-developers def __main__(): · line 24
Quoted 8 lines
utils/get-developers +2
-0@@ -17,6 +17,8 @@ def __main__(): help='find developers in charge of these files') parser.add_argument('-c', dest='check', action='store_const', const=True, help='list files not handled by any developer') + parser.add_argument('--cc', action="store_true", + help='report developpers as CC: lines ready to be pasted in a commit log')
Here, this help line does not give a clue this option only works for the "patch" action (and nothing happens if it's used on other actions).
Do you see valid use cases for other actions? Such as:
utils/get-developers --cc -p python3
utils/get-developers --cc -f package/python3/python3.mk
...If yes, this --cc should be handled in other actions too. If no, the help line could mention it is limited only to patches.
What do you think?
Also, "developpers" in the help string should be fixed to "developers".
Quoted 31 lines
parser.add_argument('-e', dest='email', action='store_const',
const=True, help='only list affected developer
email addresses')
parser.add_argument('-v', dest='validate', action='store_const',utils/get-developers +2
-3@@ -99,9 +101,9 @@ def __main__(): matching_devs.add(dev.name) matching_devs = sorted(matching_devs) - if args.email: + if args.email or args.cc: for dev in matching_devs: - print(dev) + print(f"{'Cc: ' if args.cc else ''}{dev}") else: result = "--to [email protected]" for dev in matching_devs: --2.34.1
____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration, Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.This message and its attachments may contain confidential or privileged information that may be protected by law; they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments. As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified. Thank you.
Quoted 4 lines
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Best regards,
Julien.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 5/5] utils/get-developers: add option to report Cc: lines
Julien, All,
On 2024-12-20 22:49 +0100, Julien Olivain spake thusly:
Quoted 4 lines · On 20/12/2024 14:31, [email protected] wrote:
Quoted 3 lines
From: "Yann E. MORIN" <[email protected]>
Add an option so that get-developers reports Cc: lines ready to be pasted in a commit log.
[--SNIP--]
Quoted 5 lines
Quoted 3 lines
(quoted diff) +2
-0+ parser.add_argument('--cc', action="store_true", + help='report developpers as CC: lines ready tobe pasted in a commit log')
Here, this help line does not give a clue this option only works for the "patch" action (and nothing happens if it's used on other actions).
Indeed. I modelled that new option on the existing -e option, that only affect the output when parsing a patch file.
Quoted 4 lines
Do you see valid use cases for other actions? Such as:
utils/get-developers --cc -p python3 utils/get-developers --cc -f package/python3/python3.mk ...
No, I really wanted it to behave like the existing -e option.
I agree that the help text I wrote for that new option was not entirely crystal-clear. So, I've amended it and modelled it after that of the -e option now (in v2 to come shortly).
Quoted 6 lines
If yes, this --cc should be handled in other actions too. If no, the help line could mention it is limited only to patches.
What do you think?
Also, "developpers" in the help string should be fixed to "developers".
Is that the only typo you spotted in the entire series? ;-)
Thanks for the review!
Regards,
Yann E. MORIN.
Signature · 23 lines
____________ .-----------------.--------------------: _ :------------------. | Yann E. MORIN | Real-Time Embedded | __/ ) | /"\ ASCII RIBBON | | | Software Designer | _/ - /' | \ / CAMPAIGN | | +33 638.411.245 '--------------------: (_ `--, | X AGAINST | | yann.morin (at) orange.com |_=" ,--' | / \ HTML MAIL | '--------------------------------------:______/_____:------------------' ____________________________________________________________________________________________________________ Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration, Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci. This message and its attachments may contain confidential or privileged information that may be protected by law; they should not be distributed, used or copied without authorisation. If you have received this email in error, please notify the sender and delete this message and its attachments. As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified. Thank you. _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot