Treat requirements special in the superrepo
We don't want to try and make a requirements package. But we do want to use it as the source of constraints for all the collected repos. Change-Id: I984f71f81451f0695d7e86a6cfccc555a89c4ee7
This commit is contained in:
parent
8a9592d40e
commit
169b858a83
@ -13,7 +13,6 @@
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
|
||||
import os
|
||||
|
||||
import git
|
||||
@ -57,6 +56,14 @@ class BuildSpec(object):
|
||||
# Nope, detach head
|
||||
repo.head.reference = repo.commit(self.version)
|
||||
for subdir in os.listdir(repo.working_tree_dir):
|
||||
# requirements is special
|
||||
if subdir == 'requirements':
|
||||
reqdir = os.path.join(
|
||||
repo.working_tree_dir, 'requirements')
|
||||
reqfile = os.path.join(reqdir, 'upper-constraints.txt')
|
||||
if reqfile not in self.settings.constraints:
|
||||
self.settings.constraints.append(reqfile)
|
||||
continue
|
||||
# Skip any projects explicitly in the manifest
|
||||
if subdir in existing_project_names:
|
||||
continue
|
||||
|
@ -65,7 +65,8 @@ class TestBuildSpec(unittest.TestCase):
|
||||
|
||||
@utils.make_test_repo("parentrepo")
|
||||
@utils.make_test_repo("childrepo")
|
||||
def test_build_spec_superrepo(self, parentrepo, childrepo):
|
||||
@utils.make_test_repo("reqrepo")
|
||||
def test_build_spec_superrepo(self, parentrepo, childrepo, reqrepo):
|
||||
parentrepo = git.Repo(parentrepo)
|
||||
childname = os.path.basename(childrepo)
|
||||
with open(os.path.join(childrepo, 'setup.py'), 'w') as setup:
|
||||
@ -76,6 +77,14 @@ class TestBuildSpec(unittest.TestCase):
|
||||
parentrepo.create_submodule(childname, childname,
|
||||
url=childrepo.working_tree_dir)
|
||||
parentrepo.index.commit('adding child repo')
|
||||
constraints_path = os.path.join(reqrepo, 'upper-constraints.txt')
|
||||
with open(constraints_path, 'w') as cf:
|
||||
cf.write("foo==1.0\n{}==11.0\n".format(childname))
|
||||
reqrepo = git.Repo(reqrepo)
|
||||
reqrepo.index.add(['upper-constraints.txt'])
|
||||
reqrepo.index.commit('adding upper constraints')
|
||||
parentrepo.create_submodule('requirements', 'requirements',
|
||||
url=reqrepo.working_tree_dir)
|
||||
parenthash = parentrepo.head.commit.hexsha
|
||||
childhash = childrepo.head.commit.hexsha
|
||||
manifest = {
|
||||
@ -91,3 +100,7 @@ class TestBuildSpec(unittest.TestCase):
|
||||
self.assertEqual(childhash, bs.projects[0].gitref)
|
||||
child_path = os.path.join(parentrepo.working_tree_dir, childname)
|
||||
self.assertEqual(child_path, bs.projects[0].giturl)
|
||||
constraints_added = os.path.join(parentrepo.working_tree_dir,
|
||||
'requirements',
|
||||
'upper-constraints.txt')
|
||||
self.assertIn(constraints_added, bs.settings.constraints)
|
||||
|
Loading…
Reference in New Issue
Block a user