1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
Description: retrieve upstream version from debian/changelog
Author: Jérémy Bobbio <lunar@debian.org>
diff --git a/version.py b/version.py
index 3441617..5c975ce 100644
--- a/version.py
+++ b/version.py
@@ -9,26 +9,12 @@ from subprocess import CalledProcessError, check_output
version_re = re.compile('^Version: (.+)$', re.M)
def get_version():
- d = dirname(__file__)
-
- if isdir(join(d, '.git')):
- # Get the version using "git describe".
- cmd = 'git describe --tags --match [0-9]*'.split()
- try:
- version = check_output(cmd).decode().strip()
- except CalledProcessError:
- print('Unable to get version number from git tags')
- exit(1)
-
- # PEP 386 compatibility
- if '-' in version:
- version = '.post'.join(version.split('-')[:2])
-
- else:
- # Extract the version from the PKG-INFO file.
- with open(join(d, 'PKG-INFO')) as f:
- version = version_re.search(f.read()).group(1)
-
+ cmd = 'dpkg-parsechangelog -S Version'.split()
+ try:
+ version = check_output(cmd).decode().strip().split('-')[0]
+ except CalledProcessError:
+ print('Unable to get version number from git tags')
+ exit(1)
return version
|