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

fix git status path for is_dirty #15289

Merged
merged 1 commit into from
Dec 18, 2023
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
2 changes: 1 addition & 1 deletion conan/tools/scm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def is_dirty(self):

:return: True, if the current folder is dirty. Otherwise, False.
"""
status = self.run("status -s").strip()
status = self.run(f"status . -s").strip()
return bool(status)

def get_url_and_commit(self, remote="origin"):
Expand Down
18 changes: 17 additions & 1 deletion conans/test/functional/tools/scm/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ def test_capture_remote_pushed_commit(self):
assert "pkg/0.1: COMMIT IN REMOTE: True" in c.out
assert "pkg/0.1: DIRTY: False" in c.out

def test_capture_commit_local_subfolder(self):
"""
A local repo, without remote, will have commit, but no URL, and sibling folders
can be dirty, no prob
"""
c = TestClient()
c.save({"subfolder/conanfile.py": self.conanfile,
"other/myfile.txt": "content"})
commit = c.init_git_repo()
c.save({"other/myfile.txt": "change content"})
c.run("export subfolder")
assert "pkg/0.1: COMMIT: {}".format(commit) in c.out
assert "pkg/0.1: URL: None" in c.out
assert "pkg/0.1: COMMIT IN REMOTE: False" in c.out
assert "pkg/0.1: DIRTY: False" in c.out


@pytest.mark.tool("git")
class TestGitCaptureSCM:
Expand Down Expand Up @@ -960,4 +976,4 @@ def test_detect_commit_not_in_remote(self):
assert "pkg/0.1: COMMIT: {}".format(new_commit) in c.out
assert "pkg/0.1: URL: {}".format(url) in c.out
assert "pkg/0.1: COMMIT IN REMOTE: False" in c.out
assert "pkg/0.1: DIRTY: False" in c.out
assert "pkg/0.1: DIRTY: False" in c.out