[bitbake-devel,8/9] fetch2/git: move generation of git source name into own method

Submitted by Urs Fässler on July 23, 2018, 3:42 p.m. | Patch ID: 152884

Details

Message ID 20180723154259.9076-9-urs.fassler@bbv.ch
State New
Headers show

Commit Message

Urs Fässler July 23, 2018, 3:42 p.m.
Signed-off-by: Urs Fässler <urs.fassler@bbv.ch>
Signed-off-by: Pascal Bach <pascal.bach@siemens.com>
---
 lib/bb/fetch2/git.py | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 7f7951f7..f9e31d2b 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -248,17 +248,7 @@  class Git(FetchMethod):
                     ud.unresolvedrev[name] = ud.revisions[name]
                 ud.revisions[name] = self.latest_revision(ud, d, name)
 
-        gitsrcname = '%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.'))
-        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
-        # upstream repo in the future, the mirror will remain intact and still
-        # contains the revision
-        if ud.rebaseable:
-            for name in ud.names:
-                gitsrcname = gitsrcname + '_' + ud.revisions[name]
+        gitsrcname = self.__build_git_source_name(ud.host, ud.path, ud.rebaseable, ud.names, ud.revisions)
 
         dl_dir = d.getVar("DL_DIR")
         gitdir = d.getVar("GITDIR") or (dl_dir + "/git2")
@@ -295,6 +285,22 @@  class Git(FetchMethod):
             ud.fullshallow = os.path.join(dl_dir, ud.shallowtarball)
             ud.mirrortarballs.insert(0, ud.shallowtarball)
 
+    @staticmethod
+    def __build_git_source_name(host, path, rebaseable, names, revisions):
+        gitsrcname = '%s%s' % (host.replace(':', '.'), path.replace('/', '.').replace('*', '.'))
+        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
+        # upstream repo in the future, the mirror will remain intact and still
+        # contains the revision
+        if rebaseable:
+            for name in names:
+                gitsrcname = gitsrcname + '_' + revisions[name]
+
+        return gitsrcname
+
     def localpath(self, ud, d):
         return ud.clonedir