mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-05-11 18:37:25 +08:00
Resolve the commit in the SCM.commit property method instead of the constructor
This will prevent the need to call `SCM.get_latest` in the constructor, since not all SCM objects need the commit to the branch. It also fixes the situation where a component's git repo doesn't have a "master" branch. See https://pagure.io/fm-orchestrator/issue/1224
This commit is contained in:
@@ -98,8 +98,6 @@ class SCM(object):
|
||||
self.name = self.name[:-4]
|
||||
self.commit = match.group("commit")
|
||||
self.branch = branch if branch else "master"
|
||||
if not self.commit:
|
||||
self.commit = self.get_latest(self.branch)
|
||||
self.version = None
|
||||
else:
|
||||
raise ValidationError("Unhandled SCM scheme: %s" % self.scheme)
|
||||
@@ -351,6 +349,9 @@ class SCM(object):
|
||||
@property
|
||||
def commit(self):
|
||||
"""The commit ID, for example the git hash, or None."""
|
||||
if not self._commit:
|
||||
self._commit = self.get_latest(self.branch)
|
||||
|
||||
return self._commit
|
||||
|
||||
@commit.setter
|
||||
|
||||
Reference in New Issue
Block a user