1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

Add Package.get_revision_list() for listing commit log

This commit is contained in:
Daniel Mach 2024-04-17 10:51:46 +02:00
parent eb2678e0c7
commit 89f74665d1
2 changed files with 53 additions and 0 deletions

View File

@ -3,6 +3,7 @@ from ..util.models import * # pylint: disable=wildcard-import,unused-wildcard-i
from .flag import Flag from .flag import Flag
from .group_role import GroupRole from .group_role import GroupRole
from .package_devel import PackageDevel from .package_devel import PackageDevel
from .package_revision import PackageRevision
from .person_role import PersonRole from .person_role import PersonRole
from .simple_flag import SimpleFlag from .simple_flag import SimpleFlag
from .status import Status from .status import Status
@ -126,3 +127,20 @@ class Package(XmlModel):
} }
response = cls.xml_request("POST", apiurl, url_path, url_query) response = cls.xml_request("POST", apiurl, url_path, url_query)
return Status.from_file(response, apiurl=apiurl) return Status.from_file(response, apiurl=apiurl)
@classmethod
def get_revision_list(cls, apiurl: str, project: str, package: str, deleted: Optional[bool] = None, meta: Optional[bool] = None):
from xml.etree import ElementTree as ET
url_path = ["source", project, package, "_history"]
url_query = {
"meta": meta,
"deleted": deleted,
}
response = cls.xml_request("GET", apiurl, url_path, url_query)
root = ET.parse(response).getroot()
assert root.tag == "revisionlist"
result = []
for node in root:
result.append(PackageRevision.from_xml(node, apiurl=apiurl))
return result

View File

@ -0,0 +1,35 @@
from ..util.models import * # pylint: disable=wildcard-import,unused-wildcard-import
class PackageRevision(XmlModel):
XML_TAG = "revision"
rev: int = Field(
xml_attribute=True,
)
vrev: Optional[int] = Field(
xml_attribute=True,
)
srcmd5: str = Field(
)
version: str = Field(
)
time: int = Field(
)
user: str = Field(
)
comment: Optional[str] = Field(
)
requestid: Optional[int] = Field(
)
def get_time_str(self):
import time
return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(self.time))