Skip to content

Commit

Permalink
Merge pull request #1229 from HaoZeke/fixSubmoduleTest
Browse files Browse the repository at this point in the history
TST,BUG: Fix error with submodules
  • Loading branch information
mattip committed Jan 1, 2023
2 parents fccd193 + 7590857 commit 4d4a5a0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions asv/plugins/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ def pull(self):
def checkout(self, path, commit_hash):
def checkout_existing(display_error):
# Deinit fails if no submodules, so ignore its failure
self._run_git(['submodule', 'deinit', '-f', '.'],
self._run_git(['-c','protocol.file.allow=always', 'submodule', 'deinit', '-f', '.'],
cwd=path, display_error=False, valid_return_codes=None)
self._run_git(['checkout', '-f', commit_hash],
cwd=path, display_error=display_error)
self._run_git(['clean', '-fdx'],
cwd=path, display_error=display_error)
self._run_git(['submodule', 'update', '--init', '--recursive'],
self._run_git(['-c','protocol.file.allow=always', 'submodule', 'update', '--init', '--recursive'],
cwd=path, display_error=display_error)

if os.path.isdir(path):
Expand Down
6 changes: 3 additions & 3 deletions test/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,14 @@ def test_git_submodule(tmpdir):
commit_hash_0 = dvcs.get_hash("master")

# State 1 (one submodule)
dvcs.run_git(['submodule', 'add', sub_dvcs.path, 'sub1'])
dvcs.run_git(['-c','protocol.file.allow=always', 'submodule', 'add', sub_dvcs.path, 'sub1'])
dvcs.commit('Add sub1')
commit_hash_1 = dvcs.get_hash("master")

# State 2 (one submodule with sub-submodule)
dvcs.run_git(['submodule', 'update', '--init'])
dvcs.run_git(['-c','protocol.file.allow=always', 'submodule', 'update', '--init'])
sub1_dvcs = tools.Git(join(dvcs.path, 'sub1'))
sub_dvcs.run_git(['submodule', 'add', ssub_dvcs.path, 'ssub1'])
sub_dvcs.run_git(['-c','protocol.file.allow=always', 'submodule', 'add', ssub_dvcs.path, 'ssub1'])
sub_dvcs.commit('Add sub1')
sub1_dvcs.run_git(['pull'])
dvcs.run_git(['add', 'sub1'])
Expand Down
1 change: 1 addition & 0 deletions test/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def init(self):
self.run_git(['init'])
self.run_git(['config', 'user.email', 'robot@asv'])
self.run_git(['config', 'user.name', 'Robotic Swallow'])
self.run_git(['config', 'protocol.file.allow', 'always'])

def commit(self, message, date=None):
if date is None:
Expand Down

0 comments on commit 4d4a5a0

Please sign in to comment.