Skip to content

Commit a547332

Browse files
Merge pull request #227 from sileht/master
git: ignore directory of the git archive output
2 parents b7182ba + 67a62db commit a547332

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

setuptools_scm/git.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ def _list_files_in_archive():
129129
cmd = ['git', 'archive', 'HEAD']
130130
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
131131
tf = tarfile.open(fileobj=proc.stdout, mode='r|*')
132-
for name in tf.getnames():
133-
print(name)
132+
for member in tf.getmembers():
133+
if member.type != tarfile.DIRTYPE:
134+
print(member.name)
134135

135136

136137
if __name__ == "__main__":

testing/test_git.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,12 @@ def test_git_archive_export_ignore(wd):
124124
wd('git add test1.txt test2.txt')
125125
wd.commit()
126126
assert integration.find_files(str(wd.cwd)) == ['test1.txt']
127+
128+
129+
@pytest.mark.issue(228)
130+
def test_git_archive_subdirectory(wd):
131+
wd('mkdir foobar')
132+
wd.write('foobar/test1.txt', 'test')
133+
wd('git add foobar')
134+
wd.commit()
135+
assert integration.find_files(str(wd.cwd)) == ['foobar/test1.txt']

0 commit comments

Comments
 (0)