diff options
| -rw-r--r-- | bitbake/lib/bb/fetch2/gitannex.py | 23 | ||||
| -rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 17 |
2 files changed, 37 insertions, 3 deletions
diff --git a/bitbake/lib/bb/fetch2/gitannex.py b/bitbake/lib/bb/fetch2/gitannex.py index c66c211428..a9b69caab4 100644 --- a/bitbake/lib/bb/fetch2/gitannex.py +++ b/bitbake/lib/bb/fetch2/gitannex.py | |||
| @@ -33,6 +33,11 @@ class GitANNEX(Git): | |||
| 33 | """ | 33 | """ |
| 34 | return ud.type in ['gitannex'] | 34 | return ud.type in ['gitannex'] |
| 35 | 35 | ||
| 36 | def urldata_init(self, ud, d): | ||
| 37 | super(GitANNEX, self).urldata_init(ud, d) | ||
| 38 | if ud.shallow: | ||
| 39 | ud.shallow_extra_refs += ['refs/heads/git-annex', 'refs/heads/synced/*'] | ||
| 40 | |||
| 36 | def uses_annex(self, ud, d, wd): | 41 | def uses_annex(self, ud, d, wd): |
| 37 | for name in ud.names: | 42 | for name in ud.names: |
| 38 | try: | 43 | try: |
| @@ -55,9 +60,21 @@ class GitANNEX(Git): | |||
| 55 | def download(self, ud, d): | 60 | def download(self, ud, d): |
| 56 | Git.download(self, ud, d) | 61 | Git.download(self, ud, d) |
| 57 | 62 | ||
| 58 | annex = self.uses_annex(ud, d, ud.clonedir) | 63 | if not ud.shallow or ud.localpath != ud.fullshallow: |
| 59 | if annex: | 64 | if self.uses_annex(ud, d, ud.clonedir): |
| 60 | self.update_annex(ud, d, ud.clonedir) | 65 | self.update_annex(ud, d, ud.clonedir) |
| 66 | |||
| 67 | def clone_shallow_local(self, ud, dest, d): | ||
| 68 | super(GitANNEX, self).clone_shallow_local(ud, dest, d) | ||
| 69 | |||
| 70 | try: | ||
| 71 | runfetchcmd("%s annex init" % ud.basecmd, d, workdir=dest) | ||
| 72 | except bb.fetch.FetchError: | ||
| 73 | pass | ||
| 74 | |||
| 75 | if self.uses_annex(ud, d, dest): | ||
| 76 | runfetchcmd("%s annex get" % ud.basecmd, d, workdir=dest) | ||
| 77 | runfetchcmd("chmod u+w -R %s/.git/annex" % (dest), d, quiet=True, workdir=dest) | ||
| 61 | 78 | ||
| 62 | def unpack(self, ud, destdir, d): | 79 | def unpack(self, ud, destdir, d): |
| 63 | Git.unpack(self, ud, destdir, d) | 80 | Git.unpack(self, ud, destdir, d) |
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 2a9019b05f..73f7b3f78e 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
| @@ -1234,6 +1234,23 @@ class GitShallowTest(FetcherTest): | |||
| 1234 | assert './.git/modules/' in bb.process.run('tar -tzf %s' % os.path.join(self.dldir, ud.mirrortarballs[0]))[0] | 1234 | assert './.git/modules/' in bb.process.run('tar -tzf %s' % os.path.join(self.dldir, ud.mirrortarballs[0]))[0] |
| 1235 | assert os.listdir(os.path.join(self.gitdir, 'gitsubmodule')) | 1235 | assert os.listdir(os.path.join(self.gitdir, 'gitsubmodule')) |
| 1236 | 1236 | ||
| 1237 | if any(os.path.exists(os.path.join(p, 'git-annex')) for p in os.environ.get('PATH').split(':')): | ||
| 1238 | def test_shallow_annex(self): | ||
| 1239 | self.add_empty_file('a') | ||
| 1240 | self.add_empty_file('b') | ||
| 1241 | self.git('annex init', cwd=self.srcdir) | ||
| 1242 | open(os.path.join(self.srcdir, 'c'), 'w').close() | ||
| 1243 | self.git('annex add c', cwd=self.srcdir) | ||
| 1244 | self.git('commit -m annex-c -a', cwd=self.srcdir) | ||
| 1245 | bb.process.run('chmod u+w -R %s' % os.path.join(self.srcdir, '.git', 'annex')) | ||
| 1246 | |||
| 1247 | uri = 'gitannex://%s;protocol=file;subdir=${S}' % self.srcdir | ||
| 1248 | fetcher, ud = self.fetch_shallow(uri) | ||
| 1249 | |||
| 1250 | self.assertRevCount(1) | ||
| 1251 | assert './.git/annex/' in bb.process.run('tar -tzf %s' % os.path.join(self.dldir, ud.mirrortarballs[0]))[0] | ||
| 1252 | assert os.path.exists(os.path.join(self.gitdir, 'c')) | ||
| 1253 | |||
| 1237 | def test_shallow_multi_one_uri(self): | 1254 | def test_shallow_multi_one_uri(self): |
| 1238 | # Create initial git repo | 1255 | # Create initial git repo |
| 1239 | self.add_empty_file('a') | 1256 | self.add_empty_file('a') |
