fixed a crash and updated banner
This commit is contained in:
@@ -2,6 +2,7 @@ from textual.screen import Screen
|
||||
from textual.app import ComposeResult
|
||||
from textual.widgets import Input, Select, LoadingIndicator, Static, DataTable, ContentSwitcher, Tabs, Tab, Button
|
||||
from textual.containers import VerticalGroup, Vertical, HorizontalGroup, Right
|
||||
from textual import work
|
||||
|
||||
from widgets import Navbar
|
||||
|
||||
@@ -83,8 +84,9 @@ class RepoViewScreen(Screen):
|
||||
return "\uf15b"
|
||||
else:
|
||||
return "\ue5ff"
|
||||
|
||||
async def on_mount(self):
|
||||
|
||||
@work(thread=True, exclusive=True)
|
||||
def on_mount(self):
|
||||
files: DataTable = self.query_one("#files")
|
||||
loading = self.query_one(LoadingIndicator)
|
||||
|
||||
@@ -123,18 +125,31 @@ class RepoViewScreen(Screen):
|
||||
|
||||
|
||||
rows = []
|
||||
commits = requests.get(
|
||||
self.app.GITEA_HOST + f"api/v1/repos/{self.owner_name}/{self.repo_name}/commits",
|
||||
params={
|
||||
"path": "."
|
||||
}
|
||||
).json()
|
||||
commit_page_number = 1
|
||||
page_size = 50
|
||||
commit_data = {}
|
||||
for commit in commits:
|
||||
commit_data[commit["sha"]] = commit
|
||||
|
||||
while True:
|
||||
commits = requests.get(
|
||||
self.app.GITEA_HOST + f"api/v1/repos/{self.owner_name}/{self.repo_name}/commits",
|
||||
params={
|
||||
#"path": ".",
|
||||
"verification": False,
|
||||
"files": False,
|
||||
"page": commit_page_number,
|
||||
"limit": page_size
|
||||
}
|
||||
).json()
|
||||
|
||||
|
||||
commit_data.update({commit["sha"]: commit for commit in commits})
|
||||
|
||||
if len(commits) == page_size: # we reached end of the page
|
||||
commit_page_number += 1
|
||||
else:
|
||||
break
|
||||
|
||||
for file in files_response.json():
|
||||
|
||||
commit = commit_data[file["last_commit_sha"]]
|
||||
|
||||
commit_created_at = datetime.fromisoformat(commit["created"]).replace(tzinfo=None)
|
||||
@@ -142,7 +157,7 @@ class RepoViewScreen(Screen):
|
||||
rows.append((
|
||||
f"[cyan]{self.get_icon_from_name_and_type(file["name"], file["type"] != "file")}[/] {file["name"]}",
|
||||
f"[d]{commit["commit"]["message"]}",
|
||||
f"Updated {time_delta(datetime.now() - commit_created_at)} ago"
|
||||
f"[d]Updated {time_delta(datetime.now() - commit_created_at)} ago"
|
||||
))
|
||||
files.add_rows(rows)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user