summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMehdi Abaakouk <sileht@sileht.net>2018-03-19 20:39:08 +0100
committerMehdi Abaakouk <sileht@sileht.net>2018-03-20 07:50:15 +0100
commit67a62dbef422a84bda7faeeaeef4bc25fc85e29a (patch)
tree6fef84545a5456d6d1a71df528b792cc896f5f09
parentb7182bad424848e86abf1d747fad8327d7933920 (diff)
downloadsetuptools-scm-67a62dbef422a84bda7faeeaeef4bc25fc85e29a.tar.gz
git: ignore directory of the git archive output
Since 1.16.0, if the git project have subdirectory, bdist fails. This change ignores directory of "git archive" output to fix the issue. Fixes #228
-rw-r--r--setuptools_scm/git.py5
-rw-r--r--testing/test_git.py9
2 files changed, 12 insertions, 2 deletions
diff --git a/setuptools_scm/git.py b/setuptools_scm/git.py
index 6ec9962..83898ec 100644
--- a/setuptools_scm/git.py
+++ b/setuptools_scm/git.py
@@ -129,8 +129,9 @@ def _list_files_in_archive():
cmd = ['git', 'archive', 'HEAD']
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
tf = tarfile.open(fileobj=proc.stdout, mode='r|*')
- for name in tf.getnames():
- print(name)
+ for member in tf.getmembers():
+ if member.type != tarfile.DIRTYPE:
+ print(member.name)
if __name__ == "__main__":
diff --git a/testing/test_git.py b/testing/test_git.py
index 4f4ad53..e829fc8 100644
--- a/testing/test_git.py
+++ b/testing/test_git.py
@@ -124,3 +124,12 @@ def test_git_archive_export_ignore(wd):
wd('git add test1.txt test2.txt')
wd.commit()
assert integration.find_files(str(wd.cwd)) == ['test1.txt']
+
+
+@pytest.mark.issue(228)
+def test_git_archive_subdirectory(wd):
+ wd('mkdir foobar')
+ wd.write('foobar/test1.txt', 'test')
+ wd('git add foobar')
+ wd.commit()
+ assert integration.find_files(str(wd.cwd)) == ['foobar/test1.txt']