Closes: #886372
---
distro_tracker/core/tests/tests_utils.py | 13 +
distro_tracker/core/utils/packages.py| 8 +++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/distro_tracker/core/tests/tests_utils.py
b/distro_tracker/core/tests/tests_utils.py
index 6ad6f8a..27ec1ac 100644
--- a/distro_tracker/core/tests/tests_utils.py
+++ b/distro_tracker/core/tests/tests_utils.py
@@ -716,6 +716,19 @@ class PackageUtilsTests(SimpleTestCase):
extract_vcs_information(d)
)
+# Git with branch info
+d = {
+'Vcs-Git': vcs_url + ' -b some-branch'
+}
+self.assertDictEqual(
+{
+'type': 'git',
+'url': vcs_url,
+'branch': 'some-branch',
+},
+extract_vcs_information(d)
+)
+
# Empty dict
self.assertDictEqual({}, extract_vcs_information({}))
# No vcs information in the dict
diff --git a/distro_tracker/core/utils/packages.py
b/distro_tracker/core/utils/packages.py
index bf9adc3..66004de 100644
--- a/distro_tracker/core/utils/packages.py
+++ b/distro_tracker/core/utils/packages.py
@@ -21,6 +21,7 @@ import os
import apt
import shutil
import apt_pkg
+import re
import subprocess
import tarfile
@@ -55,7 +56,7 @@ def extract_vcs_information(stanza):
:type stanza: dict
:returns: VCS information regarding the package. Contains the following
-keys: type[, browser, url]
+keys: type[, browser, url, branch]
:rtype: dict
"""
vcs = {}
@@ -66,6 +67,11 @@ def extract_vcs_information(stanza):
elif key.startswith('vcs-'):
vcs['type'] = key[4:]
vcs['url'] = value
+if vcs['type'] == 'git':
+match = re.match(r'(?P.*?)\s+-b\s*(?P\S+)', value)
+if match:
+vcs['url'] = match.group('url')
+vcs['branch'] = match.group('branch')
return vcs
--
2.14.1