diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2012-07-06 15:55:19 +0300 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2014-06-05 14:20:04 +0300 |
commit | f000c937523a083c85df55736cb58c8da57b4d69 (patch) | |
tree | 116b544a305e1978190e1896b91aba61181e565c | |
parent | 45e9e6771288f0021eadcf87ea08f0a9c4e19063 (diff) | |
download | git-buildpackage-f000c937523a083c85df55736cb58c8da57b4d69.tar.gz git-buildpackage-f000c937523a083c85df55736cb58c8da57b4d69.tar.bz2 git-buildpackage-f000c937523a083c85df55736cb58c8da57b4d69.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.py | 6 | ||||
-rw-r--r-- | tests/test_GitRepository.py | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 02476722..6f10081f 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1323,7 +1323,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 @@ -1331,6 +1331,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 """ @@ -1338,7 +1340,7 @@ class GitRepository(object): args = GitArgs() args.add_true(force, '-f') - args.add('-A') + args.add_cond(untracked, '-A', '-u') args.add(paths) if index_file: diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py index f3a83ff3..b1a14326 100644 --- a/tests/test_GitRepository.py +++ b/tests/test_GitRepository.py @@ -68,6 +68,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} @@ -80,7 +81,12 @@ def test_add_files(): 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 |