diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-16 13:05:01 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-16 13:05:01 +0200 |
commit | 919164df96d9f956c8be712f33a9a037b097745b (patch) | |
tree | 92258654fb1e137d8b5234174ef10d9dd7c83cdc /lib/git/repo.py | |
parent | f2df1f56cccab13d5c92abbc6b18be725e7b4833 (diff) | |
download | gitpython-919164df96d9f956c8be712f33a9a037b097745b.tar.gz |
repo.untracked_files added including test
Diffstat (limited to 'lib/git/repo.py')
-rw-r--r-- | lib/git/repo.py | 31 |
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): |