diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2012-05-30 09:06:59 +0300 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-07-24 21:47:30 +0200 |
commit | 21ac2d83151cd41659af5acf7bcfb130348bcd45 (patch) | |
tree | 0dfea10bbd3743597bc48da1219a6b9c1663b652 | |
parent | ba55f9e1c409aa5b3d7600ed60294fe461d26e78 (diff) | |
download | git-buildpackage-21ac2d83151cd41659af5acf7bcfb130348bcd45.tar.gz git-buildpackage-21ac2d83151cd41659af5acf7bcfb130348bcd45.tar.bz2 git-buildpackage-21ac2d83151cd41659af5acf7bcfb130348bcd45.zip |
GitRepository: option to ignore untracked in is_clean()
Add an option to ignore untracked files when checking if the repository
is clean.
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r-- | gbp/git/repository.py | 13 | ||||
-rw-r--r-- | tests/test_GitRepository.py | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py index f6269c5b..02c6c969 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -567,10 +567,13 @@ class GitRepository(object): args += [ commit, '--' ] self._git_command("reset", args) - def is_clean(self): + def is_clean(self, ignore_untracked=False): """ Does the repository contain any uncommitted modifications? + @param ignore_untracked: whether to ignore untracked files when + checking the repository status + @type ignore_untracked: C{bool} @return: C{True} if the repository is clean, C{False} otherwise and Git's status message @rtype: C{tuple} @@ -579,7 +582,13 @@ class GitRepository(object): return (True, '') clean_msg = 'nothing to commit' - out, ret = self._git_getoutput('status', extra_env={'LC_ALL': 'C'}) + + args = GitArgs() + args.add_false(untracked, '-uno') + + out, ret = self._git_getoutput('status', + args.args, + extra_env={'LC_ALL': 'C'}) if ret: raise GbpError("Can't get repository status") ret = False diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py index ff0a5d4f..fe59cdfe 100644 --- a/tests/test_GitRepository.py +++ b/tests/test_GitRepository.py @@ -79,6 +79,8 @@ def test_add_files(): os.path.join(repo.path, "testfile")) >>> repo.is_clean()[0] False + >>> repo.is_clean(ignore_untracked=True)[0] + True >>> repo.add_files(repo.path, force=True) >>> repo.commit_all(msg="foo") >>> repo.is_clean()[0] |