Add repository file browser

This commit is contained in:
Georg Bauer
2026-07-31 11:25:46 +02:00
parent 4e4dfb0db9
commit 7b2b431dfd
11 changed files with 669 additions and 21 deletions

View File

@@ -222,6 +222,51 @@ pub async fn load_branches(
Ok(branches)
}
pub async fn load_repository_contents(
server: &Server,
owner: &str,
repository: &str,
path: &str,
) -> Result<Vec<models::ContentsResponse>, String> {
let client =
Client::new(&server.url, Some(&server.token)).map_err(|error| error.to_string())?;
let configuration = client.configuration();
if path.is_empty() {
apis::repository_api::repo_get_contents_list(&configuration, owner, repository, None)
.await
.map_err(|error| error.to_string())
} else {
apis::repository_api::repo_get_contents_ext(
&configuration,
owner,
repository,
path,
None,
None,
)
.await
.map(|contents| contents.dir_contents.unwrap_or_default())
.map_err(|error| error.to_string())
}
}
pub async fn load_repository_file(
server: &Server,
owner: &str,
repository: &str,
path: &str,
) -> Result<Vec<u8>, String> {
let client =
Client::new(&server.url, Some(&server.token)).map_err(|error| error.to_string())?;
apis::repository_api::repo_get_raw_file(&client.configuration(), owner, repository, path, None)
.await
.map_err(|error| error.to_string())?
.bytes()
.await
.map(|bytes| bytes.to_vec())
.map_err(|error| error.to_string())
}
pub async fn load_branch_commits(
server: &Server,
owner: &str,