Skip to content

Commit

Permalink
Try a different workaround
Browse files Browse the repository at this point in the history
If we set the environment variable maybe we won't need to pass the -c to
multiple commands.

(The previous workaround fixed the git submodule add, but git submodule
update --init --recursive remained broken).
  • Loading branch information
mgedmin committed Oct 22, 2022
1 parent 3fc1989 commit 1ce75c4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests.py
Expand Up @@ -929,6 +929,7 @@ class VCSHelper:

# override in subclasses
command = None # type: Optional[str]
extra_env = {}

@property
def version(self):
Expand Down Expand Up @@ -959,7 +960,8 @@ def _run(self, *command):
command = [s.encode(locale.getpreferredencoding()) for s in command]
print('$', ' '.join(command))
p = subprocess.Popen(command, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stderr=subprocess.STDOUT,
env={**os.environ, **self.extra_env})
stdout, stderr = p.communicate()
rc = p.wait()
if stdout:
Expand Down Expand Up @@ -1061,6 +1063,9 @@ def test_get_vcs_files_empty(self):
class GitHelper(VCSHelper):

command = 'git'
extra_env = dict(
GIT_ALLOW_PROTOCOL='file',
)

def _init_vcs(self):
if self.version_tuple >= (2, 28):
Expand Down Expand Up @@ -1093,8 +1098,7 @@ def _init_repo_with_files(self, dirname, filenames):

def _add_submodule(self, repo, subdir, subrepo):
os.chdir(repo)
self.vcs._run('git', '-c', 'protocol.file.allow=always',
'submodule', 'add', subrepo, subdir)
self.vcs._run('git', 'submodule', 'add', subrepo, subdir)
self._commit()
os.chdir(self.tmpdir)

Expand Down

0 comments on commit 1ce75c4

Please sign in to comment.