summaryrefslogtreecommitdiffhomepage
path: root/gbp
diff options
context:
space:
mode:
authorGuido Guenther <agx@sigxcpu.org>2008-02-29 16:08:00 +0100
committerGuido Guenther <agx@sigxcpu.org>2008-02-29 16:08:00 +0100
commit71d209fa202b3828a1eb7e8518a127a7a0a08596 (patch)
tree704ca6d61854d0c9415a68b722e1b43375aef4ea /gbp
parent5632aafe16c6760aabd940eb0d3b26c852ed455a (diff)
make dsc import repeatable (Closes: #468120)
Diffstat (limited to 'gbp')
-rw-r--r--gbp/command_wrappers.py5
-rw-r--r--gbp/deb_utils.py14
-rw-r--r--gbp/git_utils.py26
3 files changed, 41 insertions, 4 deletions
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py
index f11d4860..c71d7437 100644
--- a/gbp/command_wrappers.py
+++ b/gbp/command_wrappers.py
@@ -205,8 +205,9 @@ class GitAdd(GitCommand):
class GitRm(GitCommand):
"""Wrap git rm to remove files"""
- def __init__(self):
- GitCommand.__init__(self, 'rm')
+ def __init__(self, verbose=False):
+ args = [ ['-q'], [] ][verbose]
+ GitCommand.__init__(self, cmd='rm', args=args)
self.run_error = "Couldn't remove files"
diff --git a/gbp/deb_utils.py b/gbp/deb_utils.py
index e826c06c..2e7b7078 100644
--- a/gbp/deb_utils.py
+++ b/gbp/deb_utils.py
@@ -7,6 +7,7 @@ import email
import commands
import os
import shutil
+import command_wrappers as gbpc
# When trying to parse a version-number from a dsc or changes file, these are
# the valid characters.
@@ -72,4 +73,17 @@ def copy_orig(cp, orig_dir, output_dir):
return False
return True
+def unpack_orig(archive, tmpdir, filters):
+ """
+ unpack a .orig.tar.gz to tmpdir, leave the cleanup to the caller in case of
+ an error
+ """
+ try:
+ unpackArchive = gbpc.UnpackTarArchive(archive, tmpdir, filters)
+ unpackArchive()
+ except gbpc.CommandExecFailed:
+ print >>sys.stderr, "Unpacking of %s failed" % archive
+ raise GbpError
+ return unpackArchive.dir
+
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
diff --git a/gbp/git_utils.py b/gbp/git_utils.py
index fffa3f64..90802cc3 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\:·: