Compare commits
2 Commits
d06bc05a2d
...
5412c3ea09
| Author | SHA1 | Date | |
|---|---|---|---|
| 5412c3ea09 | |||
| 6e16cebeea |
@@ -3,3 +3,11 @@
|
|||||||
[](https://gitea.koszewscy.waw.pl/slawek/docs-harvester/actions?workflow=unit-tests.yml)
|
[](https://gitea.koszewscy.waw.pl/slawek/docs-harvester/actions?workflow=unit-tests.yml)
|
||||||
|
|
||||||
This project is designed to harvest and process Markdown documentation files from Git repositories.
|
This project is designed to harvest and process Markdown documentation files from Git repositories.
|
||||||
|
|
||||||
|
## DevOps OAuth2 Flow
|
||||||
|
|
||||||
|
Type: **oauth2**
|
||||||
|
Flow: **accessCode**
|
||||||
|
Authorization URL: `https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion`
|
||||||
|
Token URL: `https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer`
|
||||||
|
Scopes: `vso.code`
|
||||||
31
sk/devops.py
31
sk/devops.py
@@ -243,8 +243,16 @@ class Item():
|
|||||||
def __init__(self, repository: Repository, **kwargs):
|
def __init__(self, repository: Repository, **kwargs):
|
||||||
self._repository = repository
|
self._repository = repository
|
||||||
self.from_args(**kwargs) # type: ignore[attr-defined]
|
self.from_args(**kwargs) # type: ignore[attr-defined]
|
||||||
|
if "branch" in kwargs:
|
||||||
|
self._branch = kwargs.get("branch")
|
||||||
log_entity_creation(log, Item, self.path)
|
log_entity_creation(log, Item, self.path)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def branch(self):
|
||||||
|
if hasattr(self, "_branch"):
|
||||||
|
return getattr(self, "_branch")
|
||||||
|
return None
|
||||||
|
|
||||||
def get_auto_properties(self):
|
def get_auto_properties(self):
|
||||||
r = self._repository._project.organization.get_path(
|
r = self._repository._project.organization.get_path(
|
||||||
path=f"{self._repository._project.id}/_apis/git/repositories/{self._repository.id}/items",
|
path=f"{self._repository._project.id}/_apis/git/repositories/{self._repository.id}/items",
|
||||||
@@ -256,17 +264,28 @@ class Item():
|
|||||||
)
|
)
|
||||||
self.from_json(r.json()) # type: ignore[attr-defined]
|
self.from_json(r.json()) # type: ignore[attr-defined]
|
||||||
|
|
||||||
def get_content(self) -> bytes:
|
def get_content(self, branch: str | None = None, commit: str | None = None, tag: str | None = None) -> bytes:
|
||||||
"""Get the content of the item if it is a file."""
|
"""Get the content of the item with optional branch, commit, or tag."""
|
||||||
if self.git_object_type != "blob": # type: ignore[attr-defined]
|
if self.git_object_type != "blob": # type: ignore[attr-defined]
|
||||||
raise ValueError("Content can only be fetched for blob items.")
|
raise ValueError("Content can only be fetched for blob items.")
|
||||||
|
|
||||||
|
params = { "path": self.path, "recursionLevel": "none" }
|
||||||
|
if self.branch and branch is None:
|
||||||
|
branch = self.branch
|
||||||
|
|
||||||
|
if branch:
|
||||||
|
params["version"] = branch
|
||||||
|
params["versionType"] = "branch"
|
||||||
|
elif tag:
|
||||||
|
params["version"] = tag
|
||||||
|
params["versionType"] = "tag"
|
||||||
|
elif commit:
|
||||||
|
params["version"] = commit
|
||||||
|
params["versionType"] = "commit"
|
||||||
|
|
||||||
r = self._repository._project.organization.get_path(
|
r = self._repository._project.organization.get_path(
|
||||||
path=f"{self._repository._project.id}/_apis/git/repositories/{self._repository.id}/items",
|
path=f"{self._repository._project.id}/_apis/git/repositories/{self._repository.id}/items",
|
||||||
params={
|
params=params
|
||||||
"path": self.path,
|
|
||||||
"recursionLevel": "none"
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
return r.content
|
return r.content
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user