Skip to contentSkip to conversation

Support for automatic package versining using git describe

RFH Otavio Salvador 3 participants 3 messages Feb 13, 2009

lore
Share & tools
lore
#0 lore raw

Hello,

One of nice features we've been using is the git-describe to get versions based on tags; many projects are using it to name the development releases and it does give a better view of how diverged it from last released version.

So we're looking for a way to use it to generate the PV based on that. The current git fetcher already has the required support to get tags, so we can use it as SRCREV, but not yet to use git-describe.

I've tried to implement it, and failed. Here is the current patch just to reference.

bb/fetch/git.py (cópia de trabalho) renamed from bb/fetch/git.py (revisão 1150) +10 -4
Index: lib/bb/fetch/git.py
===================================================================
@@ -49,10 +49,7 @@
         elif tag:
             ud.tag = tag
 
-        if not ud.tag:
-            ud.tag = self.latest_revision(url, ud, d)  
-
-        if ud.tag == "master":
+        if not ud.tag or ud.tag == "master":
             ud.tag = self.latest_revision(url, ud, d)
 
         ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.tag), d)
@@ -179,6 +176,15 @@
 
         sortable_revision = "%s+%s" % (output.split()[0], ud.tag)
         bb.data.setVar(key, sortable_revision, d)
+
+        if bb.data.getVar("GIT_USE_DESCRIBE", d, False):
+            describe = runfetchcmd("git describe 2> /dev/null").read().strip()
+
+            if describe.empty():
+                bb.data.setVar("GIT_DESCRIBED_VERSION", "0.0.0+gitr%s" % (ud.tag))
+            else:
+                bb.data.setVar("GIT_DESCRIBED_VERSION", describe)
+
         return sortable_revision
 

Do someone has a better idea how to do that?

TIA,

Signature · 3 lines
Otavio Salvador                  O.S. Systems
E-mail: [email protected]  http://www.ossystems.com.br
Mobile: +55 53 9981-7854         http://projetos.ossystems.com.br
#1 lore raw
Quoted 10 lines · Otavio Salvador

Hello,

One of nice features we've been using is the git-describe to get versions based on tags; many projects are using it to name the development releases and it does give a better view of how diverged it from last released version.

So we're looking for a way to use it to generate the PV based on that. The current git fetcher already has the required support to get tags, so we can use it as SRCREV, but not yet to use git-describe.

Do you have any examples of the output?

regards,

Koen

#2 lore raw
Quoted 8 lines · Koen Kooi
Quoted 7 lines · Otavio Salvador

Hello,

One of nice features we've been using is the git-describe to get versions based on tags; many projects are using it to name the development releases and it does give a better view of how diverged it from last released version.

Quoted 5 lines
Quoted 3 lines

So we're looking for a way to use it to generate the PV based on that. The current git fetcher already has the required support to get tags, so we can use it as SRCREV, but not yet to use git-describe.

Do you have any examples of the output?

Sure:

otavio@neumann:~/hacking/ossystems/toscoterm$ git describe 
0.1-1-gd834119

Basically this can be read as:

- last version was 0.1
- since that we've done 1 commit
- the sha1sum of it is d834119 (g is always included before it)

Cheers,

Signature · 8 lines
        O T A V I O    S A L V A D O R
---------------------------------------------
 E-mail: [email protected]      UIN: 5906116
 GNU/Linux User: 239058     GPG ID: 49A5F855
 Home Page: http://otavio.ossystems.com.br
---------------------------------------------
"Microsoft sells you Windows ... Linux gives
 you the whole house."