Skip to content

Commit

Permalink
fix: Fix name properties for GitLab URLs and clarify error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Jun 5, 2023
1 parent 2bd3dab commit 36402e4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.rst
@@ -1,6 +1,12 @@
Changelog
=========

0.2.2 (2023-06-05)
------------------

- fix: :meth:`~ocdsextensionregistry.extension_version.ExtensionVersion.repository_full_name` and :meth:`~ocdsextensionregistry.extension_version.ExtensionVersion.repository_name` return the correct name for GitLab URLs.
- fix: Clarify error message for ``AttributeError`` on :meth:`~ocdsextensionregistry.extension_version.ExtensionVersion.repository_full_name`, :meth:`~ocdsextensionregistry.extension_version.ExtensionVersion.repository_name`, and :meth:`~ocdsextensionregistry.extension_version.ExtensionVersion.repository_user`.

0.2.1 (2023-05-24)
------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Expand Up @@ -26,7 +26,7 @@
author = "Open Contracting Partnership"

# The short X.Y version
version = "0.2.1"
version = "0.2.2"
# The full version, including alpha/beta/rc tags
release = version

Expand Down
19 changes: 14 additions & 5 deletions ocdsextensionregistry/extension_version.py
Expand Up @@ -260,13 +260,22 @@ def repository_url(self):
return self._repository_property('url')

def _repository_full_name(self, parsed, config):
return re.match(config['full_name:pattern'], parsed.path).group(1)
match = re.search(config['full_name:pattern'], parsed.path)
if match:
return match.group(1)
raise AttributeError(f"{parsed.path} !~ {config['full_name:pattern']}")

def _repository_name(self, parsed, config):
return re.match(config['name:pattern'], parsed.path).group(1)
match = re.search(config['name:pattern'], parsed.path)
if match:
return match.group(1)
raise AttributeError(f"{parsed.path} !~ {config['name:pattern']}")

def _repository_user(self, parsed, config):
return re.match(config['user:pattern'], parsed.path).group(1)
match = re.search(config['user:pattern'], parsed.path)
if match:
return match.group(1)
raise AttributeError(f"{parsed.path} !~ {config['user:pattern']}")

def _repository_user_page(self, parsed, config):
return config['html_page:prefix'] + self._repository_user(parsed, config)
Expand Down Expand Up @@ -317,8 +326,8 @@ def _configuration(self, parsed):
if netloc == 'gitlab.com':
# A base URL may look like: https://gitlab.com/gitlab-org/gitter/env/raw/master/
return {
'full_name:pattern': r'\A/(.+)/raw/',
'name:pattern': r'/([^/]+)/raw/',
'full_name:pattern': r'\A/(.+)/-/raw/',
'name:pattern': r'/([^/]+)/-/raw/',
'user:pattern': r'\A/([^/]+)',
'html_page:prefix': 'https://gitlab.com/',
'url:prefix': 'https://gitlab.com/',
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = ocdsextensionregistry
version = 0.2.1
version = 0.2.2
author = Open Contracting Partnership
author_email = data@open-contracting.org
license = BSD
Expand Down

0 comments on commit 36402e4

Please sign in to comment.