kopia lustrzana https://github.com/Langenfeld/py-gitea
fixed problems with branch listing (see #4)
request response for branches did behave strangelypull/5/head
rodzic
d0960a4b6f
commit
ac41c212b4
|
@ -193,6 +193,10 @@ class Branch(GiteaApiObject):
|
||||||
def __init__(self, gitea, id: int):
|
def __init__(self, gitea, id: int):
|
||||||
super(Branch, self).__init__(gitea, id=id)
|
super(Branch, self).__init__(gitea, id=id)
|
||||||
|
|
||||||
|
fields_to_parsers = {
|
||||||
|
"commit": lambda gitea, c: Commit.parse_response(gitea, c)
|
||||||
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def request(cls, gitea, owner, repo, ref):
|
def request(cls, gitea, owner, repo, ref):
|
||||||
return cls._request(gitea, {"owner": owner, "repo": repo, "ref": ref})
|
return cls._request(gitea, {"owner": owner, "repo": repo, "ref": ref})
|
||||||
|
@ -243,7 +247,7 @@ class Repository(GiteaApiObject):
|
||||||
"website",
|
"website",
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_branches(self) -> List[GiteaApiObject]:
|
def get_branches(self) -> List['Branch']:
|
||||||
"""Get all the Branches of this Repository."""
|
"""Get all the Branches of this Repository."""
|
||||||
results = self.gitea.requests_get(
|
results = self.gitea.requests_get(
|
||||||
Repository.REPO_BRANCHES % (self.owner.username, self.name)
|
Repository.REPO_BRANCHES % (self.owner.username, self.name)
|
||||||
|
@ -257,7 +261,7 @@ class Repository(GiteaApiObject):
|
||||||
result = self.gitea.requests_post(
|
result = self.gitea.requests_post(
|
||||||
Repository.REPO_BRANCHES % (self.owner.username, self.name), data=data
|
Repository.REPO_BRANCHES % (self.owner.username, self.name), data=data
|
||||||
)
|
)
|
||||||
return Commit.parse_response(self.gitea, result)
|
return Branch.parse_response(self.gitea, result)
|
||||||
|
|
||||||
def get_issues(self) -> List["Issue"]:
|
def get_issues(self) -> List["Issue"]:
|
||||||
"""Get all Issues of this Repository (open and closed)"""
|
"""Get all Issues of this Repository (open and closed)"""
|
||||||
|
@ -444,12 +448,10 @@ class Commit(GiteaApiObject):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse_response(cls, gitea, result):
|
def parse_response(cls, gitea, result):
|
||||||
id = result["sha"]
|
id = result["id"] #``sha`` is now called ``id``
|
||||||
# gitea.logger.debug("Found api object of type %s (id: %s)" % (type(cls), id))
|
# gitea.logger.debug("Found api object of type %s (id: %s)" % (type(cls), id))
|
||||||
api_object = cls(gitea, id=id)
|
api_object = cls(gitea, id=id)
|
||||||
cls._initialize(gitea, api_object, result)
|
cls._initialize(gitea, api_object, result)
|
||||||
# HACK
|
|
||||||
api_object.__setattr__("id", uuid.uuid1().int >> 64)
|
|
||||||
return api_object
|
return api_object
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ def test_create_branch(instance):
|
||||||
branches = repo.get_branches()
|
branches = repo.get_branches()
|
||||||
master = [b for b in branches if b.name == "master"]
|
master = [b for b in branches if b.name == "master"]
|
||||||
assert len(master) > 0
|
assert len(master) > 0
|
||||||
repo.add_branch(master[0], "test123")
|
repo.add_branch(master[0], "test_branch")
|
||||||
|
|
||||||
def test_create_team(instance):
|
def test_create_team(instance):
|
||||||
org = Organization.request(instance, test_org)
|
org = Organization.request(instance, test_org)
|
||||||
|
|
Ładowanie…
Reference in New Issue