diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-10-25 18:27:28 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-10-26 10:00:54 +0200 |
commit | 15c5abf132004d3cf8c2f8ea732c3f851c3967e6 (patch) | |
tree | 88594b4af7817158306d979ac17d4534ba38b4ef | |
parent | 5edc376530f0601f5e2669a32aa26bf673193d34 (diff) | |
download | git-buildpackage-15c5abf132004d3cf8c2f8ea732c3f851c3967e6.tar.gz git-buildpackage-15c5abf132004d3cf8c2f8ea732c3f851c3967e6.tar.bz2 git-buildpackage-15c5abf132004d3cf8c2f8ea732c3f851c3967e6.zip |
GitRepository: extend list_files()
-rw-r--r-- | gbp/git.py | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -475,11 +475,25 @@ class GitRepository(object): else: return True - def index_files(self): - """List files in the index""" - out, ret = self.__git_getoutput('ls-files', ['-z']) + def list_files(self, types=['cached']): + """ + List files in index and working tree + + @param types: list of types to show + @type types: list + """ + all_types = [ 'cached', 'deleted', 'others', 'ignored', 'stage' + 'unmerged', 'killed', 'modified' ] + args = [ '-z' ] + + for t in types: + if t in all_types: + args += [ '--%s' % t ] + else: + raise GitRepositoryError("Unknown type '%s'" % t) + out, ret = self.__git_getoutput('ls-files', args) if ret: - raise GitRepositoryError, "Error listing files %d" % ret + raise GitRepositoryError("Error listing files: '%d'" % ret) if out: return [ file for file in out[0].split('\0') if file ] else: |