don't
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(knot): rename repository wrapper and attach knot state

Signed-off-by: tjh <x@tjh.dev>

tjh 930848f7 860f8573

+21 -20
+8 -7
crates/knot/src/model/repository.rs
··· 23 23 use super::Knot; 24 24 25 25 #[derive(Debug)] 26 - pub struct GixRepository { 26 + pub struct TangledRepository { 27 + knot: Knot, 27 28 repository: gix::Repository, 28 29 } 29 30 30 - impl From<gix::Repository> for GixRepository { 31 - fn from(repository: gix::Repository) -> Self { 32 - Self { repository } 31 + impl From<(Knot, gix::Repository)> for TangledRepository { 32 + fn from((knot, repository): (Knot, gix::Repository)) -> Self { 33 + Self { knot, repository } 33 34 } 34 35 } 35 36 36 - impl GixRepository { 37 + impl TangledRepository { 37 38 /// Resolve a revspec into a [`(gix::Commit, bool)`] tuple. 38 39 /// 39 40 /// The boolean value indicates whether the revspec is immutable (ie. if ··· 461 460 } 462 461 } 463 462 464 - impl<S: Send + Sync> FromRequestParts<S> for GixRepository 463 + impl<S: Send + Sync> FromRequestParts<S> for TangledRepository 465 464 where 466 465 Knot: axum::extract::FromRef<S>, 467 466 { ··· 491 490 .map_err(errors::RepoNotFound)? 492 491 .to_thread_local(); 493 492 494 - Ok(Self { repository }) 493 + Ok(Self { knot, repository }) 495 494 } 496 495 }
+1 -1
crates/knot/src/model/repository/merge_check.rs
··· 13 13 public::xrpc::{XrpcError, XrpcResponse}, 14 14 }; 15 15 16 - impl super::GixRepository { 16 + impl super::TangledRepository { 17 17 pub fn merge_check(&self, params: Input) -> Result<XrpcResponse<Json<Output>>, XrpcError> { 18 18 let worktree = TempWorktree::new(&self.repository).map_err(errors::Internal)?; 19 19
+12 -12
crates/knot/src/public/xrpc/sh/tangled/repo.rs
··· 10 10 use tokio_rayon::AsyncThreadPool as _; 11 11 12 12 use crate::{ 13 - model::{Knot, errors, repository::GixRepository}, 13 + model::{Knot, errors, repository::TangledRepository}, 14 14 public::xrpc::{XrpcError, XrpcQuery, XrpcResult}, 15 15 services::authorization::{Authorization, Verification}, 16 16 types::{ ··· 23 23 pub async fn handle_blob( 24 24 State(knot): State<Knot>, 25 25 XrpcQuery(params): XrpcQuery<blob::Input<'static>>, 26 - repository: GixRepository, 26 + repository: TangledRepository, 27 27 ) -> XrpcResult<blob::Output> { 28 28 knot.pool() 29 29 .spawn_async(move || repository.blob(params)) ··· 34 34 pub async fn handle_branch( 35 35 State(knot): State<Knot>, 36 36 XrpcQuery(params): XrpcQuery<branch::Input>, 37 - repository: GixRepository, 37 + repository: TangledRepository, 38 38 ) -> XrpcResult<Json<branch::Output>> { 39 39 knot.pool() 40 40 .spawn_async(move || repository.branch(params)) ··· 45 45 pub async fn handle_branches( 46 46 State(knot): State<Knot>, 47 47 XrpcQuery(params): XrpcQuery<branches::Input<'static>>, 48 - repository: GixRepository, 48 + repository: TangledRepository, 49 49 ) -> XrpcResult<Json<branches::Output>> { 50 50 knot.pool() 51 51 .spawn_async(move || repository.branches(params)) ··· 55 55 pub async fn handle_compare( 56 56 State(knot): State<Knot>, 57 57 XrpcQuery(params): XrpcQuery<compare::Input<'static>>, 58 - repository: GixRepository, 58 + repository: TangledRepository, 59 59 ) -> XrpcResult<Json<compare::Output>> { 60 60 knot.pool() 61 61 .spawn_async(move || repository.compare(params)) ··· 192 192 pub async fn handle_diff( 193 193 State(knot): State<Knot>, 194 194 XrpcQuery(params): XrpcQuery<diff::Input<'static>>, 195 - repository: GixRepository, 195 + repository: TangledRepository, 196 196 ) -> XrpcResult<Json<diff::Output>> { 197 197 knot.pool() 198 198 .spawn_async(move || repository.diff(params)) ··· 203 203 pub async fn handle_get_default_branch( 204 204 State(knot): State<Knot>, 205 205 XrpcQuery(params): XrpcQuery<get_default_branch::Input<'static>>, 206 - repository: GixRepository, 206 + repository: TangledRepository, 207 207 ) -> XrpcResult<Json<get_default_branch::Output>> { 208 208 knot.pool() 209 209 .spawn_async(move || repository.get_default_branch(params)) ··· 230 230 .map_err(errors::RepoNotFound)? 231 231 .to_thread_local(); 232 232 233 - let repository: GixRepository = repo.into(); 233 + let repository: TangledRepository = (knot.clone(), repo).into(); 234 234 235 235 knot.pool() 236 236 .spawn_async(move || repository.merge_check(params)) ··· 241 241 pub async fn handle_languages( 242 242 State(knot): State<Knot>, 243 243 XrpcQuery(params): XrpcQuery<languages::Input<'static>>, 244 - repository: GixRepository, 244 + repository: TangledRepository, 245 245 ) -> XrpcResult<Json<languages::Output>> { 246 246 knot.pool() 247 247 .spawn_async(move || repository.languages(params)) ··· 252 252 pub async fn handle_log( 253 253 State(knot): State<Knot>, 254 254 XrpcQuery(params): XrpcQuery<log::Input<'static>>, 255 - repository: GixRepository, 255 + repository: TangledRepository, 256 256 ) -> XrpcResult<Json<log::Output>> { 257 257 knot.pool() 258 258 .spawn_async(move || repository.log(params)) ··· 263 263 pub async fn handle_tags( 264 264 State(knot): State<Knot>, 265 265 XrpcQuery(params): XrpcQuery<tags::Input<'static>>, 266 - repository: GixRepository, 266 + repository: TangledRepository, 267 267 ) -> XrpcResult<Json<tags::Output>> { 268 268 knot.pool() 269 269 .spawn_async(move || repository.tags(params)) ··· 274 274 pub async fn handle_tree( 275 275 State(knot): State<Knot>, 276 276 XrpcQuery(params): XrpcQuery<tree::Input<'static>>, 277 - repository: GixRepository, 277 + repository: TangledRepository, 278 278 ) -> XrpcResult<Json<tree::Output>> { 279 279 let cloned_knot = knot.clone(); 280 280 knot.pool()