Added a method to get the content of files.
Some checks failed
/ unit-tests (push) Failing after 10s
Some checks failed
/ unit-tests (push) Failing after 10s
This commit is contained in:
14
sk/devops.py
14
sk/devops.py
@@ -247,6 +247,20 @@ class Item():
|
||||
)
|
||||
self.from_json(r.json()) # type: ignore[attr-defined]
|
||||
|
||||
def get_content(self) -> bytes:
|
||||
"""Get the content of the item if it is a file."""
|
||||
if self.git_object_type != "blob": # type: ignore[attr-defined]
|
||||
raise ValueError("Content can only be fetched for blob items.")
|
||||
|
||||
r = self._repository._project.organization.get_path(
|
||||
path=f"{self._repository._project.id}/_apis/git/repositories/{self._repository.id}/items",
|
||||
params={
|
||||
"path": self.path,
|
||||
"recursionLevel": "none"
|
||||
}
|
||||
)
|
||||
return r.content
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
return self._path # type: ignore[attr-defined]
|
||||
|
||||
Reference in New Issue
Block a user