Patchwork [bitbake-devel] bitbake: fetch2/git: add nobranch option for SRC_URI to skip validating SHA

login
register
mail settings
Submitter Zhenhua Luo
Date Jan. 7, 2014, 3:21 a.m.
Message ID <1389064866-26141-1-git-send-email-zhenhua.luo@freescale.com>
Download mbox | patch
Permalink /patch/64197/
State New
Headers show

Comments

Zhenhua Luo - Jan. 7, 2014, 3:21 a.m.
For rebased git tree, some commits can be found in tag rather than branch, the change
is useful for such case.

Signed-off-by: Zhenhua Luo <zhenhua.luo@freescale.com>
---
 lib/bb/fetch2/git.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Martin Jansa - Jan. 7, 2014, 8:34 a.m.
On Tue, Jan 07, 2014 at 11:21:06AM +0800, Zhenhua Luo wrote:
> For rebased git tree, some commits can be found in tag rather than branch, the change
> is useful for such case.
> 
> Signed-off-by: Zhenhua Luo <zhenhua.luo@freescale.com>
> ---
>  lib/bb/fetch2/git.py | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
> index b4b9368..6d74dbb 100644
> --- a/lib/bb/fetch2/git.py
> +++ b/lib/bb/fetch2/git.py
> @@ -101,6 +101,8 @@ class Git(FetchMethod):
>  
>          ud.rebaseable = ud.parm.get("rebaseable","0") == "1"
>  
> +        ud.nobranch = ud.parm.get("nobranch","0") == "1"
> +
>          # bareclone implies nocheckout
>          ud.bareclone = ud.parm.get("bareclone","0") == "1"
>          if ud.bareclone:
> @@ -217,7 +219,7 @@ class Git(FetchMethod):
>              ud.repochanged = True
>          os.chdir(ud.clonedir)
>          for name in ud.names:
> -            if not self._contains_ref(ud, d, name):
> +            if not ud.nobranch and not self._contains_ref(ud, d, name):

I think that even with nobranch param set you need to check that SHA-1
is included, you just don't care in which branch if it's even included
in any.

Something like
  def _contains_ref(self, tag, branch, d):
was doing before 89abfbc1953e3711d6c90aff793ee622c22609b1, so the
conditional should be in _contains_ref not skipping it completely.

>                  raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))
>  
>      def build_mirror_data(self, ud, d):
> -- 
> 1.8.4.2
> 
> 
> _______________________________________________
> bitbake-devel mailing list
> bitbake-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/bitbake-devel
Zhenhua Luo - Jan. 7, 2014, 10:47 a.m.
Thanks, v2 is submitted, please review. 

http://patches.openembedded.org/patch/64209/


Best Regards,

Zhenhua


> -----Original Message-----
> From: bitbake-devel-bounces@lists.openembedded.org [mailto:bitbake-devel-
> bounces@lists.openembedded.org] On Behalf Of Martin Jansa
> Sent: Tuesday, January 07, 2014 4:35 PM
> To: Luo Zhenhua-B19537
> Cc: Schmitt Richard-B43082; Guo Chunrong-B40290; bitbake-
> devel@lists.openembedded.org; Yu Zongchun-B40527
> Subject: Re: [bitbake-devel] [PATCH] bitbake: fetch2/git: add nobranch
> option for SRC_URI to skip validating SHA
> 
> On Tue, Jan 07, 2014 at 11:21:06AM +0800, Zhenhua Luo wrote:
> > For rebased git tree, some commits can be found in tag rather than
> > branch, the change is useful for such case.
> >
> > Signed-off-by: Zhenhua Luo <zhenhua.luo@freescale.com>
> > ---
> >  lib/bb/fetch2/git.py | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py index
> > b4b9368..6d74dbb 100644
> > --- a/lib/bb/fetch2/git.py
> > +++ b/lib/bb/fetch2/git.py
> > @@ -101,6 +101,8 @@ class Git(FetchMethod):
> >
> >          ud.rebaseable = ud.parm.get("rebaseable","0") == "1"
> >
> > +        ud.nobranch = ud.parm.get("nobranch","0") == "1"
> > +
> >          # bareclone implies nocheckout
> >          ud.bareclone = ud.parm.get("bareclone","0") == "1"
> >          if ud.bareclone:
> > @@ -217,7 +219,7 @@ class Git(FetchMethod):
> >              ud.repochanged = True
> >          os.chdir(ud.clonedir)
> >          for name in ud.names:
> > -            if not self._contains_ref(ud, d, name):
> > +            if not ud.nobranch and not self._contains_ref(ud, d, name):
> 
> I think that even with nobranch param set you need to check that SHA-1 is
> included, you just don't care in which branch if it's even included in
> any.
> 
> Something like
>   def _contains_ref(self, tag, branch, d):
> was doing before 89abfbc1953e3711d6c90aff793ee622c22609b1, so the
> conditional should be in _contains_ref not skipping it completely.
> 
> >                  raise bb.fetch2.FetchError("Unable to find revision
> > %s in branch %s even from upstream" % (ud.revisions[name],
> > ud.branches[name]))
> >
> >      def build_mirror_data(self, ud, d):
> > --
> > 1.8.4.2
> >
> >
> > _______________________________________________
> > bitbake-devel mailing list
> > bitbake-devel@lists.openembedded.org
> > http://lists.openembedded.org/mailman/listinfo/bitbake-devel
> 
> --
> Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

Patch

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index b4b9368..6d74dbb 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -101,6 +101,8 @@  class Git(FetchMethod):
 
         ud.rebaseable = ud.parm.get("rebaseable","0") == "1"
 
+        ud.nobranch = ud.parm.get("nobranch","0") == "1"
+
         # bareclone implies nocheckout
         ud.bareclone = ud.parm.get("bareclone","0") == "1"
         if ud.bareclone:
@@ -217,7 +219,7 @@  class Git(FetchMethod):
             ud.repochanged = True
         os.chdir(ud.clonedir)
         for name in ud.names:
-            if not self._contains_ref(ud, d, name):
+            if not ud.nobranch and not self._contains_ref(ud, d, name):
                 raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))
 
     def build_mirror_data(self, ud, d):