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

Updated to use maxsplit=1 #17571

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion conan/tools/scm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ def is_dirty(self, repository=False):
return bool(status)
# Parse the status output, line by line, and match it with "_excluded"
lines = [line.strip() for line in status.splitlines()]
lines = [line.split()[1] for line in lines if line]
# line is of the form STATUS PATH, get the path by splitting
# (Taking into account that STATUS is one word, PATH might be many)
lines = [line.split(maxsplit=1)[1].strip('"') for line in lines if line]
lines = [line for line in lines if not any(fnmatch.fnmatch(line, p) for p in self._excluded)]
self._conanfile.output.debug(f"Filtered git status: {lines}")
return bool(lines)
Expand Down
5 changes: 3 additions & 2 deletions test/functional/tools/scm/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Pkg(ConanFile):
version = "0.1"

def export(self):
git = Git(self, self.recipe_folder, excluded=["myfile.txt", "mynew.txt"])
git = Git(self, self.recipe_folder, excluded=["myfile.txt", "mynew.txt", "file with spaces.txt"])
commit = git.get_commit()
repo_commit = git.get_commit(repository=True)
url = git.get_remote_url()
Expand Down Expand Up @@ -127,7 +127,8 @@ def test_git_excluded(self):
c.run("export . -vvv")
assert "pkg/0.1: DIRTY: False" in c.out
c.save({"myfile.txt": "changed",
"mynew.txt": "new"})
"mynew.txt": "new",
"file with spaces.txt": "hello"})
c.run("export .")
assert "pkg/0.1: DIRTY: False" in c.out
c.save({"other.txt": "new"})
Expand Down
Loading