Skip to content

Commit

Permalink
Merge pull request #150 from gold2718/fix_combo_config
Browse files Browse the repository at this point in the history
fix to allow submodule name different from path
  • Loading branch information
jedwards4b authored Sep 18, 2020
2 parents 75f8f02 + b32c6fc commit 39ad532
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
18 changes: 15 additions & 3 deletions manic/externals_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,21 @@ def read_gitmodules_file(root_dir, file_name):
ExternalsDescription.REPO_URL, url)
externals_description.set(sec_name,
ExternalsDescription.REQUIRED, 'True')
git_hash = submods[sec_name]['hash']
externals_description.set(sec_name,
ExternalsDescription.HASH, git_hash)
if sec_name in submods:
submod_name = sec_name
else:
# The section name does not have to match the path
submod_name = path

if submod_name in submods:
git_hash = submods[submod_name]['hash']
externals_description.set(sec_name,
ExternalsDescription.HASH,
git_hash)
else:
emsg = "submodule status has no section, '{}'"
emsg += "\nCheck section names in externals config file"
fatal_error(emsg.format(submod_name))

# Required items
externals_description.add_section(DESCRIPTION_SECTION)
Expand Down
29 changes: 23 additions & 6 deletions test/test_sys_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import os
import os.path
import shutil
import sys
import unittest

from manic.externals_description import ExternalsDescription
Expand Down Expand Up @@ -557,12 +558,26 @@ def setUp(self):

self._test_id = self.id().split('.')[-1]

# find root
if os.path.exists(os.path.join(os.getcwd(), 'checkout_externals')):
root_dir = os.path.abspath(os.getcwd())
else:
# maybe we are in a subdir, search up
root_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir))
while os.path.basename(root_dir):
if os.path.exists(os.path.join(root_dir, 'checkout_externals')):
break
root_dir = os.path.dirname(root_dir)

if not os.path.exists(os.path.join(root_dir, 'checkout_externals')):
raise RuntimeError('Cannot find checkout_externals')

# path to the executable
self._checkout = os.path.join('../checkout_externals')
self._checkout = os.path.abspath(self._checkout)
self._checkout = os.path.join(root_dir, 'checkout_externals')

# directory where we have test repositories
self._bare_root = os.path.join(os.getcwd(), BARE_REPO_ROOT_NAME)
test_dir = os.path.join(root_dir, 'test')
self._bare_root = os.path.join(test_dir, BARE_REPO_ROOT_NAME)
self._bare_root = os.path.abspath(self._bare_root)

# set into the environment so var will be expanded in externals files
Expand Down Expand Up @@ -1700,8 +1715,9 @@ def setUp(self):
cwd = os.getcwd()
fork_repo_dir = os.path.join(self._bare_root, SIMPLE_FORK_NAME)
simple_repo_dir = os.path.join(self._bare_root, SIMPLE_REPO_NAME)
self._simple_ext_fork_name = SIMPLE_FORK_NAME.split('.')[0]
self._simple_ext_name = SIMPLE_REPO_NAME.split('.')[0]
self._simple_ext_fork_name = os.path.splitext(SIMPLE_FORK_NAME)[0]
self._simple_ext_name = os.path.join('sourc',
os.path.splitext(SIMPLE_REPO_NAME)[0])
os.chdir(self._repo_dir)
# Add a branch with a subrepo
cmd = ['git', 'branch', self._bare_branch_name, 'master']
Expand All @@ -1722,7 +1738,8 @@ def setUp(self):
execute_subprocess(cmd)
cmd = ['git', 'checkout', self._config_branch_name]
execute_subprocess(cmd)
cmd = ['git', 'submodule', 'add', simple_repo_dir]
cmd = ['git', 'submodule', 'add', '--name', SIMPLE_REPO_NAME,
simple_repo_dir, self._simple_ext_name]
execute_subprocess(cmd)
# Checkout feature2
os.chdir(self._simple_ext_name)
Expand Down

0 comments on commit 39ad532

Please sign in to comment.