]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
u_boot_pylib: Tidy up quoting of cc and to
authorSimon Glass <sjg@chromium.org>
Thu, 8 May 2025 02:38:30 +0000 (04:38 +0200)
committerSimon Glass <sjg@chromium.org>
Tue, 27 May 2025 09:07:42 +0000 (10:07 +0100)
The current approach to calling 'git send-email' puts double quotes
around each email address to ensure that it will pass the shell
correctly. This is a bit cumbersome and requires using a shell to sort
it all out.

Drop the quotes and use command.run() instead, to simplify things. This
will also make it possible to (later) set the current directory.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/patman/func_test.py
tools/u_boot_pylib/gitutil.py

index 3a34302fc57bc2d4cfb9d6fac8a6ba4dd75fba0f..7f9175ea44fd4fa69639528114411dd1fde58266 100644 (file)
@@ -292,7 +292,7 @@ class TestFunctional(unittest.TestCase):
         self.assertEqual('      Cc:  %s' % mel, next(lines))
         self.assertEqual('      Cc:  %s' % rick, next(lines))
         expected = ('Git command: git send-email --annotate '
-                    '--in-reply-to="%s" --to "u-boot@lists.denx.de" '
+                    '--in-reply-to="%s" --to u-boot@lists.denx.de '
                     '--cc "%s" --cc-cmd "%s send --cc-cmd %s" %s %s'
                     % (in_reply_to, stefan, sys.argv[0], cc_file, cover_fname,
                        ' '.join(args)))
index 7d3a0b68c53d53c3c4b3c099fe2ce0fc7fe01496..e5a466c8cc65f89646dac436e306d8cb7efd65f5 100644 (file)
@@ -396,7 +396,6 @@ def build_email_list(in_list, alias, tag=None, warn_on_error=True):
     >>> build_email_list(['john', 'mary'], alias, 'Cc')
     ['Cc j.bloggs@napier.co.nz', 'Cc Mary Poppins <m.poppins@cloud.net>']
     """
-    quote = '"' if tag and tag[0] == '-' else ''
     raw = []
     for item in in_list:
         raw += lookup_email(item, alias, warn_on_error=warn_on_error)
@@ -405,7 +404,7 @@ def build_email_list(in_list, alias, tag=None, warn_on_error=True):
         if item not in result:
             result.append(item)
     if tag:
-        return [f'{tag} {quote}{email}{quote}' for email in result]
+        return [x for email in result for x in (tag, email)]
     return result
 
 
@@ -524,13 +523,14 @@ send --cc-cmd cc-fname" cover p1 p2'
 
     cmd += to
     cmd += cc
-    cmd += ['--cc-cmd', f'"{sys.argv[0]} send --cc-cmd {cc_fname}"']
+    cmd += ['--cc-cmd', f'{sys.argv[0]} send --cc-cmd {cc_fname}']
     if cover_fname:
         cmd.append(cover_fname)
     cmd += args
-    cmdstr = ' '.join(cmd)
     if not dry_run:
-        os.system(cmdstr)
+        command.run(*cmd, capture=False, capture_stderr=False)
+    cmdstr = ' '.join([f'"{x}"' if ' ' in x and not '"' in x else x
+                       for x in cmd])
     return cmdstr