diff --git a/lib/spack/spack/version.py b/lib/spack/spack/version.py index 385f8f6c03c..9108b1feb5e 100644 --- a/lib/spack/spack/version.py +++ b/lib/spack/spack/version.py @@ -167,7 +167,7 @@ def __gt__(self, other): class Version(object): """Class to represent versions""" - __slots__ = ['version', 'separators', 'string', 'commit_lookup'] + __slots__ = ['version', 'separators', 'string', 'is_commit', 'commit_lookup'] def __init__(self, string): if not isinstance(string, str): @@ -189,6 +189,8 @@ def __init__(self, string): ) self.separators = tuple(m[2] for m in segments) + self.is_commit = len(self.string) == 40 and COMMIT_VERSION.match(self.string) + def _cmp(self, other_lookups=None): commit_lookup = self.commit_lookup or other_lookups @@ -205,15 +207,6 @@ def _cmp(self, other_lookups=None): return self.version - @property - def is_commit(self): - """ - Determine if the original string is referencing a commit. - """ - if self.string in infinity_versions: - return False - return COMMIT_VERSION.match(self.string) is not None - @property def dotted(self): """The dotted representation of the version.