| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4896fa2 commit c3c70da
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -585,7 +585,7 @@ def _set_alternates(self, alts): | |||
| 585 | 585 | doc="Retrieve a list of alternates paths or set a list paths to be used as alternates") | |
| 586 | 586 | ||
| 587 | 587 | def is_dirty(self, index=True, working_tree=True, untracked_files=False, | |
| 588 | - submodules=True): | ||
| 588 | + submodules=True, path=None): | ||
| 589 | 589 | """ | |
| 590 | 590 | :return: | |
| 591 | 591 | ``True``, the repository is considered dirty. By default it will react | |
@@ -600,6 +600,8 @@ def is_dirty(self, index=True, working_tree=True, untracked_files=False, | |||
| 600 | 600 | default_args = ['--abbrev=40', '--full-index', '--raw'] | |
| 601 | 601 | if not submodules: | |
| 602 | 602 | default_args.append('--ignore-submodules') | |
| 603 | + if path: | ||
| 604 | + default_args.append(path) | ||
| 603 | 605 | if index: | |
| 604 | 606 | # diff index against HEAD | |
| 605 | 607 | if isfile(self.index.path) and \ | |
@@ -612,7 +614,7 @@ def is_dirty(self, index=True, working_tree=True, untracked_files=False, | |||
| 612 | 614 | return True | |
| 613 | 615 | # END working tree handling | |
| 614 | 616 | if untracked_files: | |
| 615 | - if len(self._get_untracked_files(ignore_submodules=not submodules)): | ||
| 617 | + if len(self._get_untracked_files(path, ignore_submodules=not submodules)): | ||
| 616 | 618 | return True | |
| 617 | 619 | # END untracked files | |
| 618 | 620 | return False | |
@@ -633,9 +635,10 @@ def untracked_files(self): | |||
| 633 | 635 | consider caching it yourself.""" | |
| 634 | 636 | return self._get_untracked_files() | |
| 635 | 637 | ||
| 636 | - def _get_untracked_files(self, **kwargs): | ||
| 638 | + def _get_untracked_files(self, *args, **kwargs): | ||
| 637 | 639 | # make sure we get all files, no only untracked directores | |
| 638 | - proc = self.git.status(porcelain=True, | ||
| 640 | + proc = self.git.status(*args, | ||
| 641 | + porcelain=True, | ||
| 639 | 642 | untracked_files=True, | |
| 640 | 643 | as_process=True, | |
| 641 | 644 | **kwargs) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -271,6 +271,24 @@ def test_is_dirty(self): | |||
| 271 | 271 | assert self.rorepo.is_dirty() is False | |
| 272 | 272 | self.rorepo._bare = orig_val | |
| 273 | 273 | ||
| 274 | + @with_rw_repo('HEAD') | ||
| 275 | + def test_is_dirty_with_path(self, rwrepo): | ||
| 276 | + assert rwrepo.is_dirty(path="git") is False | ||
| 277 | + | ||
| 278 | + with open(os.path.join(rwrepo.working_dir, "git", "util.py"), "at") as f: | ||
| 279 | + f.write("junk") | ||
| 280 | + assert rwrepo.is_dirty(path="git") is True | ||
| 281 | + assert rwrepo.is_dirty(path="doc") is False | ||
| 282 | + | ||
| 283 | + rwrepo.git.add(os.path.join("git", "util.py")) | ||
| 284 | + assert rwrepo.is_dirty(index=False, path="git") is False | ||
| 285 | + assert rwrepo.is_dirty(path="git") is True | ||
| 286 | + | ||
| 287 | + with open(os.path.join(rwrepo.working_dir, "doc", "no-such-file.txt"), "wt") as f: | ||
| 288 | + f.write("junk") | ||
| 289 | + assert rwrepo.is_dirty(path="doc") is False | ||
| 290 | + assert rwrepo.is_dirty(untracked_files=True, path="doc") is True | ||
| 291 | + | ||
| 274 | 292 | def test_head(self): | |
| 275 | 293 | assert self.rorepo.head.reference.object == self.rorepo.active_branch.object | |
| 276 | 294 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments