summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2012-07-06 15:55:19 +0300
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-04-03 09:46:11 +0300
commitf9ecd0686f55830f2d8d59e5bc83696131e8f7a1 (patch)
tree914dea43d08c443a5d156754e4d9c0a7a047aa83
parentfac2b7bf47730982eedbe8b389c4b972ed9d4536 (diff)
downloadgit-buildpackage-f9ecd0686f55830f2d8d59e5bc83696131e8f7a1.tar.gz
git-buildpackage-f9ecd0686f55830f2d8d59e5bc83696131e8f7a1.tar.bz2
git-buildpackage-f9ecd0686f55830f2d8d59e5bc83696131e8f7a1.zip
GitRepository/add_files: add new option 'untracked'
With this option you can either only update already tracked files to index the (untracked=False) or add new files, too. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r--gbp/git/repository.py5
-rw-r--r--tests/test_GitRepository.py6
2 files changed, 10 insertions, 1 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index 257b2b6d..cc2c3860 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -1104,7 +1104,7 @@ class GitRepository(object):
#{ 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
@@ -1112,6 +1112,8 @@ class GitRepository(object):
@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
"""
@@ -1119,6 +1121,7 @@ class GitRepository(object):
args = GitArgs()
args.add_true(force, '-f')
+ args.add_false(untracked, '-u')
args.add(paths)
if index_file:
diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py
index cd20aa06..3b6b924b 100644
--- a/tests/test_GitRepository.py
+++ b/tests/test_GitRepository.py
@@ -73,6 +73,7 @@ def test_add_files():
- 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}
@@ -85,7 +86,12 @@ def test_add_files():
False
>>> repo.is_clean(ignore_untracked=True)[0]
True
+ >>> repo.add_files(repo.path, 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