summaryrefslogtreecommitdiff
path: root/lib/git/repo.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-10-16 13:05:01 +0200
committerSebastian Thiel <byronimo@gmail.com>2009-10-16 13:05:01 +0200
commit919164df96d9f956c8be712f33a9a037b097745b (patch)
tree92258654fb1e137d8b5234174ef10d9dd7c83cdc /lib/git/repo.py
parentf2df1f56cccab13d5c92abbc6b18be725e7b4833 (diff)
downloadgitpython-919164df96d9f956c8be712f33a9a037b097745b.tar.gz
repo.untracked_files added including test
Diffstat (limited to 'lib/git/repo.py')
-rw-r--r--lib/git/repo.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/git/repo.py b/lib/git/repo.py
index 554c10cb..6edb7f62 100644
--- a/lib/git/repo.py
+++ b/lib/git/repo.py
@@ -285,6 +285,37 @@ class Repo(object):
return False
return len(self.git.diff('HEAD', '--').strip()) > 0
+
+ @property
+ def untracked_files(self):
+ """
+ Returns
+ list(str,...)
+
+ Files currently untracked as they have not been staged yet. Paths
+ are relative to the current working directory of the git command.
+
+ Note
+ ignored files will not appear here, i.e. files mentioned in .gitignore
+ """
+ # make sure we get all files, no only untracked directores
+ proc = self.git.commit(untracked_files=True, as_process=True)
+ stream = iter(proc.stdout)
+ untracked_files = list()
+ for line in stream:
+ if not line.startswith("# Untracked files:"):
+ continue
+ # skip two lines
+ stream.next()
+ stream.next()
+
+ for untracked_info in stream:
+ if not untracked_info.startswith("#\t"):
+ break
+ untracked_files.append(untracked_info.replace("#\t", "").rstrip())
+ # END for each utracked info line
+ # END for each line
+ return untracked_files
@property
def active_branch(self):