#{ Files
- def add_files(self, paths, force=False, index_file=None, work_tree=None):
+ def add_files(self, paths, force=False, untracked=True, index_file=None, work_tree=None):
"""
Add files to a the repository
@type paths: list or C{str}
@param force: add files even if they would be ignored by .gitignore
@type force: C{bool}
+ @param untracked: add also previously untracked files
+ @type untracked: C{bool}
@param index_file: alternative index file to use
@param work_tree: alternative working tree to use
"""
args = GitArgs()
args.add_true(force, '-f')
- args.add('-A')
+ args.add_cond(untracked, '-A', '-u')
args.add(paths)
if index_file:
- L{gbp.git.GitRepository.add_files}
- L{gbp.git.GitRepository.commit_all}
- L{gbp.git.GitRepository.is_clean}
+ - L{gbp.git.GitRepository.status}
Properties tested:
- L{gbp.git.GitRepository.head}
False
>>> repo.is_clean(ignore_untracked=True)[0]
True
+ >>> repo.add_files('testfile', force=True, untracked=False)
+ >>> repo.status().items()
+ [('??', ['testfile'])]
>>> repo.add_files(repo.path, force=True)
+ >>> repo.status().items()
+ [('A ', ['testfile'])]
>>> repo.commit_all(msg="foo")
>>> repo.is_clean()[0]
True