summaryrefslogtreecommitdiffstats
path: root/bitbake-dev/lib/bb/fetch/git.py
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2009-05-11 22:59:35 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2009-05-11 22:59:35 +0100
commitc009172f77549e385b9d79f15f181581c55e9909 (patch)
treeaaf845578b30c67a2d3f4351afe29caa5e0ed235 /bitbake-dev/lib/bb/fetch/git.py
parent107a9da00640a9e086a8608c20aee48aefd92893 (diff)
downloadpoky-c009172f77549e385b9d79f15f181581c55e9909.tar.gz
bitbake-dev: Sync with upstream
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake-dev/lib/bb/fetch/git.py')
-rw-r--r--bitbake-dev/lib/bb/fetch/git.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/bitbake-dev/lib/bb/fetch/git.py b/bitbake-dev/lib/bb/fetch/git.py
index 010a4f57a2..6456403e14 100644
--- a/bitbake-dev/lib/bb/fetch/git.py
+++ b/bitbake-dev/lib/bb/fetch/git.py
@@ -20,11 +20,10 @@ BitBake 'Fetch' git implementation
20# with this program; if not, write to the Free Software Foundation, Inc., 20# with this program; if not, write to the Free Software Foundation, Inc.,
21# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 22
23import os, re 23import os
24import bb 24import bb
25from bb import data 25from bb import data
26from bb.fetch import Fetch 26from bb.fetch import Fetch
27from bb.fetch import FetchError
28from bb.fetch import runfetchcmd 27from bb.fetch import runfetchcmd
29 28
30class Git(Fetch): 29class Git(Fetch):
@@ -37,9 +36,12 @@ class Git(Fetch):
37 36
38 def localpath(self, url, ud, d): 37 def localpath(self, url, ud, d):
39 38
40 ud.proto = "rsync"
41 if 'protocol' in ud.parm: 39 if 'protocol' in ud.parm:
42 ud.proto = ud.parm['protocol'] 40 ud.proto = ud.parm['protocol']
41 elif not ud.host:
42 ud.proto = 'file'
43 else:
44 ud.proto = "rsync"
43 45
44 ud.branch = ud.parm.get("branch", "master") 46 ud.branch = ud.parm.get("branch", "master")
45 47
@@ -49,12 +51,9 @@ class Git(Fetch):
49 elif tag: 51 elif tag:
50 ud.tag = tag 52 ud.tag = tag
51 53
52 if not ud.tag: 54 if not ud.tag or ud.tag == "master":
53 ud.tag = self.latest_revision(url, ud, d) 55 ud.tag = self.latest_revision(url, ud, d)
54 56
55 if ud.tag == "master":
56 ud.tag = self.latest_revision(url, ud, d)
57
58 ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.tag), d) 57 ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.tag), d)
59 58
60 return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) 59 return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
@@ -90,11 +89,12 @@ class Git(Fetch):
90 89
91 os.chdir(repodir) 90 os.chdir(repodir)
92 # Remove all but the .git directory 91 # Remove all but the .git directory
93 runfetchcmd("rm * -Rf", d) 92 if not self._contains_ref(ud.tag, d):
94 runfetchcmd("git fetch %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.branch), d) 93 runfetchcmd("rm * -Rf", d)
95 runfetchcmd("git fetch --tags %s://%s%s%s" % (ud.proto, username, ud.host, ud.path), d) 94 runfetchcmd("git fetch %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.branch), d)
96 runfetchcmd("git prune-packed", d) 95 runfetchcmd("git fetch --tags %s://%s%s%s" % (ud.proto, username, ud.host, ud.path), d)
97 runfetchcmd("git pack-redundant --all | xargs -r rm", d) 96 runfetchcmd("git prune-packed", d)
97 runfetchcmd("git pack-redundant --all | xargs -r rm", d)
98 98
99 os.chdir(repodir) 99 os.chdir(repodir)
100 mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) 100 mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True)
@@ -120,6 +120,10 @@ class Git(Fetch):
120 def suppports_srcrev(self): 120 def suppports_srcrev(self):
121 return True 121 return True
122 122
123 def _contains_ref(self, tag, d):
124 output = runfetchcmd("git log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % tag, d, quiet=True)
125 return output.split()[0] != "0"
126
123 def _revision_key(self, url, ud, d): 127 def _revision_key(self, url, ud, d):
124 """ 128 """
125 Return a unique key for the url 129 Return a unique key for the url