[Concept,22/37] patman: Default autolink to updating the branch commit

Message ID 20260404213020.372253-23-sjg@u-boot.org
State New
Headers
Series patman: Autolink fixes and AI-assisted patch review |

Commit Message

Simon Glass April 4, 2026, 9:28 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

Autolink stores the patchwork link in the database but does not update
the Series-links tag in the commit unless -u is passed. This means
'patman status' cannot find the link since it reads from commit
metadata.

Change autolink and autolink-all to default to updating the commit,
with --no-update to opt out. Update tests to match the new default.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/patman/cmdline.py      | 10 ++++++++--
 tools/patman/test_cseries.py | 15 ++++++++-------
 2 files changed, 16 insertions(+), 9 deletions(-)
  

Patch

diff --git a/tools/patman/cmdline.py b/tools/patman/cmdline.py
index 3843811729e..3c12200949f 100644
--- a/tools/patman/cmdline.py
+++ b/tools/patman/cmdline.py
@@ -260,7 +260,10 @@  def add_series_subparser(subparsers):
 
     auto = series_subparsers.add_parser('autolink',
                                         aliases=ALIASES['autolink'])
-    _add_update(auto)
+    auto.add_argument('-u', '--update', action='store_true', default=True,
+                      help='Update the branch commit (default)')
+    auto.add_argument('--no-update', action='store_false', dest='update',
+                      help='Do not update the branch commit')
     _add_wait(auto, 0)
 
     aall = series_subparsers.add_parser('autolink-all')
@@ -268,7 +271,10 @@  def add_series_subparser(subparsers):
                       help='Link all series versions, not just the latest')
     aall.add_argument('-r', '--replace-existing', action='store_true',
                       help='Replace existing links')
-    _add_update(aall)
+    aall.add_argument('-u', '--update', action='store_true', default=True,
+                      help='Update the branch commits (default)')
+    aall.add_argument('--no-update', action='store_false', dest='update',
+                      help='Do not update the branch commits')
 
     series_subparsers.add_parser('dec')
 
diff --git a/tools/patman/test_cseries.py b/tools/patman/test_cseries.py
index 5661e13e2e9..3b78399d907 100644
--- a/tools/patman/test_cseries.py
+++ b/tools/patman/test_cseries.py
@@ -1402,7 +1402,7 @@  Tested-by: Mary Smith <msmith@wibble.com>   # yak
         with (mock.patch.object(cseries.Cseries, 'link_auto_all',
                                 return_value=None) as method):
             self.run_args('series', 'autolink-all', pwork=True)
-        method.assert_called_once_with(True, update_commit=False,
+        method.assert_called_once_with(True, update_commit=True,
                                        link_all_versions=False,
                                        replace_existing=False, dry_run=False,
                                        show_summary=True)
@@ -1410,7 +1410,7 @@  Tested-by: Mary Smith <msmith@wibble.com>   # yak
         with (mock.patch.object(cseries.Cseries, 'link_auto_all',
                                 return_value=None) as method):
             self.run_args('series', 'autolink-all', '-a', pwork=True)
-        method.assert_called_once_with(True, update_commit=False,
+        method.assert_called_once_with(True, update_commit=True,
                                        link_all_versions=True,
                                        replace_existing=False, dry_run=False,
                                        show_summary=True)
@@ -1418,7 +1418,7 @@  Tested-by: Mary Smith <msmith@wibble.com>   # yak
         with (mock.patch.object(cseries.Cseries, 'link_auto_all',
                                 return_value=None) as method):
             self.run_args('series', 'autolink-all', '-a', '-r', pwork=True)
-        method.assert_called_once_with(True, update_commit=False,
+        method.assert_called_once_with(True, update_commit=True,
                                        link_all_versions=True,
                                        replace_existing=True, dry_run=False,
                                        show_summary=True)
@@ -1426,22 +1426,23 @@  Tested-by: Mary Smith <msmith@wibble.com>   # yak
         with (mock.patch.object(cseries.Cseries, 'link_auto_all',
                                 return_value=None) as method):
             self.run_args('series', '-n', 'autolink-all', '-r', pwork=True)
-        method.assert_called_once_with(True, update_commit=False,
+        method.assert_called_once_with(True, update_commit=True,
                                        link_all_versions=False,
                                        replace_existing=True, dry_run=True,
                                        show_summary=True)
 
         with (mock.patch.object(cseries.Cseries, 'link_auto_all',
                                 return_value=None) as method):
-            self.run_args('series', 'autolink-all', '-u', pwork=True)
-        method.assert_called_once_with(True, update_commit=True,
+            self.run_args('series', 'autolink-all', '--no-update', pwork=True)
+        method.assert_called_once_with(True, update_commit=False,
                                        link_all_versions=False,
                                        replace_existing=False, dry_run=False,
                                        show_summary=True)
 
         # Now do a real one to check the patchwork handling and output
         with terminal.capture() as (out, _):
-            self.run_args('series', 'autolink-all', '-a', pwork=pwork)
+            self.run_args('series', 'autolink-all', '-a', '--no-update',
+                          pwork=pwork)
         itr = iter(out.getvalue().splitlines())
         self.assertEqual(
             '1 series linked, 1 already linked, 1 not found (3 requests)',