summaryrefslogtreecommitdiff
path: root/kodereviewer/network_manager.py
diff options
context:
space:
mode:
Diffstat (limited to 'kodereviewer/network_manager.py')
-rw-r--r--kodereviewer/network_manager.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/kodereviewer/network_manager.py b/kodereviewer/network_manager.py
index 62b6047..ebc2797 100644
--- a/kodereviewer/network_manager.py
+++ b/kodereviewer/network_manager.py
@@ -5,6 +5,7 @@ from PySide6.QtCore import QObject, QSettings, Signal, Slot, Property, qDebug
from PySide6.QtNetwork import QHttpHeaders, QNetworkAccessManager, QNetworkReply, QNetworkRequestFactory
from PySide6.QtQml import QmlElement
+from kodereviewer.data import PullRequest
from kodereviewer.project import Project
QML_IMPORT_NAME = "org.deprecated.kodereviewer"
@@ -12,6 +13,7 @@ QML_IMPORT_MAJOR_VERSION = 1
PULL_REQUEST_LIST_URL = re.compile(r'/pulls$')
COMMENT_LIST_URL = re.compile(r'/issues/(\d+)/comments')
+FILE_LIST_URL = re.compile(r'/pulls/(\d+)/files')
@QmlElement
@@ -69,6 +71,11 @@ class NetworkManager(QObject):
pull_request = self._project.find_pull_request(pull_request_number)
if pull_request is not None:
pull_request.load_comments(response_body)
+ elif (match := FILE_LIST_URL.search(reply.url().toString())):
+ pull_request_number = int(match.groups()[0])
+ pull_request: Optional[PullRequest] = self._project.find_pull_request(pull_request_number)
+ if pull_request is not None:
+ pull_request.load_files(response_body)
else:
print(f"Can't handle {reply.url()}")
@@ -79,3 +86,7 @@ class NetworkManager(QObject):
@Slot(int)
def getPullRequestComments(self, number: int) -> None:
self._manager.get(self._request_factory.createRequest(f'/issues/{number}/comments'))
+
+ @Slot(int)
+ def getFiles(self, pull_request_number) -> None:
+ self._manager.get(self._request_factory.createRequest(f'/pulls/{pull_request_number}/files'))