Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/gitignored folders #3375

Merged
merged 9 commits into from
Aug 20, 2018
8 changes: 5 additions & 3 deletions conans/client/tools/scm.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ def checkout(self, element, submodule=None):

def excluded_files(self):
try:
file_paths = [os.path.normpath(os.path.join(os.path.relpath(folder, self.folder), f))
for folder, _, fs in os.walk(self.folder) for f in fs]

file_paths = [os.path.normpath(os.path.join(os.path.relpath(folder, self.folder), el)).replace("\\", "/")
for folder, dirpaths, fs in os.walk(self.folder)
for el in fs + dirpaths]
p = subprocess.Popen(['git', 'check-ignore', '--stdin'],
stdout=PIPE, stdin=PIPE, stderr=STDOUT, cwd=self.folder)
paths = to_file_bytes('\n'.join(file_paths))
paths = to_file_bytes("\n".join(file_paths))
grep_stdout = decode_text(p.communicate(input=paths)[0])
tmp = grep_stdout.splitlines()
except CalledProcessError:
Expand Down
14 changes: 12 additions & 2 deletions conans/test/functional/scm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,20 @@ def test_deleted_source_folder(self):
self.assertTrue(error)
self.assertIn("Getting sources from url: '%s'" % path.replace("\\", "/"), self.client.out)

def test_excluded_repo_fies(self):
def test_excluded_repo_files(self):
conanfile = base.format(url="auto", revision="auto")
conanfile = conanfile.replace("short_paths = True", "short_paths = False")
path, commit = create_local_git_repo({"myfile": "contents",
"ignored.pyc": "bin",
".gitignore": "*.pyc\n",
".gitignore": """
*.pyc
my_excluded_folder
other_folder/excluded_subfolder
""",
"myfile.txt": "My file!",
"my_excluded_folder/some_file": "hey Apple!",
"other_folder/excluded_subfolder/some_file": "hey Apple!",
"other_folder/valid_file": "!",
"conanfile.py": conanfile}, branch="my_release")
self.client.current_folder = path
self._commit_contents()
Expand All @@ -186,6 +193,9 @@ def test_excluded_repo_fies(self):
self.assertTrue(os.path.exists(os.path.join(bf, "myfile")))
self.assertTrue(os.path.exists(os.path.join(bf, ".git")))
self.assertFalse(os.path.exists(os.path.join(bf, "ignored.pyc")))
self.assertFalse(os.path.exists(os.path.join(bf, "my_excluded_folder")))
self.assertTrue(os.path.exists(os.path.join(bf, "other_folder", "valid_file")))
self.assertFalse(os.path.exists(os.path.join(bf, "other_folder", "excluded_subfolder")))

def test_local_source(self):
curdir = self.client.current_folder
Expand Down