diff mbox series

[RFC,3/4] recipetool: create: use default AUTOREV only for SCM URI

Message ID 20260304104342.869457-4-corentin.guillevic@smile.fr
State New
Headers show
Series Clean AUTOREV usage, add revision check for every SCM URI | expand

Commit Message

Corentin Guillevic March 4, 2026, 10:43 a.m. UTC
AUTOREV shoud only be used for SCM URIs (Git, SVN...). However, the
default revision is set to AUTOREV regardless of the URI scheme.

To fix this, set AUTOREV as the default value only if the source URI
supports SRCREV.

Signed-off-by: Corentin Guillevic <corentin.guillevic@smile.fr>
---
 scripts/lib/recipetool/create.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index ef0ba974a9..d785f042ee 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -419,7 +419,7 @@  def create_recipe(args):
     tempsrc = ''
     source = args.source
     srcsubdir = ''
-    srcrev = '${AUTOREV}'
+    srcrev = ''
     srcbranch = ''
     scheme = ''
     storeTagName = ''
@@ -470,6 +470,11 @@  def create_recipe(args):
             # so we need to extract to a subdirectory
             fetchuri += ';subdir=${BPN}'
         srcuri = fetchuri
+
+        # Define AUTOREV as default value only if the source URI supports SRCREV
+        if srcuri and srcuri.startswith(('gitsm://', 'git://', 'hg://', 'svn://')):
+            srcrev = '${AUTOREV}'
+
         rev_re = re.compile(';rev=([^;]+)')
         res = rev_re.search(srcuri)
         if res: