summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/fetch2/gitsm.py17
-rw-r--r--bitbake/lib/bb/tests/fetch.py31
2 files changed, 38 insertions, 10 deletions
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
index a95584c821..0aff1008e5 100644
--- a/bitbake/lib/bb/fetch2/gitsm.py
+++ b/bitbake/lib/bb/fetch2/gitsm.py
@@ -117,14 +117,19 @@ class GitSM(Git):
117 def download(self, ud, d): 117 def download(self, ud, d):
118 Git.download(self, ud, d) 118 Git.download(self, ud, d)
119 119
120 submodules = self.uses_submodules(ud, d, ud.clonedir) 120 if not ud.shallow or ud.localpath != ud.fullshallow:
121 if submodules: 121 submodules = self.uses_submodules(ud, d, ud.clonedir)
122 self.update_submodules(ud, d) 122 if submodules:
123 self.update_submodules(ud, d)
124
125 def clone_shallow_local(self, ud, dest, d):
126 super(GitSM, self).clone_shallow_local(ud, dest, d)
127
128 runfetchcmd('cp -fpPRH "%s/modules" "%s/"' % (ud.clonedir, os.path.join(dest, '.git')), d)
123 129
124 def unpack(self, ud, destdir, d): 130 def unpack(self, ud, destdir, d):
125 Git.unpack(self, ud, destdir, d) 131 Git.unpack(self, ud, destdir, d)
126 132
127 submodules = self.uses_submodules(ud, d, ud.destdir) 133 if self.uses_submodules(ud, d, ud.destdir):
128 if submodules:
129 runfetchcmd(ud.basecmd + " checkout " + ud.revisions[ud.names[0]], d, workdir=ud.destdir) 134 runfetchcmd(ud.basecmd + " checkout " + ud.revisions[ud.names[0]], d, workdir=ud.destdir)
130 runfetchcmd(ud.basecmd + " submodule update --init --recursive", d, workdir=ud.destdir) 135 runfetchcmd(ud.basecmd + " submodule update --init --recursive", d, workdir=ud.destdir)
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 3e2ce53056..2a9019b05f 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -1027,12 +1027,14 @@ class GitShallowTest(FetcherTest):
1027 cwd = self.gitdir 1027 cwd = self.gitdir
1028 return bb.process.run(cmd, cwd=cwd)[0] 1028 return bb.process.run(cmd, cwd=cwd)[0]
1029 1029
1030 def add_empty_file(self, path, msg=None): 1030 def add_empty_file(self, path, cwd=None, msg=None):
1031 if msg is None: 1031 if msg is None:
1032 msg = path 1032 msg = path
1033 open(os.path.join(self.srcdir, path), 'w').close() 1033 if cwd is None:
1034 self.git(['add', path], self.srcdir) 1034 cwd = self.srcdir
1035 self.git(['commit', '-m', msg, path], self.srcdir) 1035 open(os.path.join(cwd, path), 'w').close()
1036 self.git(['add', path], cwd)
1037 self.git(['commit', '-m', msg, path], cwd)
1036 1038
1037 def fetch(self, uri=None): 1039 def fetch(self, uri=None):
1038 if uri is None: 1040 if uri is None:
@@ -1211,6 +1213,27 @@ class GitShallowTest(FetcherTest):
1211 self.assertRefs(['master', 'origin/master']) 1213 self.assertRefs(['master', 'origin/master'])
1212 self.assertRevCount(1) 1214 self.assertRevCount(1)
1213 1215
1216 def test_shallow_submodules(self):
1217 self.add_empty_file('a')
1218 self.add_empty_file('b')
1219
1220 smdir = os.path.join(self.tempdir, 'gitsubmodule')
1221 bb.utils.mkdirhier(smdir)
1222 self.git('init', cwd=smdir)
1223 self.add_empty_file('asub', cwd=smdir)
1224
1225 self.git('submodule init', cwd=self.srcdir)
1226 self.git('submodule add file://%s' % smdir, cwd=self.srcdir)
1227 self.git('submodule update', cwd=self.srcdir)
1228 self.git('commit -m submodule -a', cwd=self.srcdir)
1229
1230 uri = 'gitsm://%s;protocol=file;subdir=${S}' % self.srcdir
1231 fetcher, ud = self.fetch_shallow(uri)
1232
1233 self.assertRevCount(1)
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'))
1236
1214 def test_shallow_multi_one_uri(self): 1237 def test_shallow_multi_one_uri(self):
1215 # Create initial git repo 1238 # Create initial git repo
1216 self.add_empty_file('a') 1239 self.add_empty_file('a')