Skip to content

Commit

Permalink
Merge pull request #63 from Kentzo/issue-62
Browse files Browse the repository at this point in the history
  • Loading branch information
Kentzo authored Nov 13, 2018
2 parents b57d7b2 + 65f1cf5 commit be79f43
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 15 deletions.
19 changes: 19 additions & 0 deletions .appveyor
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 4 additions & 3 deletions git_archive_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
27 changes: 15 additions & 12 deletions test_git_archive_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -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)
Expand All @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit be79f43

Please sign in to comment.