diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-09-04 11:58:21 +0300 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2013-09-04 22:36:31 +0200 |
commit | bc409569f58a2c9c1c0393c923650bf84f159ddc (patch) | |
tree | 00b02c3a74ccebedeca9b29e49b78e8f52cc1abf /gbp/git/repository.py | |
parent | 171579fa5f27ea91563920d672c5b89d1c16f78b (diff) |
GitRepository: Add clean() method
Signed-off-by: Lingchaox Xin <lingchaox.xin@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'gbp/git/repository.py')
-rw-r--r-- | gbp/git/repository.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 41e6471..6eed588 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -765,6 +765,27 @@ class GitRepository(object): break return (ret, "".join(out)) + def clean(self, directories=False, force=False, dry_run=False): + """ + Remove untracked files from the working tree. + + @param directories: remove untracked directories, too + @type directories: C{bool} + @param force: satisfy git configuration variable clean.requireForce + @type force: C{bool} + @param dry_run: don’t actually remove anything + @type dry_run: C{bool} + """ + options = GitArgs() + options.add_true(directories, '-d') + options.add_true(force, '-f') + options.add_true(dry_run, '-n') + + _out, err, ret = self._git_inout('clean', options.args, + extra_env={'LC_ALL': 'C'}) + if ret: + raise GitRepositoryError("Can't execute repository clean: %s" % err) + def is_empty(self): """ Is the repository empty? |