get commit info, needs to be sped up a ton tho
This commit is contained in:
@@ -5,6 +5,9 @@ from textual.containers import VerticalGroup, Vertical, HorizontalGroup, Right
|
|||||||
|
|
||||||
from widgets import Navbar
|
from widgets import Navbar
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
from human_readable import time_delta
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
@@ -120,8 +123,22 @@ class RepoViewScreen(Screen):
|
|||||||
|
|
||||||
|
|
||||||
rows = []
|
rows = []
|
||||||
|
commit_data = {}
|
||||||
for file in files_response.json():
|
for file in files_response.json():
|
||||||
rows.append((f"[cyan]{self.get_icon_from_name_and_type(file["name"], file["type"] != "file")}[/] {file["name"]}", "[d]todo lol", "Updated idk ago"))
|
|
||||||
|
commit_sha = file["last_commit_sha"]
|
||||||
|
commit = commit_data[commit_sha] if commit_sha in commit_data else requests.get(
|
||||||
|
self.app.GITEA_HOST + f"api/v1/repos/{self.owner_name}/{self.repo_name}/git/commits/{file["last_commit_sha"]}"
|
||||||
|
).json()
|
||||||
|
commit_data[commit_sha] = commit
|
||||||
|
|
||||||
|
commit_created_at = datetime.fromisoformat(commit["created"]).replace(tzinfo=None)
|
||||||
|
|
||||||
|
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"
|
||||||
|
))
|
||||||
files.add_rows(rows)
|
files.add_rows(rows)
|
||||||
|
|
||||||
files.display = True
|
files.display = True
|
||||||
|
|||||||
Reference in New Issue
Block a user