Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

is_dirty supports path. Fixes #482.#496

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 1 commit intogitpython-developers:masterfromhaizaar:master
Aug 2, 2016
Merged
Show file tree
Hide file tree
Changes fromall 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
11 changes: 7 additions & 4 deletionsgit/repo/base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -585,7 +585,7 @@ def _set_alternates(self, alts):
doc="Retrieve a list of alternates paths or set a list paths to be used as alternates")

def is_dirty(self, index=True, working_tree=True, untracked_files=False,
submodules=True):
submodules=True, path=None):
"""
:return:
``True``, the repository is considered dirty. By default it will react
Expand All@@ -600,6 +600,8 @@ def is_dirty(self, index=True, working_tree=True, untracked_files=False,
default_args = ['--abbrev=40', '--full-index', '--raw']
if not submodules:
default_args.append('--ignore-submodules')
if path:
default_args.append(path)
if index:
# diff index against HEAD
if isfile(self.index.path) and \
Expand All@@ -612,7 +614,7 @@ def is_dirty(self, index=True, working_tree=True, untracked_files=False,
return True
# END working tree handling
if untracked_files:
if len(self._get_untracked_files(ignore_submodules=not submodules)):
if len(self._get_untracked_files(path,ignore_submodules=not submodules)):
return True
# END untracked files
return False
Expand All@@ -633,9 +635,10 @@ def untracked_files(self):
consider caching it yourself."""
return self._get_untracked_files()

def _get_untracked_files(self, **kwargs):
def _get_untracked_files(self, *args, **kwargs):
# make sure we get all files, no only untracked directores
proc = self.git.status(porcelain=True,
proc = self.git.status(*args,
porcelain=True,
untracked_files=True,
as_process=True,
**kwargs)
Expand Down
18 changes: 18 additions & 0 deletionsgit/test/test_repo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -271,6 +271,24 @@ def test_is_dirty(self):
assert self.rorepo.is_dirty() is False
self.rorepo._bare = orig_val

@with_rw_repo('HEAD')
def test_is_dirty_with_path(self, rwrepo):
assert rwrepo.is_dirty(path="git") is False

with open(os.path.join(rwrepo.working_dir, "git", "util.py"), "at") as f:
f.write("junk")
assert rwrepo.is_dirty(path="git") is True
assert rwrepo.is_dirty(path="doc") is False

rwrepo.git.add(os.path.join("git", "util.py"))
assert rwrepo.is_dirty(index=False, path="git") is False
assert rwrepo.is_dirty(path="git") is True

with open(os.path.join(rwrepo.working_dir, "doc", "no-such-file.txt"), "wt") as f:
f.write("junk")
assert rwrepo.is_dirty(path="doc") is False
assert rwrepo.is_dirty(untracked_files=True, path="doc") is True

def test_head(self):
assert self.rorepo.head.reference.object == self.rorepo.active_branch.object

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp