420dedbc1e
- Add IM service modules: audit, channel roles, custom emojis, forum tags, integrations, invitations, repo links, slash commands, stages, voice, webhooks - Add PR service modules: review requests, templates - Add repo service modules: contributors, release assets, git extras (archive, branch rename, commit extras, diff/merge, tag, tree) - Add user service: social (follow/block) - Add internal auth service - Update existing service modules with expanded functionality - Remove deleted IM modules: articles, delivery trace, drafts, follows, messages, polls, presence, reactions, threads
43 lines
1.6 KiB
Rust
43 lines
1.6 KiB
Rust
use crate::error::AppError;
|
|
use crate::service::RepoService;
|
|
use crate::session::Session;
|
|
|
|
impl RepoService {
|
|
pub async fn git_archive(
|
|
&self,
|
|
ctx: &Session,
|
|
wk_name: &str,
|
|
repo_name: &str,
|
|
format: i32,
|
|
treeish: &str,
|
|
) -> Result<tonic::Streaming<crate::pb::repo::ArchiveChunk>, AppError> {
|
|
let user_uid = ctx.user().ok_or(AppError::Unauthorized)?;
|
|
let repo = self.resolve_repo(wk_name, repo_name).await?;
|
|
self.ensure_repo_readable(user_uid, &repo).await?;
|
|
let ws = self.resolve_workspace(wk_name).await?;
|
|
let header = self.repo_header(&repo, &ws);
|
|
let mut svc = self.git_client(&repo)?.archive;
|
|
let resp = svc
|
|
.get_archive(tonic::Request::new(crate::pb::repo::ArchiveRequest {
|
|
repository: Some(header),
|
|
treeish: Some(crate::pb::repo::ObjectSelector {
|
|
selector: Some(crate::pb::repo::object_selector::Selector::Revision(
|
|
crate::pb::repo::ObjectName {
|
|
revision: treeish.to_string(),
|
|
},
|
|
)),
|
|
}),
|
|
options: Some(crate::pb::repo::ArchiveOptions {
|
|
format,
|
|
prefix: String::new(),
|
|
pathspec: Vec::new(),
|
|
compression_level: 0,
|
|
include_global_extended_pax_headers: false,
|
|
}),
|
|
}))
|
|
.await
|
|
.map_err(|e| AppError::InternalServerError(e.to_string()))?;
|
|
Ok(resp.into_inner())
|
|
}
|
|
}
|