diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2009-05-11 22:59:35 +0100 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2009-05-11 22:59:35 +0100 |
commit | c009172f77549e385b9d79f15f181581c55e9909 (patch) | |
tree | aaf845578b30c67a2d3f4351afe29caa5e0ed235 /bitbake-dev/lib/bb/fetch/git.py | |
parent | 107a9da00640a9e086a8608c20aee48aefd92893 (diff) | |
download | openembedded-core-c009172f77549e385b9d79f15f181581c55e9909.tar.gz openembedded-core-c009172f77549e385b9d79f15f181581c55e9909.tar.bz2 openembedded-core-c009172f77549e385b9d79f15f181581c55e9909.zip |
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.py | 28 |
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 # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -import os, re +import os import bb from bb import data from bb.fetch import Fetch -from bb.fetch import FetchError from bb.fetch import runfetchcmd class Git(Fetch): @@ -37,9 +36,12 @@ class Git(Fetch): def localpath(self, url, ud, d): - ud.proto = "rsync" if 'protocol' in ud.parm: ud.proto = ud.parm['protocol'] + elif not ud.host: + ud.proto = 'file' + else: + ud.proto = "rsync" ud.branch = ud.parm.get("branch", "master") @@ -49,12 +51,9 @@ class Git(Fetch): elif tag: ud.tag = tag - if not ud.tag: + if not ud.tag or ud.tag == "master": ud.tag = self.latest_revision(url, ud, d) - if 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) return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) @@ -90,11 +89,12 @@ class Git(Fetch): os.chdir(repodir) # Remove all but the .git directory - runfetchcmd("rm * -Rf", d) - runfetchcmd("git fetch %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.branch), d) - runfetchcmd("git fetch --tags %s://%s%s%s" % (ud.proto, username, ud.host, ud.path), d) - runfetchcmd("git prune-packed", d) - runfetchcmd("git pack-redundant --all | xargs -r rm", d) + if not self._contains_ref(ud.tag, d): + runfetchcmd("rm * -Rf", d) + runfetchcmd("git fetch %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.branch), d) + runfetchcmd("git fetch --tags %s://%s%s%s" % (ud.proto, username, ud.host, ud.path), d) + runfetchcmd("git prune-packed", d) + runfetchcmd("git pack-redundant --all | xargs -r rm", d) os.chdir(repodir) mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) @@ -120,6 +120,10 @@ class Git(Fetch): def suppports_srcrev(self): return True + def _contains_ref(self, tag, d): + output = runfetchcmd("git log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % tag, d, quiet=True) + return output.split()[0] != "0" + def _revision_key(self, url, ud, d): """ Return a unique key for the url |