mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-11 23:10:10 +01:00
index: expose rev property (#8909)
index: add rev property This is very useful to identify indexes that are built from git revisions and so are describing an immutable state and can be used for caching. We were already using this for `__repr__`.
This commit is contained in:
+7
-3
@@ -128,10 +128,14 @@ class Index:
|
||||
self._params = params or {}
|
||||
self._collected_targets: Dict[int, List["StageInfo"]] = {}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
rev = "workspace"
|
||||
@cached_property
|
||||
def rev(self) -> Optional[str]:
|
||||
if not isinstance(self.repo.fs, LocalFileSystem):
|
||||
rev = self.repo.get_rev()[:7]
|
||||
return self.repo.get_rev()[:7]
|
||||
return None
|
||||
|
||||
def __repr__(self) -> str:
|
||||
rev = self.rev or "workspace"
|
||||
return f"Index({self.repo}, fs@{rev})"
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user