From 49103833dac62f780226239fb923b90812ab4695 Mon Sep 17 00:00:00 2001 From: Ilya Kulakov Date: Tue, 13 Nov 2018 10:46:18 -0800 Subject: [PATCH 1/3] Pass GIT_FLUSH via the env argument instead of command Fixes compatibility with cmd.exe Refs #62 --- git_archive_all.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/git_archive_all.py b/git_archive_all.py index afc28aa..e1f1fad 100755 --- a/git_archive_all.py +++ b/git_archive_all.py @@ -27,7 +27,7 @@ from __future__ import unicode_literals import logging -from os import extsep, path, readlink +from os import environ, extsep, path, readlink from subprocess import CalledProcessError, Popen, PIPE import sys import re @@ -356,8 +356,9 @@ def check_attr(cls, repo_abspath, attrs): @rtype: generator """ def make_process(): - cmd = 'GIT_FLUSH=1 git check-attr --stdin -z {0}'.format(' '.join(attrs)) - return Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, cwd=repo_abspath) + env = dict(environ, GIT_FLUSH='1') + cmd = 'git check-attr --stdin -z {0}'.format(' '.join(attrs)) + return Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, cwd=repo_abspath, env=env) def read_attrs(process, repo_file_path): process.stdin.write(repo_file_path.encode('utf-8') + b'\0') From d7f99ae63ae6900cc4c917087a0b33381d254aa0 Mon Sep 17 00:00:00 2001 From: Ilya Kulakov Date: Tue, 13 Nov 2018 12:46:14 -0800 Subject: [PATCH 2/3] Fix tests to modify environment transparently for the actual code. --- test_git_archive_all.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/test_git_archive_all.py b/test_git_archive_all.py index 9a948b8..bd57933 100644 --- a/test_git_archive_all.py +++ b/test_git_archive_all.py @@ -34,9 +34,10 @@ def git_env(tmpdir_factory): 2. Custom git user 3. .gitmodules file is ignored by default """ - e = deepcopy(os.environ) - e['GIT_CONFIG_NOSYSTEM'] = 'true' - e['HOME'] = str(tmpdir_factory.getbasetemp()) + e = { + 'GIT_CONFIG_NOSYSTEM': 'true', + 'HOME': str(tmpdir_factory.getbasetemp()) + } with tmpdir_factory.getbasetemp().join('.gitconfig').open('w+') as f: f.writelines([ @@ -74,9 +75,8 @@ def __setitem__(self, key, value): class Repo: - def __init__(self, path, git_env): + def __init__(self, path): self.path = os.path.abspath(path) - self.git_env = git_env def init(self): os.mkdir(self.path) @@ -98,7 +98,7 @@ def add_file(self, rel_path, contents): with open(file_path, 'w') as f: f.write(contents) - check_call(['git', 'add', file_path], cwd=self.path, env=self.git_env) + check_call(['git', 'add', file_path], cwd=self.path) return file_path def add_dir(self, rel_path, contents): @@ -108,20 +108,20 @@ def add_dir(self, rel_path, contents): for k, v in contents.items(): self.add(os.path.join(dir_path, k), v) - check_call(['git', 'add', dir_path], cwd=self.path, env=self.git_env) + check_call(['git', 'add', dir_path], cwd=self.path) return dir_path def add_submodule(self, rel_path, contents): submodule_path = os.path.join(self.path, rel_path) - r = Repo(submodule_path, self.git_env) + r = Repo(submodule_path) r.init() r.add_dir('.', contents) r.commit('init') - check_call(['git', 'submodule', 'add', submodule_path], cwd=self.path, env=self.git_env) + check_call(['git', 'submodule', 'add', submodule_path], cwd=self.path) return submodule_path def commit(self, message): - check_call(['git', 'commit', '-m', 'init'], cwd=self.path, env=self.git_env) + check_call(['git', 'commit', '-m', 'init'], cwd=self.path) def archive(self, path): a = GitArchiver(main_repo_abspath=self.path) @@ -265,12 +265,15 @@ def archive(self, path): pytest.param(quote_base, id="Quote"), pytest.param(quote_quoted, id="Quote (Quoted)") ]) -def test_ignore(contents, tmpdir, git_env): +def test_ignore(contents, tmpdir, git_env, monkeypatch): """ Ensure that GitArchiver respects export-ignore. """ + for name, value in git_env.items(): + monkeypatch.setenv(name, value) + repo_path = os.path.join(str(tmpdir), 'repo') - repo = Repo(repo_path, git_env) + repo = Repo(repo_path) repo.init() repo.add_dir('.', contents) repo.commit('init') From 65f1cf5859db4f89ad44cb1a199b75b915d25314 Mon Sep 17 00:00:00 2001 From: Ilya Kulakov Date: Tue, 13 Nov 2018 12:51:42 -0800 Subject: [PATCH 3/3] Add config for AppVeyor. --- .appveyor | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .appveyor diff --git a/.appveyor b/.appveyor new file mode 100644 index 0000000..3c33adb --- /dev/null +++ b/.appveyor @@ -0,0 +1,19 @@ +environment: + matrix: + - PYTHON: "C:\\Python26" + - PYTHON: "C:\\Python26-x64" + - PYTHON: "C:\\Python27" + - PYTHON: "C:\\Python27-x64" + - PYTHON: "C:\\Python34" + - PYTHON: "C:\\Python34-x64" + - PYTHON: "C:\\Python35" + - PYTHON: "C:\\Python35-x64" + - PYTHON: "C:\\Python36" + - PYTHON: "C:\\Python36-x64" + - PYTHON: "C:\\Python37" + - PYTHON: "C:\\Python37-x64" + +build: off + +test_script: + - "%PYTHON%\\python.exe -m setup.py test"