kopia lustrzana https://github.com/Langenfeld/py-gitea
add apiendpoint to request file listing from repositories
rodzic
d9a0dcbb66
commit
a0d1b6f80a
|
@ -237,6 +237,7 @@ class Repository(GiteaApiObject):
|
|||
REPO_USER_TIME = """/repos/%s/%s/times/%s""" # <owner>, <reponame>, <username>
|
||||
REPO_COMMITS = "/repos/%s/%s/commits" # <owner>, <reponame>
|
||||
REPO_TRANSFER = "/repos/{owner}/{repo}/transfer"
|
||||
REPO_CONTENTS = "/repos/{owner}/{repo}/contents"
|
||||
|
||||
def __init__(self, gitea, id: int):
|
||||
super(Repository, self).__init__(gitea, id=id)
|
||||
|
@ -410,6 +411,17 @@ class Repository(GiteaApiObject):
|
|||
self.gitea.requests_post(url, data=data)
|
||||
# TODO: make sure this instance is either updated or discarded
|
||||
|
||||
def get_git_content(self, ref : str = "HEAD"):
|
||||
"""https://git.sopranium.de/api/swagger#/repository/repoGetContentsList"""
|
||||
url = Repository.REPO_CONTENTS.format(owner=self.owner.username, repo=self.name)
|
||||
data = {"ref": ref}
|
||||
result = self.gitea.requests_get(url)
|
||||
return result
|
||||
|
||||
def get_file_content(self):
|
||||
"""https://git.sopranium.de/api/swagger#/repository/repoGetContents"""
|
||||
pass
|
||||
|
||||
def delete(self):
|
||||
self.gitea.requests_delete(
|
||||
Repository.REPO_DELETE % (self.owner.username, self.name)
|
||||
|
|
|
@ -10,7 +10,7 @@ class GiteaApiObject(BasicGiteaApiObject):
|
|||
|
||||
@classmethod
|
||||
def request(cls, gitea, id):
|
||||
"""Use for ginving a nice e.g. 'request(gita, orgname, repo, ticket)'.
|
||||
"""Use for giving a nice e.g. 'request(gita, orgname, repo, ticket)'.
|
||||
All args are put into an args tuple for passing around"""
|
||||
return cls._request(gitea, {"id": id})
|
||||
|
||||
|
|
|
@ -133,6 +133,12 @@ def test_list_branches(instance):
|
|||
master = [b for b in branches if b.name == "master"]
|
||||
assert len(master) > 0
|
||||
|
||||
def test_list_files(instance):
|
||||
org = Organization.request(instance, test_org)
|
||||
repo = org.get_repository(test_repo)
|
||||
content = repo.get_git_content()
|
||||
assert True
|
||||
|
||||
def test_create_branch(instance):
|
||||
org = Organization.request(instance, test_org)
|
||||
repo = org.get_repository(test_repo)
|
||||
|
|
Ładowanie…
Reference in New Issue