Patchwork [RFC,V2] base.bbclass: show git summary in BUILDCFG_HEADER

login
register
mail settings
Submitter Robert Yang
Date June 28, 2014, 2:32 a.m.
Message ID <1403922753-33481-1-git-send-email-liezhi.yang@windriver.com>
Download mbox | patch
Permalink /patch/74443/
State New
Headers show

Comments

Robert Yang - June 28, 2014, 2:32 a.m.
It was:
meta
meta-yocto
meta-yocto-bsp    = "master:3a054dc27067efaae9150b465298d9c45d728f85"

Now:
meta
meta-yocto
meta-yocto-bsp    = "master:3a054dc base.bbclass: show git summary in BUILDCFG_HEADER"

The benefit is that we can easily know the top commit info rather than
query it again in the git repo.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 meta/classes/base.bbclass         |    2 +-
 meta/classes/metadata_scm.bbclass |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
Robert Yang - July 7, 2014, 9:33 a.m.
On 06/28/2014 10:32 AM, Robert Yang wrote:
> It was:
> meta
> meta-yocto
> meta-yocto-bsp    = "master:3a054dc27067efaae9150b465298d9c45d728f85"
>
> Now:
> meta
> meta-yocto
> meta-yocto-bsp    = "master:3a054dc base.bbclass: show git summary in BUILDCFG_HEADER"

Any objections on this patch, please ? Or I will send a regular patch.

// Robert

>
> The benefit is that we can easily know the top commit info rather than
> query it again in the git repo.
>
> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
> ---
>   meta/classes/base.bbclass         |    2 +-
>   meta/classes/metadata_scm.bbclass |    6 ++++++
>   2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index c0d2c8ec8..f5abb88 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -244,7 +244,7 @@ def get_layers_branch_rev(d):
>       layers = (d.getVar("BBLAYERS", True) or "").split()
>       layers_branch_rev = ["%-17s = \"%s:%s\"" % (os.path.basename(i), \
>           base_get_metadata_git_branch(i, None).strip(), \
> -        base_get_metadata_git_revision(i, None)) \
> +        base_get_metadata_git_revision_and_summary(i, None)) \
>               for i in layers]
>       i = len(layers_branch_rev)-1
>       p1 = layers_branch_rev[i].find("=")
> diff --git a/meta/classes/metadata_scm.bbclass b/meta/classes/metadata_scm.bbclass
> index ba0edf9..dace653 100644
> --- a/meta/classes/metadata_scm.bbclass
> +++ b/meta/classes/metadata_scm.bbclass
> @@ -80,3 +80,9 @@ def base_get_metadata_git_revision(path, d):
>               return rev
>       return "<unknown>"
>
> +def base_get_metadata_git_revision_and_summary(path, d):
> +    f = os.popen("cd %s; git log -n 1 --abbrev-commit --pretty=oneline -- 2>&1" % path)
> +    data = f.readline()
> +    if f.close() is None:
> +            return data.rstrip()
> +    return "<unknown>"
>
Richard Purdie - July 7, 2014, 9:54 a.m.
On Mon, 2014-07-07 at 17:33 +0800, Robert Yang wrote:
> On 06/28/2014 10:32 AM, Robert Yang wrote:
> > It was:
> > meta
> > meta-yocto
> > meta-yocto-bsp    = "master:3a054dc27067efaae9150b465298d9c45d728f85"
> >
> > Now:
> > meta
> > meta-yocto
> > meta-yocto-bsp    = "master:3a054dc base.bbclass: show git summary in BUILDCFG_HEADER"
> 
> Any objections on this patch, please ? Or I will send a regular patch.

Being able to find the full sha1 can be useful and is something I use
periodical but I also understand why you want more information here.

So I have mixed feelings on it...

Cheers,

Richard
Robert Yang - July 7, 2014, 9:58 a.m.
On 07/07/2014 05:54 PM, Richard Purdie wrote:
> On Mon, 2014-07-07 at 17:33 +0800, Robert Yang wrote:
>> On 06/28/2014 10:32 AM, Robert Yang wrote:
>>> It was:
>>> meta
>>> meta-yocto
>>> meta-yocto-bsp    = "master:3a054dc27067efaae9150b465298d9c45d728f85"
>>>
>>> Now:
>>> meta
>>> meta-yocto
>>> meta-yocto-bsp    = "master:3a054dc base.bbclass: show git summary in BUILDCFG_HEADER"
>>
>> Any objections on this patch, please ? Or I will send a regular patch.
>
> Being able to find the full sha1 can be useful and is something I use
> periodical but I also understand why you want more information here.

Thanks, let's drop the patch since the full sha1 is useful.

// Robert

>
> So I have mixed feelings on it...
>
> Cheers,
>
> Richard
>
>
>

Patch

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index c0d2c8ec8..f5abb88 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -244,7 +244,7 @@  def get_layers_branch_rev(d):
     layers = (d.getVar("BBLAYERS", True) or "").split()
     layers_branch_rev = ["%-17s = \"%s:%s\"" % (os.path.basename(i), \
         base_get_metadata_git_branch(i, None).strip(), \
-        base_get_metadata_git_revision(i, None)) \
+        base_get_metadata_git_revision_and_summary(i, None)) \
             for i in layers]
     i = len(layers_branch_rev)-1
     p1 = layers_branch_rev[i].find("=")
diff --git a/meta/classes/metadata_scm.bbclass b/meta/classes/metadata_scm.bbclass
index ba0edf9..dace653 100644
--- a/meta/classes/metadata_scm.bbclass
+++ b/meta/classes/metadata_scm.bbclass
@@ -80,3 +80,9 @@  def base_get_metadata_git_revision(path, d):
             return rev
     return "<unknown>"
 
+def base_get_metadata_git_revision_and_summary(path, d):
+    f = os.popen("cd %s; git log -n 1 --abbrev-commit --pretty=oneline -- 2>&1" % path)
+    data = f.readline()
+    if f.close() is None:
+            return data.rstrip()
+    return "<unknown>"