Skip to content

Commit

Permalink
fix git status path for is_dirty (#15289)
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded authored Dec 18, 2023
1 parent 1cba305 commit 86557a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
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

0 comments on commit 86557a9

Please sign in to comment.