diff options
author | Guido Guenther <agx@sigxcpu.org> | 2006-10-06 19:17:14 +0200 |
---|---|---|
committer | Guido Guenther <agx@bogon.sigxcpu.org> | 2006-10-06 19:17:14 +0200 |
commit | 16425af87c8e566f5eff6b255c55ebf9159708c2 (patch) | |
tree | c20a8ce5846a3fa60e9ac60d5b32a34c3ccc1110 | |
parent | 29948a722e3a63668c29239e072381731070e017 (diff) | |
download | git-buildpackage-16425af87c8e566f5eff6b255c55ebf9159708c2.tar.gz git-buildpackage-16425af87c8e566f5eff6b255c55ebf9159708c2.tar.bz2 git-buildpackage-16425af87c8e566f5eff6b255c55ebf9159708c2.zip |
more robust regex matching, sanitze all version numbers before running git-tagdebian/0.2.7
-rw-r--r-- | debian/changelog | 7 | ||||
-rwxr-xr-x | git-buildpackage | 6 | ||||
-rwxr-xr-x | git-import-dsc | 18 | ||||
-rwxr-xr-x | git-import-orig | 4 | ||||
-rw-r--r-- | git_buildpackage/deb_utils.py | 7 | ||||
-rw-r--r-- | git_buildpackage/git_utils.py (renamed from git_buildpackage/utils.py) | 4 |
6 files changed, 35 insertions, 11 deletions
diff --git a/debian/changelog b/debian/changelog index 86237a94..e0010f91 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +git-buildpackage (0.2.7) git-buildpackage; urgency=low + + * more robust regex matching + * sanitze all version numbers before running git-tag + + -- Guido Guenther <agx@sigxcpu.org> Fri, 6 Oct 2006 18:40:12 +0200 + git-buildpackage (0.2.6) git-buildpackage; urgency=low * UNRELEASED diff --git a/git-buildpackage b/git-buildpackage index f7360c4d..375b82a4 100755 --- a/git-buildpackage +++ b/git-buildpackage @@ -20,12 +20,12 @@ import sys,os,commands,re import optparse from git_buildpackage import GitTag, Command, CommandExecFailed -from git_buildpackage.utils import is_repository_clean, is_repository +from git_buildpackage.git_utils import * build_cmd='debuild' def get_version(): - versionre=re.compile('^Version:\s+(?P<version>[\d\w~\-\.]+)$') + versionre=re.compile('^Version:\s+(?P<version>.+)\s*$') (status, out) = commands.getstatusoutput('dpkg-parsechangelog') for line in out.split('\n'): m=versionre.match(line) @@ -71,7 +71,7 @@ def main(argv): version=get_version() if version: print "Tagging", version - if not GitTag()(version.replace('~','.')): return 1 + if not GitTag()(sanitize_version(version)): return 1 else: print >>sys.stderr,"Can't parse version from changes file" except CommandExecFailed: diff --git a/git-import-dsc b/git-import-dsc index 59d7b5ed..156aa804 100755 --- a/git-import-dsc +++ b/git-import-dsc @@ -24,6 +24,8 @@ import tempfile import glob from optparse import OptionParser from git_buildpackage import * +from git_buildpackage.git_utils import * +from git_buildpackage.deb_utils import * gitAdd=GitAdd() gitCommitAll=GitCommitAll() @@ -31,9 +33,10 @@ gitTag=GitTag() class DscPackage(object): """Parse the dsc file for verions, package names, etc""" - pkgre=re.compile('Source: (?P<pkg>[\w\-]+)') - versionre=re.compile('Version: (?P<upstream>[a-z\d\.\+]+)(-(?P<debian>[a-z\d\.~\+]+))?') - tarre=re.compile ('^ [\da-z]+ \d+ (?P<tar>[a-z\d\-]+_[a-z\d\.\~\+\-]+(\.orig)?\.tar\.gz)') + pkgre=re.compile('Source:\s+(?P<pkg>.+)\s*') + versionre=re.compile("Version:\s(\d+\:)?(?P<upstream>[%s]+)(-(?P<debian>[%s]+))?\s*$" % + (debian_version_chars, debian_version_chars)) + tarre=re.compile('^\s\w+\s\d+\s+(?P<tar>[^_]+_[^_]+(\.orig)?\.tar\.(gz|bz2))') def __init__(self, dscfile): self.dscfile=os.path.abspath(dscfile) @@ -45,9 +48,12 @@ class DscPackage(object): if m.group('debian'): self.debian_version = m.group('debian') self.native = False + print "Upstream version:", self.upstream_version + print "Debian version:", self.debian_version else: print "Debian Native Package" self.native = True # Debian native package + print "Version:", self.upstream_version continue m=self.pkgre.match(line) if m: @@ -61,7 +67,7 @@ class DscPackage(object): self.tgz = dir+m.group('tar') continue f.close() - + def import_upstream(src, dirs, upstream_branch): try: @@ -78,7 +84,7 @@ def import_upstream(src, dirs, upstream_branch): GitInitDB()() gitAdd(['.']) gitCommitAll(msg="Imported %s version %s" % (['upstream','Debian'][src.native],src.upstream_version,)) - gitTag(src.upstream_version) + gitTag(sanitize_version(src.upstream_version)) if not src.native: GitBranch()(upstream_branch) except CommandExecFailed: @@ -93,7 +99,7 @@ def apply_debian_patch(src, dirs): DpkgSourceExtract()(src.dscfile, dirs['dpkg-src']) os.chdir(dirs['git']) GitLoadDirs()(dirs['dpkg-src'], 'Imported Debian patch') - gitTag('%s-%s' % (src.upstream_version, src.debian_version)) + gitTag(sanitize_version('%s-%s' % (src.upstream_version, src.debian_version))) except CommandExecFailed: print >>sys.stderr,"Failed to import Debian package" return 1 diff --git a/git-import-orig b/git-import-orig index ca802996..fdf597e1 100755 --- a/git-import-orig +++ b/git-import-orig @@ -24,7 +24,7 @@ import re import glob from optparse import OptionParser from git_buildpackage import * -from git_buildpackage.utils import is_repository_clean, is_repository +from git_buildpackage.git_utils import * def cleanupTmpTree(tree): @@ -108,7 +108,7 @@ def main(): gitCheckoutUpstream() gitShowBranch() GitLoadDirs()(origdir) - GitTag()(version) + GitTag()(sanitize_version(version)) print "Merging to master..." gitCheckoutMaster() diff --git a/git_buildpackage/deb_utils.py b/git_buildpackage/deb_utils.py new file mode 100644 index 00000000..173c3128 --- /dev/null +++ b/git_buildpackage/deb_utils.py @@ -0,0 +1,7 @@ +# utility functions for git-buildpackge and friends +# (C) 2006 Guido Guenther <agx@sigxcpu.org> + +# When trying to parse a version-number from a dsc or changes file, these are +# the valid characters. +debian_version_chars='a-zA-Z\d.~+' + diff --git a/git_buildpackage/utils.py b/git_buildpackage/git_utils.py index e2455ff3..330c960a 100644 --- a/git_buildpackage/utils.py +++ b/git_buildpackage/git_utils.py @@ -31,4 +31,8 @@ def is_repository(path): return False return True +def sanitize_version(version): + """sanitize a version so git accepts it as a tag""" + return version.replace('~','.') + # vim:et:ts=4:sw=4: |