from .errors import BaseModuleInfoError
from .base_moduleinfo import BaseModuleInfo
-
-__version__ = '0.3.0'
+__version__ = '0.3.1'
LOG = logging.getLogger(__name__)
default_repo_type = 'forge'
valid_repo_types = ('forge', 'git', 'svn', 'tarball', 'local')
+ valid_ref_types = ('ref', 'head', 'tag', 'branch', 'commit-id')
re_empty_mod_pf_line = re.compile(r'\s*mod\s+\'([^\']+)\'\s*$', re.IGNORECASE)
re_mod_pf_line = re.compile(r'\s*mod\s+\'([^\']+)\'\s*,\s*(\S+.*)\s*$', re.IGNORECASE)
initialized=None, name=None, vendor=None, full_name=None,
repo_type=None, repo=None, ref=None, use_control_branch=False,
forge_version=None, default_branch=None, exclude_spec=False,
- install_path=None):
+ ref_type=None, install_path=None):
self._repo_type = self.default_repo_type
self._repo = None
self._ref = None
+ self._ref_type = None
self._use_control_branch = False
self._forge_version = None
self._default_branch = None
self.repo_type = repo_type
self.repo = repo
self.ref = ref
+ self.ref_type = ref_type
self.use_control_branch = use_control_branch
self.forge_version = forge_version
self.default_branch = default_branch
return
self._ref = to_str(value).strip()
+ # -------------------------------------------------------------------------
+ @property
+ def ref_type(self):
+ """The type of the Git reference."""
+ return self._ref_type
+
+ @ref_type.setter
+ def ref_type(self, value):
+ if value is None:
+ self._ref_type = None
+ return
+ v = to_str(value).strip().lower()
+ if v not in self.valid_ref_types:
+ msg = _("Invalid Git reference type {!r}.").format(value)
+ raise ModuleInfoTypeError(msg)
+ self._ref_type = v
+
# -------------------------------------------------------------------------
@property
def forge_version(self):
res['forge_version'] = self.forge_version
res['install_path'] = self.install_path
res['ref'] = self.ref
+ res['ref_type'] = self.ref_type
res['repo'] = self.repo
res['repo_type'] = self.repo_type
res['use_control_branch'] = self.use_control_branch
res['forge_version'] = self.forge_version
res['install_path'] = self.install_path
res['ref'] = self.ref
+ res['ref_type'] = self.ref_type
res['repo'] = self.repo
res['repo_type'] = self.repo_type
res['use_control_branch'] = self.use_control_branch
fields.append("repo={!r}".format(self.repo))
if self.ref:
fields.append("ref={!r}".format(self.ref))
+ if self.ref_type:
+ fields.append("ref_type={!r}".format(self.ref_type))
if self.use_control_branch:
fields.append("use_control_branch={!r}".format(True))
if self.forge_version:
module_info.repo = self.repo
if self.ref:
module_info.ref = self.ref
+ if self.ref_type:
+ module_info.ref_type = self.ref_type
if self.use_control_branch:
module_info.use_control_branch = True
if self.forge_version:
if 'ref' in data:
module_info.ref = data['ref']
+ if 'ref_type' in data:
+ module_info.ref_type = data['ref_type']
+
if 'use_control_branch' in data:
module_info.use_control_branch = data['use_control_branch']
if 'tag' in definitions:
module_info.ref = definitions['tag']
+ module_info.ref_type = 'tag'
if 'ref' in definitions:
module_info.ref = definitions['ref']
+ module_info.ref_type = 'ref'
if 'branch' in definitions:
branch = definitions['branch']
module_info.use_control_branch = True
else:
module_info.ref = branch
+ module_info.ref_type = 'branch'
if 'commit' in definitions:
module_info.ref = definitions['commit']
+ module_info.ref_type = 'commit-id'
if 'latest' in definitions:
module_info.forge_version = 'latest'