diff options
author | Guido Guenther <agx@sigxcpu.org> | 2008-02-29 16:08:00 +0100 |
---|---|---|
committer | Guido Guenther <agx@sigxcpu.org> | 2008-02-29 16:08:00 +0100 |
commit | 71d209fa202b3828a1eb7e8518a127a7a0a08596 (patch) | |
tree | 704ca6d61854d0c9415a68b722e1b43375aef4ea /gbp/git_utils.py | |
parent | 5632aafe16c6760aabd940eb0d3b26c852ed455a (diff) |
make dsc import repeatable (Closes: #468120)
Diffstat (limited to 'gbp/git_utils.py')
-rw-r--r-- | gbp/git_utils.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/gbp/git_utils.py b/gbp/git_utils.py index fffa3f6..90802cc 100644 --- a/gbp/git_utils.py +++ b/gbp/git_utils.py @@ -5,6 +5,7 @@ import subprocess import os.path +from command_wrappers import (GitAdd, GitRm, copy_from) class GitRepositoryError(Exception): """Exception thrown by GitRepository""" @@ -21,7 +22,7 @@ class GitRepository(object): raise GitRepositoryError self.path = os.path.abspath(path) - + def __check_path(self): if os.getcwd() != self.path: raise GitRepositoryError @@ -53,6 +54,12 @@ class GitRepository(object): out, ret = self.__git_getoutput('ls-tree', [ treeish ]) return [ True, False ][ret != 0] + def has_tag(self, tag): + """check if the repository has the given tag""" + self.__check_path() + out, ret = self.__git_getoutput('tag', [ '-l', tag ]) + return [ False, True ][len(out)] + def get_branch(self): """on what branch is the current working copy""" @@ -98,4 +105,19 @@ def sanitize_version(version): version = version.split(':', 1)[1] return version.replace('~', '.') -# vim:et:ts=4:sw=4: + +def replace_source_tree(repo, src_dir, filters, verbose=False): + """ + make the current wc match what's in src_dir + @return: True if wc was modified + @rtype: boolean + """ + old = set(repo.index_files()) + new = set(copy_from(src_dir, filters)) + GitAdd()(['.']) + files = [ obj for obj in old - new if not os.path.isdir(obj)] + if files: + GitRm(verbose=verbose)(files) + return not repo.is_clean()[0] + +# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: |