<div dir="ltr">rev-parse is a better bet than rev-list for ref validation, IMO.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 15, 2017 at 1:24 AM, Chang Rebecca Swee Fun <span dir="ltr">&lt;<a href="mailto:rebecca.swee.fun.chang@intel.com" target="_blank">rebecca.swee.fun.chang@intel.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Stanley Phoong &lt;<a href="mailto:stanley.cheong.kwan.phoong@intel.com">stanley.cheong.kwan.phoong@<wbr>intel.com</a>&gt;<br>
<br>
If a git URL is passed to recipetool create with a tag=, recipetool<br>
should handle it assuming that the tag is valid.<br>
<br>
[YOCTO #11393]<br>
<br>
Signed-off-by: Stanley Phoong &lt;<a href="mailto:stanley.cheong.kwan.phoong@intel.com">stanley.cheong.kwan.phoong@<wbr>intel.com</a>&gt;<br>
---<br>
 scripts/lib/recipetool/create.<wbr>py | 23 ++++++++++++++++++++++-<br>
 1 file changed, 22 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/scripts/lib/recipetool/<wbr>create.py b/scripts/lib/recipetool/<wbr>create.py<br>
index d2e6fc0..52c10e5 100644<br>
--- a/scripts/lib/recipetool/<wbr>create.py<br>
+++ b/scripts/lib/recipetool/<wbr>create.py<br>
@@ -423,6 +423,7 @@ def create_recipe(args):<br>
     srcsubdir = &#39;&#39;<br>
     srcrev = &#39;${AUTOREV}&#39;<br>
     srcbranch = &#39;&#39;<br>
+    storeTagName = &#39;&#39;<br>
<br>
     if os.path.isfile(source):<br>
         source = &#39;file://%s&#39; % os.path.abspath(source)<br>
@@ -446,13 +447,21 @@ def create_recipe(args):<br>
         scheme, network, path, user, passwd, params = bb.fetch2.decodeurl(fetchuri)<br>
         srcbranch = params.get(&#39;branch&#39;)<br>
         nobranch = params.get(&#39;nobranch&#39;)<br>
+        tag = params.get(&#39;tag&#39;)<br>
         if not srcbranch and not nobranch and srcrev != &#39;${AUTOREV}&#39;:<br>
             # Append nobranch=1 in the following conditions:<br>
             # 1. User did not set &#39;branch=&#39; in srcuri, and<br>
             # 2. User did not set &#39;nobranch=1&#39; in srcuri, and<br>
             # 3. Source revision is not &#39;${AUTOREV}&#39;<br>
             params[&#39;nobranch&#39;] = &#39;1&#39;<br>
-            fetchuri = bb.fetch2.encodeurl((scheme, network, path, user, passwd, params))<br>
+        if tag:<br>
+            # Keep a copy of tag and append nobranch=1 then remove tag from URL.<br>
+            # Bitbake fetcher unable to fetch when {AUTOREV} and tag is set at the same time.<br>
+            # We will re-introduce tag argument after bitbake fetcher process is complete.<br>
+            storeTagName = params[&#39;tag&#39;]<br>
+            params[&#39;nobranch&#39;] = &#39;1&#39;<br>
+            del params[&#39;tag&#39;]<br>
+        fetchuri = bb.fetch2.encodeurl((scheme, network, path, user, passwd, params))<br>
<br>
         tmpparent = tinfoil.config_data.getVar(&#39;<wbr>BASE_WORKDIR&#39;)<br>
         bb.utils.mkdirhier(tmpparent)<br>
@@ -523,6 +532,18 @@ def create_recipe(args):<br>
             params[&#39;branch&#39;] = srcbranch<br>
             srcuri = bb.fetch2.encodeurl((scheme, network, path, user, passwd, params))<br>
<br>
+        if storeTagName:<br>
+            # Re-introduced tag variable from storeTagName<br>
+            # Check srcrev using tag and check validity of the tag<br>
+            try:<br>
+                cmd = (&#39;git rev-list -n 1 %s&#39; % (storeTagName))<br>
+                check_tag, check_tag_err = bb.process.run(&#39;%s&#39; % cmd, cwd=srctree)<br>
+                srcrev = check_tag.split()[0]<br>
+            except bb.process.ExecutionError as err:<br>
+                logger.error(str(err))<br>
+                logger.error(&quot;Possibly wrong tag name is provided&quot;)<br>
+                sys.exit(1)<br>
+<br>
         if os.path.exists(os.path.join(<wbr>srctree, &#39;.gitmodules&#39;)) and srcuri.startswith(&#39;git://&#39;):<br>
             srcuri = &#39;gitsm://&#39; + srcuri[6:]<br>
             <a href="http://logger.info" rel="noreferrer" target="_blank">logger.info</a>(&#39;Fetching submodules...&#39;)<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.7.4<br>
<br>
--<br>
______________________________<wbr>_________________<br>
Openembedded-core mailing list<br>
<a href="mailto:Openembedded-core@lists.openembedded.org">Openembedded-core@lists.<wbr>openembedded.org</a><br>
<a href="http://lists.openembedded.org/mailman/listinfo/openembedded-core" rel="noreferrer" target="_blank">http://lists.openembedded.org/<wbr>mailman/listinfo/openembedded-<wbr>core</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Christopher Larson<br>kergoth at gmail dot com<br>Founder - BitBake, OpenEmbedded, OpenZaurus<br>Senior Software Engineer, Mentor Graphics</div></div></div></div>
</div>