* [PATCH] fetch2/git: Simplify the validation of SHA-1 revisions
@ 2022-04-14 15:42 Peter Kjellerstedt
2022-04-14 16:27 ` [bitbake-devel] " Richard Purdie
0 siblings, 1 reply; 3+ messages in thread
From: Peter Kjellerstedt @ 2022-04-14 15:42 UTC (permalink / raw)
To: bitbake-devel
Also correct two comments.
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
bitbake/lib/bb/fetch2/git.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index b3eb8248d0..90104ac383 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -248,9 +248,10 @@ class Git(FetchMethod):
ud.setup_revisions(d)
+ sha1_re = re.compile(r'^[0-9a-f]{40}$')
for name in ud.names:
- # Ensure anything that doesn't look like a sha256 checksum/revision is translated into one
- if not ud.revisions[name] or len(ud.revisions[name]) != 40 or (False in [c in "abcdef0123456789" for c in ud.revisions[name]]):
+ # Ensure any revision that doesn't look like a SHA-1 is translated into one
+ if not sha1_re.match(ud.revisions[name] or ''):
if ud.revisions[name]:
ud.unresolvedrev[name] = ud.revisions[name]
ud.revisions[name] = self.latest_revision(ud, d, name)
@@ -259,10 +260,10 @@ class Git(FetchMethod):
if gitsrcname.startswith('.'):
gitsrcname = gitsrcname[1:]
- # for rebaseable git repo, it is necessary to keep mirror tar ball
- # per revision, so that even the revision disappears from the
+ # For a rebaseable git repo, it is necessary to keep a mirror tar ball
+ # per revision, so that even if the revision disappears from the
# upstream repo in the future, the mirror will remain intact and still
- # contains the revision
+ # contain the revision
if ud.rebaseable:
for name in ud.names:
gitsrcname = gitsrcname + '_' + ud.revisions[name]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [bitbake-devel] [PATCH] fetch2/git: Simplify the validation of SHA-1 revisions
2022-04-14 15:42 [PATCH] fetch2/git: Simplify the validation of SHA-1 revisions Peter Kjellerstedt
@ 2022-04-14 16:27 ` Richard Purdie
2022-04-14 20:20 ` Peter Kjellerstedt
0 siblings, 1 reply; 3+ messages in thread
From: Richard Purdie @ 2022-04-14 16:27 UTC (permalink / raw)
To: Peter Kjellerstedt, bitbake-devel
On Thu, 2022-04-14 at 17:42 +0200, Peter Kjellerstedt wrote:
> Also correct two comments.
>
> Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> ---
> bitbake/lib/bb/fetch2/git.py | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
> index b3eb8248d0..90104ac383 100644
> --- a/bitbake/lib/bb/fetch2/git.py
> +++ b/bitbake/lib/bb/fetch2/git.py
> @@ -248,9 +248,10 @@ class Git(FetchMethod):
>
> ud.setup_revisions(d)
>
> + sha1_re = re.compile(r'^[0-9a-f]{40}$')
re.compile() is expensive so in general we should cache that or do it at the
module top level...
Cheers,
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [bitbake-devel] [PATCH] fetch2/git: Simplify the validation of SHA-1 revisions
2022-04-14 16:27 ` [bitbake-devel] " Richard Purdie
@ 2022-04-14 20:20 ` Peter Kjellerstedt
0 siblings, 0 replies; 3+ messages in thread
From: Peter Kjellerstedt @ 2022-04-14 20:20 UTC (permalink / raw)
To: Richard Purdie, bitbake-devel
> -----Original Message-----
> From: Richard Purdie <richard.purdie@linuxfoundation.org>
> Sent: den 14 april 2022 18:28
> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>; bitbake-
> devel@lists.openembedded.org
> Subject: Re: [bitbake-devel] [PATCH] fetch2/git: Simplify the validation
> of SHA-1 revisions
>
> On Thu, 2022-04-14 at 17:42 +0200, Peter Kjellerstedt wrote:
> > Also correct two comments.
> >
> > Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> > ---
> > bitbake/lib/bb/fetch2/git.py | 11 ++++++-----
> > 1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
> > index b3eb8248d0..90104ac383 100644
> > --- a/bitbake/lib/bb/fetch2/git.py
> > +++ b/bitbake/lib/bb/fetch2/git.py
> > @@ -248,9 +248,10 @@ class Git(FetchMethod):
> >
> > ud.setup_revisions(d)
> >
> > + sha1_re = re.compile(r'^[0-9a-f]{40}$')
>
> re.compile() is expensive so in general we should cache that or do it at
> the module top level...
Sure, I can move it to the module top level.
I based the use of re.compile() in that class on how it was done in
the _revision_key() function. Do you want me to move its slash_re as
well?
> Cheers,
>
> Richard
//Peter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-14 20:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14 15:42 [PATCH] fetch2/git: Simplify the validation of SHA-1 revisions Peter Kjellerstedt
2022-04-14 16:27 ` [bitbake-devel] " Richard Purdie
2022-04-14 20:20 ` Peter Kjellerstedt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.