File: retrieve-version-from-debian-changelog.diff

package info (click to toggle)
python-libarchive-c 2.9-0.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 880 kB
  • sloc: python: 1,175; makefile: 17; sh: 10
file content (46 lines) | stat: -rw-r--r-- 1,465 bytes parent folder | download | duplicates (2)
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
41
42
43
44
45
46
Description: retrieve upstream version from debian/changelog
Author: Jérémy Bobbio <lunar@debian.org>
Last-Update: 2019-01-08
Forwarded: non-needed

--- a/version.py
+++ b/version.py
@@ -12,32 +12,12 @@
 
 
 def get_version():
-    # Return the version if it has been injected into the file by git-archive
-    version = tag_re.search('$Format:%D$')
-    if version:
-        return version.group(1)
-
-    d = dirname(__file__)
-
-    if isdir(join(d, '.git')):
-        # Get the version using "git describe".
-        cmd = 'git describe --tags --match %s[0-9]* --dirty' % PREFIX
-        try:
-            version = check_output(cmd.split()).decode().strip()[len(PREFIX):]
-        except CalledProcessError:
-            raise RuntimeError('Unable to get version number from git tags')
-
-        # PEP 440 compatibility
-        if '-' in version:
-            if version.endswith('-dirty'):
-                raise RuntimeError('The working tree is dirty')
-            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