summaryrefslogtreecommitdiff
path: root/git-import-orig
diff options
context:
space:
mode:
authorGuido Guenther <agx@sigxcpu.org>2007-10-03 18:00:02 +0200
committerGuido Guenther <agx@sigxcpu.org>2007-10-03 18:00:02 +0200
commit65fa3c4980f5163b00c6d13fce429b7f9cda3a5e (patch)
treee5eefdf76638a984199cc8ad396741b9708b9734 /git-import-orig
parente76a6a180a57701ae4ae381f74523cacb3152780 (diff)
downloadgit-buildpackage-65fa3c4980f5163b00c6d13fce429b7f9cda3a5e.tar.gz
git-buildpackage-65fa3c4980f5163b00c6d13fce429b7f9cda3a5e.tar.bz2
git-buildpackage-65fa3c4980f5163b00c6d13fce429b7f9cda3a5e.zip
detect upstream version from common tarball formates (Closes: #443306)
Diffstat (limited to 'git-import-orig')
-rwxr-xr-xgit-import-orig24
1 files changed, 17 insertions, 7 deletions
diff --git a/git-import-orig b/git-import-orig
index b9c3e8d2..54bed776 100755
--- a/git-import-orig
+++ b/git-import-orig
@@ -67,12 +67,22 @@ def import_source_tree(repo, orig_dir, version, upstream, filter):
raise GbpError, "Import of new upstream version failed."
-def get_version(tgz):
- """get the version from the filename of a .orig.tar.gz"""
- origre = re.compile('^[a-z\d-]+_(?P<version>[a-z\d\.\~\-]+)\.orig\.tar\.gz')
- m = origre.match(os.path.basename(tgz))
- if m:
- return m.group('version')
+def guess_version(archive, version_regex=r''):
+ """
+ guess the version from the filename of an upstgream archive
+ @archive: filename to guess to version for
+ @version_regex: additional version regex to apply, needs a 'version' group
+ """
+ version_filters = [ # Debian package_<version>.orig.tar.gz:
+ r'^[a-z\d\-]+_(?P<version>[a-z\d\.\~\-]+)\.orig\.tar\.(gz|bz2)',
+ # Upstream package-<version>.tar.gz:
+ r'^[a-z\d\-]+-(?P<version>[a-z\d\.]+)\.tar\.(gz|bz2)' ]
+ if version_regex:
+ version_filters = version_regex + version_filters
+ for filter in version_filters:
+ m = re.match(filter, os.path.basename(archive))
+ if m:
+ return m.group('version')
def main(argv):
@@ -138,7 +148,7 @@ create it otherwise use --upstream-branch to specify it.
if options.version:
version = options.version
else:
- version = get_version(archive)
+ version = guess_version(archive)
if version:
print "Upstream version is %s" % version