diff --git a/crates/tangled-api/src/lexicon/com/atproto/repo/create_record.rs b/crates/tangled-api/src/lexicon/com/atproto/repo/create_record.rs index 4937c52..986ddcf 100644 --- a/crates/tangled-api/src/lexicon/com/atproto/repo/create_record.rs +++ b/crates/tangled-api/src/lexicon/com/atproto/repo/create_record.rs @@ -46,7 +46,11 @@ pub struct Output { /// /// Errors: /// - `InvalidSwap`: Indicates that 'swapCommit' didn't match current repo commit. -pub fn create_record(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn create_record( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = rb.json(input); diff --git a/crates/tangled-api/src/lexicon/com/atproto/repo/delete_record.rs b/crates/tangled-api/src/lexicon/com/atproto/repo/delete_record.rs index ef54747..b446b02 100644 --- a/crates/tangled-api/src/lexicon/com/atproto/repo/delete_record.rs +++ b/crates/tangled-api/src/lexicon/com/atproto/repo/delete_record.rs @@ -39,7 +39,11 @@ pub struct Output { /// /// Errors: /// - `InvalidSwap` -pub fn delete_record(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn delete_record( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = rb.json(input); diff --git a/crates/tangled-api/src/lexicon/com/atproto/repo/get_record.rs b/crates/tangled-api/src/lexicon/com/atproto/repo/get_record.rs index bd27cfa..4642abb 100644 --- a/crates/tangled-api/src/lexicon/com/atproto/repo/get_record.rs +++ b/crates/tangled-api/src/lexicon/com/atproto/repo/get_record.rs @@ -30,7 +30,11 @@ pub struct Output { /// /// Errors: /// - `RecordNotFound` -pub fn get_record(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn get_record( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = crate::xrpc::push_query(rb, params); diff --git a/crates/tangled-api/src/lexicon/com/atproto/repo/put_record.rs b/crates/tangled-api/src/lexicon/com/atproto/repo/put_record.rs index 68897a8..94d0736 100644 --- a/crates/tangled-api/src/lexicon/com/atproto/repo/put_record.rs +++ b/crates/tangled-api/src/lexicon/com/atproto/repo/put_record.rs @@ -52,7 +52,11 @@ pub struct Output { /// /// Errors: /// - `InvalidSwap` -pub fn put_record(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn put_record( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = rb.json(input); diff --git a/crates/tangled-api/src/lexicon/com/atproto/server/create_session.rs b/crates/tangled-api/src/lexicon/com/atproto/server/create_session.rs index 2b44178..46bbe39 100644 --- a/crates/tangled-api/src/lexicon/com/atproto/server/create_session.rs +++ b/crates/tangled-api/src/lexicon/com/atproto/server/create_session.rs @@ -32,7 +32,11 @@ pub struct Output { #[serde(skip_serializing_if = "Option::is_none", default)] pub active: Option, pub did: String, - #[serde(rename = "didDoc", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "didDoc", + skip_serializing_if = "Option::is_none", + default + )] pub did_doc: Option, #[serde(skip_serializing_if = "Option::is_none", default)] pub email: Option, diff --git a/crates/tangled-api/src/lexicon/com/atproto/server/refresh_session.rs b/crates/tangled-api/src/lexicon/com/atproto/server/refresh_session.rs index 95f2b42..c4169e2 100644 --- a/crates/tangled-api/src/lexicon/com/atproto/server/refresh_session.rs +++ b/crates/tangled-api/src/lexicon/com/atproto/server/refresh_session.rs @@ -12,7 +12,11 @@ pub struct Output { #[serde(skip_serializing_if = "Option::is_none", default)] pub active: Option, pub did: String, - #[serde(rename = "didDoc", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "didDoc", + skip_serializing_if = "Option::is_none", + default + )] pub did_doc: Option, #[serde(skip_serializing_if = "Option::is_none", default)] pub email: Option, @@ -42,7 +46,10 @@ pub struct Output { /// - `AccountTakedown` /// - `InvalidToken` /// - `ExpiredToken` -pub fn refresh_session(http: &reqwest::Client, base: &str) -> reqwest::RequestBuilder { +pub fn refresh_session( + http: &reqwest::Client, + base: &str, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); rb diff --git a/crates/tangled-api/src/lexicon/com/atproto/sync/get_blob.rs b/crates/tangled-api/src/lexicon/com/atproto/sync/get_blob.rs index 5aad961..6c4e663 100644 --- a/crates/tangled-api/src/lexicon/com/atproto/sync/get_blob.rs +++ b/crates/tangled-api/src/lexicon/com/atproto/sync/get_blob.rs @@ -23,7 +23,11 @@ pub struct Params { /// - `RepoDeactivated` /// /// The response body is binary; use [`crate::xrpc::send_bytes`]. -pub fn get_blob(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn get_blob( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = crate::xrpc::push_query(rb, params); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/actor/profile.rs b/crates/tangled-api/src/lexicon/sh/tangled/actor/profile.rs index 31af42a..bfb6585 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/actor/profile.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/actor/profile.rs @@ -9,7 +9,11 @@ pub const NSID: &str = "sh.tangled.actor.profile"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, /// Small image to be displayed next to posts from account. AKA, 'profile picture' #[serde(skip_serializing_if = "Option::is_none", default)] diff --git a/crates/tangled-api/src/lexicon/sh/tangled/ci/pipeline.rs b/crates/tangled-api/src/lexicon/sh/tangled/ci/pipeline.rs index 18ef195..0a85be1 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/ci/pipeline.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/ci/pipeline.rs @@ -8,7 +8,11 @@ pub struct Pipeline { /// Commit Id this pipeline is running on pub commit: String, - #[serde(rename = "createdAt", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "createdAt", + skip_serializing_if = "Option::is_none", + default + )] pub created_at: Option, /// Spindle-local pipeline id pub id: String, @@ -44,7 +48,11 @@ pub struct Workflow { pub id: String, /// Name of the workflow pub name: String, - #[serde(rename = "startedAt", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "startedAt", + skip_serializing_if = "Option::is_none", + default + )] pub started_at: Option, /// Workflow status pub status: String, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/feed/comment.rs b/crates/tangled-api/src/lexicon/sh/tangled/feed/comment.rs index bc10ce5..cb50c35 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/feed/comment.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/feed/comment.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.feed.comment"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, pub body: serde_json::Value, #[serde(rename = "createdAt")] @@ -20,8 +24,13 @@ pub struct Record { default )] pub pull_round_idx: Option, - #[serde(rename = "replyTo", skip_serializing_if = "Option::is_none", default)] - pub reply_to: Option, + #[serde( + rename = "replyTo", + skip_serializing_if = "Option::is_none", + default + )] + pub reply_to: + Option, pub subject: crate::lexicon::com::atproto::repo::strong_ref::StrongRef, /// Unknown fields, preserved across read-modify-write round-trips. #[serde(flatten)] diff --git a/crates/tangled-api/src/lexicon/sh/tangled/feed/reaction.rs b/crates/tangled-api/src/lexicon/sh/tangled/feed/reaction.rs index 1a5a892..c31929c 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/feed/reaction.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/feed/reaction.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.feed.reaction"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(rename = "createdAt")] pub created_at: String, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/feed/star.rs b/crates/tangled-api/src/lexicon/sh/tangled/feed/star.rs index abd7de9..b14d42a 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/feed/star.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/feed/star.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.feed.star"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(rename = "createdAt")] pub created_at: String, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/git/list_refs.rs b/crates/tangled-api/src/lexicon/sh/tangled/git/list_refs.rs index 2fcf4c5..b51e5c8 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/git/list_refs.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/git/list_refs.rs @@ -39,7 +39,8 @@ pub struct Output { skip_serializing_if = "Option::is_none", default )] - pub default_branch: Option, + pub default_branch: + Option, pub refs: Vec, } @@ -48,7 +49,11 @@ pub struct Output { /// Errors: /// - `RepoNotFound`: Repo is not registered on this knot /// - `InvalidRequest`: Invalid request parameters -pub fn list_refs(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn list_refs( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = crate::xrpc::push_query(rb, params); diff --git a/crates/tangled-api/src/lexicon/sh/tangled/git/ref_update.rs b/crates/tangled-api/src/lexicon/sh/tangled/git/ref_update.rs index bf6157f..cf8ccd5 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/git/ref_update.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/git/ref_update.rs @@ -46,7 +46,11 @@ pub const NSID: &str = "sh.tangled.git.refUpdate"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, /// files changed between commits #[serde( @@ -66,7 +70,11 @@ pub struct Record { #[serde(rename = "oldSha")] pub old_sha: String, /// did of the owner of the repo - #[serde(rename = "ownerDid", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "ownerDid", + skip_serializing_if = "Option::is_none", + default + )] pub owner_did: Option, /// push options passed on git-push #[serde( @@ -87,7 +95,8 @@ pub struct Record { #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Meta { #[serde(rename = "commitCount")] - pub commit_count: crate::lexicon::sh::tangled::git::ref_update::CommitCountBreakdown, + pub commit_count: + crate::lexicon::sh::tangled::git::ref_update::CommitCountBreakdown, #[serde(rename = "isDefaultRef")] pub is_default_ref: bool, #[serde( @@ -95,7 +104,8 @@ pub struct Meta { skip_serializing_if = "Option::is_none", default )] - pub lang_breakdown: Option, + pub lang_breakdown: + Option, /// Unknown fields, preserved across read-modify-write round-trips. #[serde(flatten)] pub extra: serde_json::Map, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/analyze_merge.rs b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/analyze_merge.rs index 2f1a1b8..2d42dcb 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/analyze_merge.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/analyze_merge.rs @@ -30,7 +30,11 @@ pub struct Params { pub struct Output { /// List of files with merge conflicts #[serde(skip_serializing_if = "Option::is_none", default)] - pub conflicts: Option>, + pub conflicts: Option< + Vec< + crate::lexicon::sh::tangled::git::temp::analyze_merge::ConflictInfo, + >, + >, /// Whether the merge has conflicts pub is_conflicted: bool, } diff --git a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_archive.rs b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_archive.rs index d8d503c..bbfb190 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_archive.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_archive.rs @@ -27,7 +27,11 @@ pub struct Params { /// - `ArchiveError`: Failed to create archive /// /// The response body is binary; use [`crate::xrpc::send_bytes`]. -pub fn get_archive(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn get_archive( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = crate::xrpc::push_query(rb, params); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_blob.rs b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_blob.rs index c6b6174..a438e97 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_blob.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_blob.rs @@ -23,7 +23,11 @@ pub struct Params { /// - `InvalidRequest`: Invalid request parameters /// /// The response body is binary; use [`crate::xrpc::send_bytes`]. -pub fn get_blob(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn get_blob( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = crate::xrpc::push_query(rb, params); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_branch.rs b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_branch.rs index e4e7fc9..b213bd8 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_branch.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_branch.rs @@ -33,7 +33,11 @@ pub struct Output { /// - `RepoNotFound`: Repository not found or access denied /// - `BranchNotFound`: Branch not found /// - `InvalidRequest`: Invalid request parameters -pub fn get_branch(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn get_branch( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = crate::xrpc::push_query(rb, params); diff --git a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_commit.rs b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_commit.rs index 1bd3ce1..17b16b3 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_commit.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_commit.rs @@ -21,7 +21,11 @@ pub type Output = crate::lexicon::sh::tangled::git::temp::defs::Commit; /// - `RepoNotFound`: Repository not found or access denied /// - `CommitNotFound`: Commit not found /// - `InvalidRequest`: Invalid request parameters -pub fn get_commit(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn get_commit( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = crate::xrpc::push_query(rb, params); diff --git a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_diff.rs b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_diff.rs index fb3002d..5ba32ce 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_diff.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_diff.rs @@ -23,7 +23,11 @@ pub struct Params { /// - `CompareError`: Failed to compare revisions /// /// The response body is binary; use [`crate::xrpc::send_bytes`]. -pub fn get_diff(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn get_diff( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = crate::xrpc::push_query(rb, params); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_entry.rs b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_entry.rs index e6865ef..9465231 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_entry.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_entry.rs @@ -23,7 +23,8 @@ pub struct Output { skip_serializing_if = "Option::is_none", default )] - pub last_commit: Option, + pub last_commit: + Option, pub mode: String, /// The file name pub name: String, @@ -31,7 +32,8 @@ pub struct Output { /// Blob size pub size: i64, #[serde(skip_serializing_if = "Option::is_none", default)] - pub submodule: Option, + pub submodule: + Option, } /// get metadata of blob by ref and path @@ -41,7 +43,11 @@ pub struct Output { /// - `RefNotFound`: Git reference not found /// - `EntryNotFound`: Entry not found /// - `InvalidRequest`: Invalid request parameters -pub fn get_entry(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn get_entry( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = crate::xrpc::push_query(rb, params); diff --git a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_head.rs b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_head.rs index 1166625..5484702 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_head.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_head.rs @@ -17,7 +17,11 @@ pub type Output = crate::lexicon::sh::tangled::git::temp::defs::Branch; /// Errors: /// - `RepoNotFound`: Repository not found or access denied /// - `InvalidRequest`: Invalid request parameters -pub fn get_head(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn get_head( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = crate::xrpc::push_query(rb, params); diff --git a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_tag.rs b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_tag.rs index 1236911..fb98068 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_tag.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_tag.rs @@ -20,7 +20,11 @@ pub struct Params { /// - `InvalidRequest`: Invalid request parameters /// /// The response body is binary; use [`crate::xrpc::send_bytes`]. -pub fn get_tag(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn get_tag( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = crate::xrpc::push_query(rb, params); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_tree.rs b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_tree.rs index 7fa2c36..49a9a0f 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_tree.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/get_tree.rs @@ -6,7 +6,8 @@ #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct LastCommit { #[serde(skip_serializing_if = "Option::is_none", default)] - pub author: Option, + pub author: + Option, /// Commit hash pub hash: String, /// Commit message @@ -42,12 +43,14 @@ pub struct Output { skip_serializing_if = "Option::is_none", default )] - pub last_commit: Option, + pub last_commit: + Option, /// The parent path in the tree #[serde(skip_serializing_if = "Option::is_none", default)] pub parent: Option, #[serde(skip_serializing_if = "Option::is_none", default)] - pub readme: Option, + pub readme: + Option, /// The git reference used pub r#ref: String, } @@ -58,7 +61,11 @@ pub struct Output { /// - `RefNotFound`: Git reference not found /// - `PathNotFound`: Path not found in repository tree /// - `InvalidRequest`: Invalid request parameters -pub fn get_tree(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn get_tree( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = crate::xrpc::push_query(rb, params); @@ -92,7 +99,8 @@ pub struct Signature { #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct TreeEntry { #[serde(skip_serializing_if = "Option::is_none", default)] - pub last_commit: Option, + pub last_commit: + Option, /// File mode pub mode: String, /// Relative file or directory name diff --git a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/list_languages.rs b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/list_languages.rs index 9e0d2e2..4d6ed6f 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/list_languages.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/list_languages.rs @@ -27,7 +27,8 @@ pub struct Params { #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Output { - pub languages: Vec, + pub languages: + Vec, /// The git reference used pub r#ref: String, /// Total size of all analyzed files in bytes diff --git a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/list_tags.rs b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/list_tags.rs index 3720cf6..d239b9d 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/git/temp/list_tags.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/git/temp/list_tags.rs @@ -23,7 +23,11 @@ pub struct Params { /// - `InvalidRequest`: Invalid request parameters /// /// The response body is binary; use [`crate::xrpc::send_bytes`]. -pub fn list_tags(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn list_tags( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = crate::xrpc::push_query(rb, params); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/graph/follow.rs b/crates/tangled-api/src/lexicon/sh/tangled/graph/follow.rs index 254c662..78800fd 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/graph/follow.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/graph/follow.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.graph.follow"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(rename = "createdAt")] pub created_at: String, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/graph/vouch.rs b/crates/tangled-api/src/lexicon/sh/tangled/graph/vouch.rs index 235c0a0..6d93776 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/graph/vouch.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/graph/vouch.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.graph.vouch"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(rename = "createdAt")] pub created_at: String, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/knot/add_member.rs b/crates/tangled-api/src/lexicon/sh/tangled/knot/add_member.rs index 95977b1..3c18dcf 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/knot/add_member.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/knot/add_member.rs @@ -14,7 +14,11 @@ pub struct Input { /// Add a member to this knot /// /// The response has no body; use [`crate::xrpc::send_unit`]. -pub fn add_member(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn add_member( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.json(input); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/knot/list_keys.rs b/crates/tangled-api/src/lexicon/sh/tangled/knot/list_keys.rs index 0318b21..9c8b43f 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/knot/list_keys.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/knot/list_keys.rs @@ -27,7 +27,11 @@ pub struct Output { /// /// Errors: /// - `InternalServerError`: Failed to retrieve public keys -pub fn list_keys(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn list_keys( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = crate::xrpc::push_query(rb, params); diff --git a/crates/tangled-api/src/lexicon/sh/tangled/knot/member.rs b/crates/tangled-api/src/lexicon/sh/tangled/knot/member.rs index 93c5b6d..061f6f0 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/knot/member.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/knot/member.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.knot.member"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(rename = "createdAt")] pub created_at: String, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/knot/mod.rs b/crates/tangled-api/src/lexicon/sh/tangled/knot/mod.rs index 0322d84..e6bdf1f 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/knot/mod.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/knot/mod.rs @@ -22,7 +22,11 @@ pub const NSID: &str = "sh.tangled.knot"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(rename = "createdAt")] pub created_at: String, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/knot/remove_member.rs b/crates/tangled-api/src/lexicon/sh/tangled/knot/remove_member.rs index 1449167..f6523ac 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/knot/remove_member.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/knot/remove_member.rs @@ -14,7 +14,11 @@ pub struct Input { /// Remove a member from this knot /// /// The response has no body; use [`crate::xrpc::send_unit`]. -pub fn remove_member(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn remove_member( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.json(input); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/label/definition.rs b/crates/tangled-api/src/lexicon/sh/tangled/label/definition.rs index 7e363be..0b68cc3 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/label/definition.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/label/definition.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.label.definition"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, /// The hex value for the background color for the label. Appviews may choose to respect this. #[serde(skip_serializing_if = "Option::is_none", default)] diff --git a/crates/tangled-api/src/lexicon/sh/tangled/label/op.rs b/crates/tangled-api/src/lexicon/sh/tangled/label/op.rs index 4ef2f98..a5e15f6 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/label/op.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/label/op.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.label.op"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, pub add: Vec, pub delete: Vec, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/pipeline/mod.rs b/crates/tangled-api/src/lexicon/sh/tangled/pipeline/mod.rs index 9d811a5..c79d51c 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/pipeline/mod.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/pipeline/mod.rs @@ -24,10 +24,15 @@ pub const NSID: &str = "sh.tangled.pipeline"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(rename = "triggerMetadata")] - pub trigger_metadata: crate::lexicon::sh::tangled::pipeline::TriggerMetadata, + pub trigger_metadata: + crate::lexicon::sh::tangled::pipeline::TriggerMetadata, pub workflows: Vec, /// Unknown fields, preserved across read-modify-write round-trips. #[serde(flatten)] @@ -89,13 +94,15 @@ pub struct PushTriggerData { pub struct TriggerMetadata { pub kind: String, #[serde(skip_serializing_if = "Option::is_none", default)] - pub manual: Option, + pub manual: + Option, #[serde( rename = "pullRequest", skip_serializing_if = "Option::is_none", default )] - pub pull_request: Option, + pub pull_request: + Option, #[serde(skip_serializing_if = "Option::is_none", default)] pub push: Option, pub repo: crate::lexicon::sh::tangled::pipeline::TriggerRepo, @@ -120,7 +127,11 @@ pub struct TriggerRepo { #[serde(skip_serializing_if = "Option::is_none", default)] pub repo: Option, /// DID of the repo itself - #[serde(rename = "repoDid", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "repoDid", + skip_serializing_if = "Option::is_none", + default + )] pub repo_did: Option, /// Unknown fields, preserved across read-modify-write round-trips. #[serde(flatten)] diff --git a/crates/tangled-api/src/lexicon/sh/tangled/pipeline/status.rs b/crates/tangled-api/src/lexicon/sh/tangled/pipeline/status.rs index 54633d3..15f7c14 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/pipeline/status.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/pipeline/status.rs @@ -9,7 +9,11 @@ pub const NSID: &str = "sh.tangled.pipeline.status"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, /// time of creation of this status update #[serde(rename = "createdAt")] @@ -18,7 +22,11 @@ pub struct Record { #[serde(skip_serializing_if = "Option::is_none", default)] pub error: Option, /// exit code if failed - #[serde(rename = "exitCode", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "exitCode", + skip_serializing_if = "Option::is_none", + default + )] pub exit_code: Option, /// ATURI of the pipeline pub pipeline: String, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/public_key.rs b/crates/tangled-api/src/lexicon/sh/tangled/public_key.rs index 452cc72..b20b216 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/public_key.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/public_key.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.publicKey"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, /// key upload timestamp #[serde(rename = "createdAt")] diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/add_secret.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/add_secret.rs index ea12d7f..e13b740 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/add_secret.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/add_secret.rs @@ -15,7 +15,11 @@ pub struct Input { /// Add a CI secret /// /// The response has no body; use [`crate::xrpc::send_unit`]. -pub fn add_secret(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn add_secret( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.json(input); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/archive.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/archive.rs index 36c6363..fa9f75a 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/archive.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/archive.rs @@ -27,7 +27,11 @@ pub struct Params { /// - `ArchiveError`: Failed to create archive /// /// The response body is binary; use [`crate::xrpc::send_bytes`]. -pub fn archive(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn archive( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = crate::xrpc::push_query(rb, params); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/artifact.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/artifact.rs index bfc8659..2cdafbe 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/artifact.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/artifact.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.repo.artifact"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, /// the artifact pub artifact: crate::types::BlobRef, @@ -20,7 +24,11 @@ pub struct Record { /// repo that this artifact is being uploaded to #[serde(skip_serializing_if = "Option::is_none", default)] pub repo: Option, - #[serde(rename = "repoDid", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "repoDid", + skip_serializing_if = "Option::is_none", + default + )] pub repo_did: Option, /// hash of the tag object that this artifact is attached to (only annotated tags are supported) pub tag: serde_json::Value, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/blob.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/blob.rs index de9d5bd..19f2ffe 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/blob.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/blob.rs @@ -48,16 +48,25 @@ pub struct Output { )] pub file_too_large: Option, /// Whether the file is binary - #[serde(rename = "isBinary", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "isBinary", + skip_serializing_if = "Option::is_none", + default + )] pub is_binary: Option, #[serde( rename = "lastCommit", skip_serializing_if = "Option::is_none", default )] - pub last_commit: Option, + pub last_commit: + Option, /// MIME type of the file - #[serde(rename = "mimeType", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "mimeType", + skip_serializing_if = "Option::is_none", + default + )] pub mime_type: Option, /// The file path pub path: String, @@ -76,7 +85,11 @@ pub struct Output { /// - `RefNotFound`: Git reference not found /// - `FileNotFound`: File not found at the specified path /// - `InvalidRequest`: Invalid request parameters -pub fn blob(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn blob( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = crate::xrpc::push_query(rb, params); diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/branch.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/branch.rs index 29b1c37..6d2985f 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/branch.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/branch.rs @@ -20,7 +20,11 @@ pub struct Output { /// Latest commit hash on this branch pub hash: String, /// Whether this is the default branch - #[serde(rename = "isDefault", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "isDefault", + skip_serializing_if = "Option::is_none", + default + )] pub is_default: Option, /// Latest commit message #[serde(skip_serializing_if = "Option::is_none", default)] @@ -28,7 +32,11 @@ pub struct Output { /// Branch name pub name: String, /// Short commit hash - #[serde(rename = "shortHash", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "shortHash", + skip_serializing_if = "Option::is_none", + default + )] pub short_hash: Option, /// Timestamp of latest commit pub when: String, @@ -39,7 +47,11 @@ pub struct Output { /// - `RepoNotFound`: Repository not found or access denied /// - `BranchNotFound`: Branch not found /// - `InvalidRequest`: Invalid request parameters -pub fn branch(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn branch( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = crate::xrpc::push_query(rb, params); diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/branches.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/branches.rs index fa068dc..d601fa0 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/branches.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/branches.rs @@ -23,7 +23,11 @@ pub struct Params { /// - `InvalidRequest`: Invalid request parameters /// /// The response body is binary; use [`crate::xrpc::send_bytes`]. -pub fn branches(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn branches( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = crate::xrpc::push_query(rb, params); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/collaborator.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/collaborator.rs index a47d23a..d7279cd 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/collaborator.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/collaborator.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.repo.collaborator"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(rename = "createdAt")] pub created_at: String, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/compare.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/compare.rs index 2242761..7b83bcc 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/compare.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/compare.rs @@ -23,7 +23,11 @@ pub struct Params { /// - `CompareError`: Failed to compare revisions /// /// The response body is binary; use [`crate::xrpc::send_bytes`]. -pub fn compare(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn compare( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = crate::xrpc::push_query(rb, params); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/create.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/create.rs index 481966f..f4090d0 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/create.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/create.rs @@ -17,7 +17,11 @@ pub struct Input { /// Name of the repository pub name: String, /// Optional user-provided did:web to use as the repo identity instead of minting a did:plc. - #[serde(rename = "repoDid", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "repoDid", + skip_serializing_if = "Option::is_none", + default + )] pub repo_did: Option, /// Rkey of the repository record pub rkey: String, @@ -28,12 +32,20 @@ pub struct Input { #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Output { - #[serde(rename = "repoDid", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "repoDid", + skip_serializing_if = "Option::is_none", + default + )] pub repo_did: Option, } /// Create a new repository -pub fn create(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn create( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = rb.json(input); diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/delete.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/delete.rs index 07014d3..bb555e8 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/delete.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/delete.rs @@ -18,7 +18,11 @@ pub struct Input { /// Delete a repository /// /// The response has no body; use [`crate::xrpc::send_unit`]. -pub fn delete(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn delete( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.json(input); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/delete_branch.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/delete_branch.rs index 7d7fd13..dbfc957 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/delete_branch.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/delete_branch.rs @@ -14,7 +14,11 @@ pub struct Input { /// Delete a branch on this repository /// /// The response has no body; use [`crate::xrpc::send_unit`]. -pub fn delete_branch(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn delete_branch( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.json(input); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/diff.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/diff.rs index 230368a..abf754e 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/diff.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/diff.rs @@ -20,7 +20,11 @@ pub struct Params { /// - `InvalidRequest`: Invalid request parameters /// /// The response body is binary; use [`crate::xrpc::send_bytes`]. -pub fn diff(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn diff( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = crate::xrpc::push_query(rb, params); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/fork_status.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/fork_status.rs index 479230f..4d15f82 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/fork_status.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/fork_status.rs @@ -27,7 +27,11 @@ pub struct Output { } /// Check fork status relative to upstream source -pub fn fork_status(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn fork_status( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = rb.json(input); diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/fork_sync.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/fork_sync.rs index e3852bd..01ae715 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/fork_sync.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/fork_sync.rs @@ -20,7 +20,11 @@ pub struct Input { /// Sync a forked repository with its upstream source /// /// The response has no body; use [`crate::xrpc::send_unit`]. -pub fn fork_sync(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn fork_sync( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.json(input); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/get_default_branch.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/get_default_branch.rs index 74b6c5f..c28ad6f 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/get_default_branch.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/get_default_branch.rs @@ -14,7 +14,9 @@ pub struct Params { #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Output { #[serde(skip_serializing_if = "Option::is_none", default)] - pub author: Option, + pub author: Option< + crate::lexicon::sh::tangled::repo::get_default_branch::Signature, + >, /// Latest commit hash on default branch pub hash: String, /// Latest commit message @@ -23,7 +25,11 @@ pub struct Output { /// Default branch name pub name: String, /// Short commit hash - #[serde(rename = "shortHash", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "shortHash", + skip_serializing_if = "Option::is_none", + default + )] pub short_hash: Option, /// Timestamp of latest commit pub when: String, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/hidden_ref.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/hidden_ref.rs index cc54e76..90509eb 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/hidden_ref.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/hidden_ref.rs @@ -30,7 +30,11 @@ pub struct Output { } /// Create a hidden ref in a repository -pub fn hidden_ref(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn hidden_ref( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = rb.json(input); diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/issue/comment.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/issue/comment.rs index a1108bc..cde2364 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/issue/comment.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/issue/comment.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.repo.issue.comment"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, pub body: String, #[serde(rename = "createdAt")] @@ -18,7 +22,11 @@ pub struct Record { pub mentions: Option>, #[serde(skip_serializing_if = "Option::is_none", default)] pub references: Option>, - #[serde(rename = "replyTo", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "replyTo", + skip_serializing_if = "Option::is_none", + default + )] pub reply_to: Option, /// Unknown fields, preserved across read-modify-write round-trips. #[serde(flatten)] diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/issue/mod.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/issue/mod.rs index 87156b3..a87f34d 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/issue/mod.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/issue/mod.rs @@ -11,7 +11,11 @@ pub const NSID: &str = "sh.tangled.repo.issue"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(skip_serializing_if = "Option::is_none", default)] pub body: Option, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/issue/state/mod.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/issue/state/mod.rs index 9c2ae60..7f49944 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/issue/state/mod.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/issue/state/mod.rs @@ -11,7 +11,11 @@ pub const NSID: &str = "sh.tangled.repo.issue.state"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(rename = "createdAt")] pub created_at: String, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/languages.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/languages.rs index 08eda7b..793c110 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/languages.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/languages.rs @@ -12,7 +12,11 @@ pub struct Language { #[serde(skip_serializing_if = "Option::is_none", default)] pub extensions: Option>, /// Number of files in this language - #[serde(rename = "fileCount", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "fileCount", + skip_serializing_if = "Option::is_none", + default + )] pub file_count: Option, /// Programming language name pub name: String, @@ -49,7 +53,11 @@ pub struct Output { )] pub total_files: Option, /// Total size of all analyzed files in bytes - #[serde(rename = "totalSize", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "totalSize", + skip_serializing_if = "Option::is_none", + default + )] pub total_size: Option, } @@ -58,7 +66,11 @@ pub struct Output { /// - `RepoNotFound`: Repository not found or access denied /// - `RefNotFound`: Git reference not found /// - `InvalidRequest`: Invalid request parameters -pub fn languages(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn languages( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = crate::xrpc::push_query(rb, params); diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/list_collaborators.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/list_collaborators.rs index 8c22a4e..b32e899 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/list_collaborators.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/list_collaborators.rs @@ -44,7 +44,8 @@ pub struct Params { pub struct Output { #[serde(skip_serializing_if = "Option::is_none", default)] pub cursor: Option, - pub items: Vec, + pub items: + Vec, } pub fn list_collaborators( diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/list_collaborators_by.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/list_collaborators_by.rs index abc94a2..dbdf06c 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/list_collaborators_by.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/list_collaborators_by.rs @@ -23,7 +23,8 @@ pub struct Params { pub struct Output { #[serde(skip_serializing_if = "Option::is_none", default)] pub cursor: Option, - pub items: Vec, + pub items: + Vec, } pub fn list_collaborators_by( diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/log.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/log.rs index ea98be2..0296f0a 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/log.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/log.rs @@ -30,7 +30,11 @@ pub struct Params { /// - `InvalidRequest`: Invalid request parameters /// /// The response body is binary; use [`crate::xrpc::send_bytes`]. -pub fn log(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn log( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = crate::xrpc::push_query(rb, params); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/merge.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/merge.rs index 52ddb05..789945e 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/merge.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/merge.rs @@ -48,7 +48,11 @@ pub struct Input { /// Merge a patch into a repository branch /// /// The response has no body; use [`crate::xrpc::send_unit`]. -pub fn merge(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn merge( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.json(input); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/merge_check.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/merge_check.rs index ad8a6e1..c405a44 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/merge_check.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/merge_check.rs @@ -32,7 +32,9 @@ pub struct Input { pub struct Output { /// List of files with merge conflicts #[serde(skip_serializing_if = "Option::is_none", default)] - pub conflicts: Option>, + pub conflicts: Option< + Vec, + >, /// Error message if check failed #[serde(skip_serializing_if = "Option::is_none", default)] pub error: Option, @@ -44,7 +46,11 @@ pub struct Output { } /// Check if a merge is possible between two branches -pub fn merge_check(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn merge_check( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = rb.json(input); diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/mod.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/mod.rs index ff80201..a18e146 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/mod.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/mod.rs @@ -71,7 +71,11 @@ pub const NSID: &str = "sh.tangled.repo"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(rename = "createdAt")] pub created_at: String, @@ -86,7 +90,11 @@ pub struct Record { #[serde(skip_serializing_if = "Option::is_none", default)] pub name: Option, /// DID of the repo itself, if assigned - #[serde(rename = "repoDid", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "repoDid", + skip_serializing_if = "Option::is_none", + default + )] pub repo_did: Option, /// source of the repo #[serde(skip_serializing_if = "Option::is_none", default)] diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/pull/comment.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/pull/comment.rs index 6e11713..6890f29 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/pull/comment.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/pull/comment.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.repo.pull.comment"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, pub body: String, #[serde(rename = "createdAt")] diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/pull/mod.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/pull/mod.rs index 4e63581..dd5f807 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/pull/mod.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/pull/mod.rs @@ -11,7 +11,11 @@ pub const NSID: &str = "sh.tangled.repo.pull"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(skip_serializing_if = "Option::is_none", default)] pub body: Option, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/pull/status/mod.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/pull/status/mod.rs index 9517f80..d443dce 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/pull/status/mod.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/pull/status/mod.rs @@ -12,7 +12,11 @@ pub const NSID: &str = "sh.tangled.repo.pull.status"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(rename = "createdAt")] pub created_at: String, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/remove_secret.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/remove_secret.rs index fefe54d..1b850f7 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/remove_secret.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/remove_secret.rs @@ -14,7 +14,11 @@ pub struct Input { /// Remove a CI secret /// /// The response has no body; use [`crate::xrpc::send_unit`]. -pub fn remove_secret(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn remove_secret( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.json(input); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/tag.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/tag.rs index a5ecc15..d20ef75 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/tag.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/tag.rs @@ -20,7 +20,11 @@ pub struct Params { /// - `InvalidRequest`: Invalid request parameters /// /// The response body is binary; use [`crate::xrpc::send_bytes`]. -pub fn tag(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn tag( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = crate::xrpc::push_query(rb, params); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/tags.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/tags.rs index 079527e..2fc9524 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/tags.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/tags.rs @@ -23,7 +23,11 @@ pub struct Params { /// - `InvalidRequest`: Invalid request parameters /// /// The response body is binary; use [`crate::xrpc::send_bytes`]. -pub fn tags(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn tags( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = crate::xrpc::push_query(rb, params); rb diff --git a/crates/tangled-api/src/lexicon/sh/tangled/repo/tree.rs b/crates/tangled-api/src/lexicon/sh/tangled/repo/tree.rs index dcc92d3..8b277b2 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/repo/tree.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/repo/tree.rs @@ -42,7 +42,8 @@ pub struct Output { skip_serializing_if = "Option::is_none", default )] - pub last_commit: Option, + pub last_commit: + Option, /// The parent path in the tree #[serde(skip_serializing_if = "Option::is_none", default)] pub parent: Option, @@ -58,7 +59,11 @@ pub struct Output { /// - `RefNotFound`: Git reference not found /// - `PathNotFound`: Path not found in repository tree /// - `InvalidRequest`: Invalid request parameters -pub fn tree(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn tree( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = crate::xrpc::push_query(rb, params); @@ -92,7 +97,8 @@ pub struct Signature { #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct TreeEntry { #[serde(skip_serializing_if = "Option::is_none", default)] - pub last_commit: Option, + pub last_commit: + Option, /// File mode pub mode: String, /// Relative file or directory name diff --git a/crates/tangled-api/src/lexicon/sh/tangled/spindle/member.rs b/crates/tangled-api/src/lexicon/sh/tangled/spindle/member.rs index 8041949..8a1971d 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/spindle/member.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/spindle/member.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.spindle.member"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(rename = "createdAt")] pub created_at: String, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/spindle/mod.rs b/crates/tangled-api/src/lexicon/sh/tangled/spindle/mod.rs index fdf3731..cb547e0 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/spindle/mod.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/spindle/mod.rs @@ -10,7 +10,11 @@ pub const NSID: &str = "sh.tangled.spindle"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, #[serde(rename = "createdAt")] pub created_at: String, diff --git a/crates/tangled-api/src/lexicon/sh/tangled/string.rs b/crates/tangled-api/src/lexicon/sh/tangled/string.rs index e05658d..0ea448e 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/string.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/string.rs @@ -8,7 +8,11 @@ pub const NSID: &str = "sh.tangled.string"; #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct Record { /// Record type discriminator (`$type`); set to [`NSID`] when writing. - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub r#type: Option, pub contents: String, #[serde(rename = "createdAt")] diff --git a/crates/tangled-api/src/lexicon/sh/tangled/sync/list_repos.rs b/crates/tangled-api/src/lexicon/sh/tangled/sync/list_repos.rs index d918936..85187a9 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/sync/list_repos.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/sync/list_repos.rs @@ -40,7 +40,11 @@ pub struct Output { /// /// Errors: /// - `InvalidRequest`: Invalid request parameters -pub fn list_repos(http: &reqwest::Client, base: &str, params: &Params) -> reqwest::RequestBuilder { +pub fn list_repos( + http: &reqwest::Client, + base: &str, + params: &Params, +) -> reqwest::RequestBuilder { let rb = http.get(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.header(reqwest::header::ACCEPT, "application/json"); let rb = crate::xrpc::push_query(rb, params); @@ -54,7 +58,8 @@ pub struct Repo { skip_serializing_if = "Option::is_none", default )] - pub default_branch: Option, + pub default_branch: + Option, /// DID of the git repo as minted by the knot pub repo: String, /// Serving status of the repo according to the knot. diff --git a/crates/tangled-api/src/lexicon/sh/tangled/sync/request_crawl.rs b/crates/tangled-api/src/lexicon/sh/tangled/sync/request_crawl.rs index 049bb7d..414a7ec 100644 --- a/crates/tangled-api/src/lexicon/sh/tangled/sync/request_crawl.rs +++ b/crates/tangled-api/src/lexicon/sh/tangled/sync/request_crawl.rs @@ -24,7 +24,11 @@ pub struct Input { /// - `HostBanned` /// /// The response has no body; use [`crate::xrpc::send_unit`]. -pub fn request_crawl(http: &reqwest::Client, base: &str, input: &Input) -> reqwest::RequestBuilder { +pub fn request_crawl( + http: &reqwest::Client, + base: &str, + input: &Input, +) -> reqwest::RequestBuilder { let rb = http.post(crate::xrpc::xrpc_url(base, NSID)); let rb = rb.json(input); rb diff --git a/crates/tangled-api/src/types.rs b/crates/tangled-api/src/types.rs index b49094a..0e81608 100644 --- a/crates/tangled-api/src/types.rs +++ b/crates/tangled-api/src/types.rs @@ -5,7 +5,11 @@ use serde::{Deserialize, Serialize}; /// A blob reference as stored in records (`{"$type": "blob", "ref": {"$link": ...}, ...}`). #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct BlobRef { - #[serde(rename = "$type", skip_serializing_if = "Option::is_none", default)] + #[serde( + rename = "$type", + skip_serializing_if = "Option::is_none", + default + )] pub record_type: Option, #[serde(rename = "ref")] pub reference: BlobLink, diff --git a/crates/tangled-api/src/xrpc.rs b/crates/tangled-api/src/xrpc.rs index ee6635c..9cffa59 100644 --- a/crates/tangled-api/src/xrpc.rs +++ b/crates/tangled-api/src/xrpc.rs @@ -82,7 +82,9 @@ fn scalar_to_string(v: &serde_json::Value) -> String { } /// Sends the request and deserializes a JSON response body into `T`. -pub async fn send(rb: reqwest::RequestBuilder) -> Result { +pub async fn send( + rb: reqwest::RequestBuilder, +) -> Result { parse(rb.send().await?).await } @@ -93,14 +95,18 @@ pub async fn send_unit(rb: reqwest::RequestBuilder) -> Result<(), XrpcError> { /// Sends the request and returns the raw response bytes (for binary outputs /// such as `com.atproto.sync.getBlob`). -pub async fn send_bytes(rb: reqwest::RequestBuilder) -> Result, XrpcError> { +pub async fn send_bytes( + rb: reqwest::RequestBuilder, +) -> Result, XrpcError> { parse_bytes(rb.send().await?).await } /// Checks the status of an already-received response and deserializes its /// JSON body into `T`. Useful when the caller needs to inspect response /// headers (e.g. DPoP nonces) before handing off parsing. -pub async fn parse(res: reqwest::Response) -> Result { +pub async fn parse( + res: reqwest::Response, +) -> Result { let (url, body) = success_body(res).await?; serde_json::from_slice(&body).map_err(|source| XrpcError::Decode { url, @@ -120,7 +126,9 @@ pub async fn parse_bytes(res: reqwest::Response) -> Result, XrpcError> { success_body(res).await.map(|(_, body)| body.to_vec()) } -async fn success_body(res: reqwest::Response) -> Result<(String, bytes::Bytes), XrpcError> { +async fn success_body( + res: reqwest::Response, +) -> Result<(String, bytes::Bytes), XrpcError> { let status = res.status(); let url = res.url().to_string(); let body = res.bytes().await?; diff --git a/crates/tangled-api/tests/generated.rs b/crates/tangled-api/tests/generated.rs index 490a8d4..97333ac 100644 --- a/crates/tangled-api/tests/generated.rs +++ b/crates/tangled-api/tests/generated.rs @@ -15,7 +15,8 @@ fn record_round_trip_preserves_unknown_fields() { "labels": ["at://did:plc:x/sh.tangled.label.definition/abc"], "someFutureField": {"nested": true}, }); - let mut record: tangled_repo::Record = serde_json::from_value(live.clone()).unwrap(); + let mut record: tangled_repo::Record = + serde_json::from_value(live.clone()).unwrap(); assert_eq!(record.knot, "knot1.tangled.sh"); assert_eq!(record.r#type.as_deref(), Some(tangled_repo::NSID)); @@ -66,7 +67,10 @@ async fn query_builder_serializes_params_and_repeats_arrays() { .mock("GET", "/xrpc/com.atproto.repo.listRecords") .match_query(mockito::Matcher::AllOf(vec![ mockito::Matcher::UrlEncoded("repo".into(), "did:plc:abc".into()), - mockito::Matcher::UrlEncoded("collection".into(), "sh.tangled.repo".into()), + mockito::Matcher::UrlEncoded( + "collection".into(), + "sh.tangled.repo".into(), + ), mockito::Matcher::UrlEncoded("limit".into(), "100".into()), ])) .with_body(r#"{"records":[]}"#) diff --git a/crates/tangled-cli/src/cli.rs b/crates/tangled-cli/src/cli.rs index cf29a96..a4913e1 100644 --- a/crates/tangled-cli/src/cli.rs +++ b/crates/tangled-cli/src/cli.rs @@ -432,12 +432,14 @@ pub struct SpindleSecretRemoveArgs { #[cfg(test)] mod tests { - use super::*; use clap::Parser; + use super::*; + #[test] fn parses_raw_api_auth_status() { - let cli = Cli::try_parse_from(["tangled", "api", "auth", "status"]).unwrap(); + let cli = + Cli::try_parse_from(["tangled", "api", "auth", "status"]).unwrap(); assert!(matches!( cli.command, Command::Api(ApiCommand::Auth(AuthCommand::Status)) @@ -446,7 +448,8 @@ mod tests { #[test] fn parses_raw_api_repo_list() { - let cli = Cli::try_parse_from(["tangled", "api", "repo", "list"]).unwrap(); + let cli = + Cli::try_parse_from(["tangled", "api", "repo", "list"]).unwrap(); assert!(matches!( cli.command, Command::Api(ApiCommand::Repo(RepoCommand::List(_))) diff --git a/crates/tangled-cli/src/commands/auth.rs b/crates/tangled-cli/src/commands/auth.rs index 332a334..63a2a3c 100644 --- a/crates/tangled-cli/src/commands/auth.rs +++ b/crates/tangled-cli/src/commands/auth.rs @@ -47,7 +47,10 @@ async fn login(_cli: &Cli, mut args: AuthLoginArgs) -> Result<()> { .pds .unwrap_or_else(|| "https://bsky.social".to_string()); - let mut session = match crate::ops::session::login_with_password(&pds, &handle, &password).await + let mut session = match crate::ops::session::login_with_password( + &pds, &handle, &password, + ) + .await { Ok(sess) => sess, Err(e) => { diff --git a/crates/tangled-cli/src/commands/issue.rs b/crates/tangled-cli/src/commands/issue.rs index 24a5e9d..f190781 100644 --- a/crates/tangled-cli/src/commands/issue.rs +++ b/crates/tangled-cli/src/commands/issue.rs @@ -1,16 +1,20 @@ +use std::io::IsTerminal; + +use anyhow::{anyhow, Result}; +use dialoguer::Input; + use crate::cli::{ - Cli, IssueCommand, IssueCommentArgs, IssueCreateArgs, IssueEditArgs, IssueListArgs, - IssueShowArgs, + Cli, IssueCommand, IssueCommentArgs, IssueCreateArgs, IssueEditArgs, + IssueListArgs, IssueShowArgs, }; use crate::ops::types::Issue; -use anyhow::{anyhow, Result}; -use dialoguer::Input; -use std::io::IsTerminal; pub async fn run(_cli: &Cli, cmd: IssueCommand) -> Result<()> { match cmd { IssueCommand::List(args) => list(args, IssueMode::Convenience).await, - IssueCommand::Create(args) => create(args, IssueMode::Convenience).await, + IssueCommand::Create(args) => { + create(args, IssueMode::Convenience).await + } IssueCommand::Show(args) => show(args).await, IssueCommand::Edit(args) => edit(args).await, IssueCommand::Comment(args) => comment(args).await, @@ -52,7 +56,8 @@ async fn list(args: IssueListArgs, mode: IssueMode) -> Result<()> { let repo_filter_refs = if let Some(repo) = &repo_arg { let (owner, name) = parse_repo_ref(repo, &session.handle); - let info = crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; + let info = + crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; if let Some(context) = inferred.as_ref() { validate_remote_matches_repo(context, &info)?; } @@ -61,10 +66,13 @@ async fn list(args: IssueListArgs, mode: IssueMode) -> Result<()> { None }; - let mut items = crate::ops::issue::list_issues(&pds, &session.did, None, &auth).await?; + let mut items = + crate::ops::issue::list_issues(&pds, &session.did, None, &auth).await?; if let Some(repo_refs) = repo_filter_refs.as_ref() { - items.retain(|it| repo_refs.iter().any(|repo_ref| repo_ref == &it.issue.repo)); + items.retain(|it| { + repo_refs.iter().any(|repo_ref| repo_ref == &it.issue.repo) + }); } // Filter by state if requested @@ -81,7 +89,9 @@ async fn list(args: IssueListArgs, mode: IssueMode) -> Result<()> { }; // Fetch issue states - let states = crate::ops::issue::list_issue_states(&pds, &session.did, &auth).await?; + let states = + crate::ops::issue::list_issue_states(&pds, &session.did, &auth) + .await?; // Build map of issue AT-URI to current state let mut issue_states = std::collections::HashMap::new(); @@ -91,7 +101,10 @@ async fn list(args: IssueListArgs, mode: IssueMode) -> Result<()> { // Filter issues by state items.retain(|it| { - let issue_at = format!("at://{}/sh.tangled.repo.issue/{}", it.author_did, it.rkey); + let issue_at = format!( + "at://{}/sh.tangled.repo.issue/{}", + it.author_did, it.rkey + ); match issue_states.get(&issue_at) { Some(state) => state == state_nsid, None => state_nsid == "sh.tangled.repo.issue.state.open", // default to open @@ -109,23 +122,29 @@ async fn list(args: IssueListArgs, mode: IssueMode) -> Result<()> { std::collections::HashMap::new(); for it in items { - let repo_display = if let Some(cached) = repo_cache.get(&it.issue.repo) { + let repo_display = if let Some(cached) = + repo_cache.get(&it.issue.repo) + { cached.clone() - } else if let Some((repo_did, repo_rkey)) = parse_repo_at_uri(&it.issue.repo) { + } else if let Some((repo_did, repo_rkey)) = + parse_repo_at_uri(&it.issue.repo) + { // Fetch and format repo info - let formatted = - match crate::ops::repo::get_repo_by_rkey(&pds, &repo_did, &repo_rkey, &auth) + let formatted = match crate::ops::repo::get_repo_by_rkey( + &pds, &repo_did, &repo_rkey, &auth, + ) + .await + { + Ok(repo) => { + let handle = crate::ops::repo::resolve_did_to_handle( + &pds, &repo_did, &auth, + ) .await - { - Ok(repo) => { - let handle = - crate::ops::repo::resolve_did_to_handle(&pds, &repo_did, &auth) - .await - .unwrap_or(repo_did.clone()); - format!("{}/{}", handle, repo.name) - } - Err(_) => it.issue.repo.clone(), - }; + .unwrap_or(repo_did.clone()); + format!("{}/{}", handle, repo.name) + } + Err(_) => it.issue.repo.clone(), + }; repo_cache.insert(it.issue.repo.clone(), formatted.clone()); formatted } else { @@ -171,7 +190,8 @@ async fn create(args: IssueCreateArgs, mode: IssueMode) -> Result<()> { return Err(anyhow!("--repo is required for tangled api issue create")); }; let (owner, name) = parse_repo_ref(repo, &session.handle); - let info = crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; + let info = + crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; if let Some(context) = inferred.as_ref() { validate_remote_matches_repo(context, &info)?; } @@ -191,7 +211,10 @@ async fn create(args: IssueCreateArgs, mode: IssueMode) -> Result<()> { Ok(()) } -fn resolve_issue_title(provided: Option<&str>, mode: IssueMode) -> Result { +fn resolve_issue_title( + provided: Option<&str>, + mode: IssueMode, +) -> Result { if let Some(title) = provided { return Ok(title.to_string()); } @@ -206,7 +229,10 @@ fn resolve_issue_title(provided: Option<&str>, mode: IssueMode) -> Result, mode: IssueMode) -> Result> { +fn resolve_issue_body( + provided: Option<&str>, + mode: IssueMode, +) -> Result> { if let Some(body) = provided { return Ok(Some(body.to_string())); } @@ -228,7 +254,8 @@ fn validate_remote_matches_repo( ) -> Result<()> { let host = context.host.as_str(); let repo_knot = info.knot.as_str(); - let compatible = host == "tangled.org" && repo_knot == "knot1.tangled.sh" || host == repo_knot; + let compatible = host == "tangled.org" && repo_knot == "knot1.tangled.sh" + || host == repo_knot; if compatible { Ok(()) } else { @@ -280,7 +307,8 @@ async fn edit(args: IssueEditArgs) -> Result<()> { .or_else(|| std::env::var("TANGLED_PDS_BASE").ok()) .unwrap_or_else(|| "https://bsky.social".into()); // Get existing - let mut rec: Issue = crate::ops::issue::get_issue_record(&pds, &did, &rkey, &auth).await?; + let mut rec: Issue = + crate::ops::issue::get_issue_record(&pds, &did, &rkey, &auth).await?; if let Some(t) = args.title.as_deref() { rec.title = t.to_string(); } @@ -303,8 +331,14 @@ async fn edit(args: IssueEditArgs) -> Result<()> { } }; let issue_at = format!("at://{}/sh.tangled.repo.issue/{}", did, rkey); - crate::ops::issue::set_issue_state(&pds, &auth, &session.did, &issue_at, state_nsid) - .await?; + crate::ops::issue::set_issue_state( + &pds, + &auth, + &session.did, + &issue_at, + state_nsid, + ) + .await?; } println!("Updated issue {}:{}", did, rkey); Ok(()) @@ -320,10 +354,18 @@ async fn comment(args: IssueCommentArgs) -> Result<()> { .or_else(|| std::env::var("TANGLED_PDS_BASE").ok()) .unwrap_or_else(|| "https://bsky.social".into()); // Resolve issue AT-URI - let _issue = crate::ops::issue::get_issue_record(&pds, &did, &rkey, &auth).await?; + let _issue = + crate::ops::issue::get_issue_record(&pds, &did, &rkey, &auth).await?; let issue_at = format!("at://{}/sh.tangled.repo.issue/{}", did, rkey); if let Some(body) = args.body.as_deref() { - crate::ops::issue::comment_issue(&pds, &auth, &session.did, &issue_at, body).await?; + crate::ops::issue::comment_issue( + &pds, + &auth, + &session.did, + &issue_at, + body, + ) + .await?; println!("Comment posted"); } if args.close { @@ -340,7 +382,10 @@ async fn comment(args: IssueCommentArgs) -> Result<()> { Ok(()) } -fn parse_repo_ref<'a>(spec: &'a str, default_owner: &'a str) -> (&'a str, &'a str) { +fn parse_repo_ref<'a>( + spec: &'a str, + default_owner: &'a str, +) -> (&'a str, &'a str) { if let Some((owner, name)) = spec.split_once('/') { (owner, name) } else { @@ -348,7 +393,10 @@ fn parse_repo_ref<'a>(spec: &'a str, default_owner: &'a str) -> (&'a str, &'a st } } -fn parse_record_id<'a>(id: &'a str, default_did: &'a str) -> Result<(String, String)> { +fn parse_record_id<'a>( + id: &'a str, + default_did: &'a str, +) -> Result<(String, String)> { if let Some(rest) = id.strip_prefix("at://") { let parts: Vec<&str> = rest.split('/').collect(); if parts.len() >= 4 { diff --git a/crates/tangled-cli/src/commands/knot.rs b/crates/tangled-cli/src/commands/knot.rs index 48ae0e8..0ce988c 100644 --- a/crates/tangled-cli/src/commands/knot.rs +++ b/crates/tangled-cli/src/commands/knot.rs @@ -1,9 +1,10 @@ -use crate::cli::{Cli, KnotCommand, KnotMigrateArgs}; -use anyhow::anyhow; -use anyhow::Result; -use git2::{Direction, Repository as GitRepository, StatusOptions}; use std::path::Path; +use anyhow::{anyhow, Result}; +use git2::{Direction, Repository as GitRepository, StatusOptions}; + +use crate::cli::{Cli, KnotCommand, KnotMigrateArgs}; + pub async fn run(_cli: &Cli, cmd: KnotCommand) -> Result<()> { match cmd { KnotCommand::Migrate(args) => migrate(args).await, @@ -62,7 +63,9 @@ async fn migrate(args: KnotMigrateArgs) -> Result<()> { None } }) - .ok_or_else(|| anyhow!("origin does not have branch '{}' — push first", branch))?; + .ok_or_else(|| { + anyhow!("origin does not have branch '{}' — push first", branch) + })?; if remote_oid != head_oid { return Err(anyhow!( "local {} ({}) != origin {} ({}); please push before migrating", @@ -78,11 +81,13 @@ async fn migrate(args: KnotMigrateArgs) -> Result<()> { .url() .ok_or_else(|| anyhow!("origin has no URL"))? .to_string(); - let (origin_owner, origin_name, _origin_host) = parse_remote_url(&origin_url) - .ok_or_else(|| anyhow!("unsupported origin URL: {}", origin_url))?; + let (origin_owner, origin_name, _origin_host) = + parse_remote_url(&origin_url) + .ok_or_else(|| anyhow!("unsupported origin URL: {}", origin_url))?; let (owner, name) = parse_repo_ref(&args.repo, &session.handle); - if origin_owner.trim_start_matches('@') != owner.trim_start_matches('@') || origin_name != name + if origin_owner.trim_start_matches('@') != owner.trim_start_matches('@') + || origin_name != name { return Err(anyhow!( "repo mismatch: current checkout '{}'/{} != argument '{}'/{}", @@ -98,7 +103,8 @@ async fn migrate(args: KnotMigrateArgs) -> Result<()> { .clone() .or_else(|| std::env::var("TANGLED_PDS_BASE").ok()) .unwrap_or_else(|| "https://bsky.social".into()); - let info = crate::ops::repo::get_repo_info(&pds, owner, &name, &auth).await?; + let info = + crate::ops::repo::get_repo_info(&pds, owner, &name, &auth).await?; // Build a publicly accessible source URL on tangled.org for the existing repo let owner_path = if owner.starts_with('@') { @@ -132,7 +138,14 @@ async fn migrate(args: KnotMigrateArgs) -> Result<()> { // Update the PDS record to point to the new knot if args.update_record { - crate::ops::repo::update_repo_knot(&pds, &session.did, &info.rkey, &args.to, &auth).await?; + crate::ops::repo::update_repo_knot( + &pds, + &session.did, + &info.rkey, + &args.to, + &auth, + ) + .await?; } println!("Migrated repo '{}' to knot {}", name, args.to); @@ -143,7 +156,10 @@ async fn migrate(args: KnotMigrateArgs) -> Result<()> { Ok(()) } -fn parse_repo_ref<'a>(spec: &'a str, default_owner: &'a str) -> (&'a str, String) { +fn parse_repo_ref<'a>( + spec: &'a str, + default_owner: &'a str, +) -> (&'a str, String) { if let Some((owner, name)) = spec.split_once('/') { (owner, name.to_string()) } else { diff --git a/crates/tangled-cli/src/commands/pr.rs b/crates/tangled-cli/src/commands/pr.rs index c0fb54e..091c6ea 100644 --- a/crates/tangled-cli/src/commands/pr.rs +++ b/crates/tangled-cli/src/commands/pr.rs @@ -1,11 +1,16 @@ -use crate::cli::{Cli, PrCommand, PrCreateArgs, PrListArgs, PrMergeArgs, PrReviewArgs, PrShowArgs}; -use anyhow::{anyhow, Result}; -use dialoguer::{Editor, Input, Select}; use std::fs; use std::io::{IsTerminal, Read}; use std::path::{Path, PathBuf}; use std::process::Command; +use anyhow::{anyhow, Result}; +use dialoguer::{Editor, Input, Select}; + +use crate::cli::{ + Cli, PrCommand, PrCreateArgs, PrListArgs, PrMergeArgs, PrReviewArgs, + PrShowArgs, +}; + pub async fn run(_cli: &Cli, cmd: PrCommand) -> Result<()> { match cmd { PrCommand::List(args) => list(args).await, @@ -42,12 +47,14 @@ async fn list(args: PrListArgs) -> Result<()> { .unwrap_or_else(|| "https://bsky.social".into()); let target_repo_refs = if let Some(repo) = &args.repo { let (owner, name) = parse_repo_ref(repo, &session.handle); - let info = crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; + let info = + crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; Some(vec![info.issue_repo_ref(), info.repo_at_uri()]) } else { None }; - let mut pulls = crate::ops::pull::list_pulls(&pds, &session.did, None, &auth).await?; + let mut pulls = + crate::ops::pull::list_pulls(&pds, &session.did, None, &auth).await?; if let Some(repo_refs) = target_repo_refs.as_ref() { pulls.retain(|it| { repo_refs @@ -60,7 +67,12 @@ async fn list(args: PrListArgs) -> Result<()> { } else { println!("RKEY\tTITLE\tTARGET"); for pr in pulls { - println!("{}\t{}\t{}", pr.rkey, pr.pull.title, pr.pull.target_repo()); + println!( + "{}\t{}\t{}", + pr.rkey, + pr.pull.title, + pr.pull.target_repo() + ); } } Ok(()) @@ -90,7 +102,8 @@ async fn create(args: PrCreateArgs, mode: CreateMode) -> Result<()> { return Err(anyhow!("--repo is required for tangled api pr create")); }; let (owner, name) = parse_repo_ref(repo, ""); - let info = crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; + let info = + crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; if let Some(context) = inferred.as_ref() { validate_remote_matches_repo(context, &info)?; } @@ -125,7 +138,9 @@ async fn create(args: PrCreateArgs, mode: CreateMode) -> Result<()> { head_buf = inferred .as_ref() .and_then(|context| context.current_branch.clone()) - .ok_or_else(|| anyhow!("could not infer current branch; pass --head"))?; + .ok_or_else(|| { + anyhow!("could not infer current branch; pass --head") + })?; head_buf.as_str() } else { return Err(anyhow!( @@ -146,10 +161,11 @@ async fn create(args: PrCreateArgs, mode: CreateMode) -> Result<()> { .ok() .and_then(|repo| repo.workdir().map(Path::to_path_buf)); let body_buf = resolve_body(&args, mode, repo_root.as_deref())?; - let source_repo_ref = match (info.repo_did.as_deref(), target.repo_did.as_str()) { - (Some(source), target) if source != target => Some(source), - _ => None, - }; + let source_repo_ref = + match (info.repo_did.as_deref(), target.repo_did.as_str()) { + (Some(source), target) if source != target => Some(source), + _ => None, + }; let rkey = crate::ops::pull::create_pull( &pds, &auth, @@ -188,8 +204,8 @@ struct PullTarget { impl PullTarget { fn pull_list_url(&self) -> Option { let path = self.web_path.as_deref()?; - let base = - std::env::var("TANGLED_WEB_BASE").unwrap_or_else(|_| "https://tangled.org".to_string()); + let base = std::env::var("TANGLED_WEB_BASE") + .unwrap_or_else(|_| "https://tangled.org".to_string()); Some(format!("{}/{}/pulls", base.trim_end_matches('/'), path)) } } @@ -203,10 +219,19 @@ async fn resolve_pull_target( mode: CreateMode, ) -> Result { if let Some(target) = requested { - return pull_target_from_spec(target, source, pds_base, default_owner, auth).await; + return pull_target_from_spec( + target, + source, + pds_base, + default_owner, + auth, + ) + .await; } - if mode == CreateMode::Convenience && source.source.is_some() && std::io::stdin().is_terminal() + if mode == CreateMode::Convenience + && source.source.is_some() + && std::io::stdin().is_terminal() { let choices = vec![ format!("this repo ({})", source.name), @@ -221,7 +246,14 @@ async fn resolve_pull_target( .default(0) .interact()?; if selected == 1 { - return pull_target_from_spec("source", source, pds_base, default_owner, auth).await; + return pull_target_from_spec( + "source", + source, + pds_base, + default_owner, + auth, + ) + .await; } } @@ -238,10 +270,9 @@ async fn pull_target_from_spec( match spec { "self" => pull_target_from_repo_record(source, pds_base, auth).await, "source" => { - let repo_did = source - .source - .clone() - .ok_or_else(|| anyhow!("current repo does not declare a fork source"))?; + let repo_did = source.source.clone().ok_or_else(|| { + anyhow!("current repo does not declare a fork source") + })?; Ok(PullTarget { display: repo_did.clone(), repo_did, @@ -257,7 +288,9 @@ async fn pull_target_from_spec( }), repo_ref => { let (owner, name) = parse_repo_ref(repo_ref, default_owner); - let info = crate::ops::repo::get_repo_info(pds_base, owner, name, auth).await?; + let info = + crate::ops::repo::get_repo_info(pds_base, owner, name, auth) + .await?; pull_target_from_repo_record(&info, pds_base, auth).await } } @@ -274,9 +307,10 @@ async fn pull_target_from_repo_record( info.name ) })?; - let owner = crate::ops::repo::resolve_did_to_handle(pds_base, &info.did, auth) - .await - .unwrap_or_else(|_| info.did.clone()); + let owner = + crate::ops::repo::resolve_did_to_handle(pds_base, &info.did, auth) + .await + .unwrap_or_else(|_| info.did.clone()); let slug = repo_slug(info.name.as_str(), info.rkey.as_str()); Ok(PullTarget { display: repo_did, @@ -295,11 +329,13 @@ async fn resolve_pull_list_url( return Some(url); } - let described = describe_repo_for_web_url(&target.repo_did, pds_base, auth).await; + let described = + describe_repo_for_web_url(&target.repo_did, pds_base, auth).await; if let Ok((owner_did, rkey, name)) = described { - let owner = crate::ops::repo::resolve_did_to_handle(pds_base, &owner_did, auth) - .await - .unwrap_or(owner_did); + let owner = + crate::ops::repo::resolve_did_to_handle(pds_base, &owner_did, auth) + .await + .unwrap_or(owner_did); let slug = repo_slug(name.as_deref().unwrap_or(""), &rkey); return PullTarget { display: target.display.clone(), @@ -317,13 +353,18 @@ async fn describe_repo_for_web_url( pds_base: &str, auth: &crate::ops::auth::PdsAuth, ) -> Result<(String, String, Option)> { - let resolver_base = - std::env::var("TANGLED_API_BASE").unwrap_or_else(|_| crate::ops::DEFAULT_KNOT.to_string()); - let described = crate::ops::repo::describe_repo(&resolver_base, repo_did, None).await?; - let repo = - crate::ops::repo::get_repo_by_rkey(pds_base, &described.owner_did, &described.rkey, auth) - .await - .ok(); + let resolver_base = std::env::var("TANGLED_API_BASE") + .unwrap_or_else(|_| crate::ops::DEFAULT_KNOT.to_string()); + let described = + crate::ops::repo::describe_repo(&resolver_base, repo_did, None).await?; + let repo = crate::ops::repo::get_repo_by_rkey( + pds_base, + &described.owner_did, + &described.rkey, + auth, + ) + .await + .ok(); Ok(( described.owner_did, described.rkey, @@ -380,7 +421,8 @@ fn resolve_body( }; let mut initial = if let Some(template) = args.template.as_deref() { Some(read_requested_template(&templates, template)?) - } else if mode == CreateMode::Convenience && std::io::stdin().is_terminal() { + } else if mode == CreateMode::Convenience && std::io::stdin().is_terminal() + { select_template_body(&templates)? } else if templates.len() == 1 { Some(fs::read_to_string(&templates[0].path)?) @@ -420,7 +462,8 @@ fn validate_remote_matches_repo( ) -> Result<()> { let host = context.host.as_str(); let repo_knot = info.knot.as_str(); - let compatible = host == "tangled.org" && repo_knot == "knot1.tangled.sh" || host == repo_knot; + let compatible = host == "tangled.org" && repo_knot == "knot1.tangled.sh" + || host == repo_knot; if compatible { Ok(()) } else { @@ -434,7 +477,10 @@ fn validate_remote_matches_repo( } } -fn ensure_source_branch_pushed(context: &crate::util::GitRepoContext, branch: &str) -> Result<()> { +fn ensure_source_branch_pushed( + context: &crate::util::GitRepoContext, + branch: &str, +) -> Result<()> { let status = Command::new("git") .arg("ls-remote") .arg("--exit-code") @@ -555,7 +601,9 @@ fn discover_pr_templates(repo_root: &Path) -> Result> { for child in fs::read_dir(path)? { let child = child?; let child_path = child.path(); - if child_path.is_file() && is_supported_template_file(&child_path) { + if child_path.is_file() + && is_supported_template_file(&child_path) + { templates.push(template_from_path(repo_root, child_path)?); } } @@ -581,7 +629,9 @@ fn is_pr_template_dir(path: &Path) -> bool { fn is_supported_template_file(path: &Path) -> bool { path.extension() .and_then(|ext| ext.to_str()) - .is_some_and(|ext| ext.eq_ignore_ascii_case("md") || ext.eq_ignore_ascii_case("txt")) + .is_some_and(|ext| { + ext.eq_ignore_ascii_case("md") || ext.eq_ignore_ascii_case("txt") + }) } fn template_from_path(repo_root: &Path, path: PathBuf) -> Result { @@ -601,7 +651,10 @@ fn template_from_path(repo_root: &Path, path: PathBuf) -> Result { }) } -fn read_requested_template(templates: &[PrTemplate], requested: &str) -> Result { +fn read_requested_template( + templates: &[PrTemplate], + requested: &str, +) -> Result { let template = templates .iter() .find(|template| { @@ -613,7 +666,9 @@ fn read_requested_template(templates: &[PrTemplate], requested: &str) -> Result< .and_then(|name| name.to_str()) .is_some_and(|name| name.eq_ignore_ascii_case(requested)) }) - .ok_or_else(|| anyhow!("pull request template not found: {}", requested))?; + .ok_or_else(|| { + anyhow!("pull request template not found: {}", requested) + })?; Ok(fs::read_to_string(&template.path)?) } @@ -668,14 +723,16 @@ async fn show(args: PrShowArgs) -> Result<()> { .clone() .or_else(|| std::env::var("TANGLED_PDS_BASE").ok()) .unwrap_or_else(|| "https://bsky.social".into()); - let pr = crate::ops::pull::get_pull_record(&pds, &did, &rkey, &auth).await?; + let pr = + crate::ops::pull::get_pull_record(&pds, &did, &rkey, &auth).await?; println!("TITLE: {}", pr.title); if !pr.body.is_empty() { println!("BODY:\n{}", pr.body); } println!("TARGET: {} @ {}", pr.target_repo(), pr.target_branch()); if args.diff { - let patch = crate::ops::pull::pull_patch(&pds, &did, &pr, &auth).await?; + let patch = + crate::ops::pull::pull_patch(&pds, &did, &pr, &auth).await?; println!("PATCH:\n{}", patch); } Ok(()) @@ -701,9 +758,12 @@ async fn review(args: PrReviewArgs) -> Result<()> { "" }; if note.is_empty() { - return Err(anyhow!("provide --comment or --approve/--request-changes")); + return Err(anyhow!( + "provide --comment or --approve/--request-changes" + )); } - crate::ops::pull::comment_pull(&pds, &auth, &session.did, &pr_at, note).await?; + crate::ops::pull::comment_pull(&pds, &auth, &session.did, &pr_at, note) + .await?; println!("Review comment posted"); Ok(()) } @@ -719,7 +779,8 @@ async fn merge(args: PrMergeArgs) -> Result<()> { .unwrap_or_else(|| "https://bsky.social".into()); // Get the PR to find the target repo - let pull = crate::ops::pull::get_pull_record(&pds, &did, &rkey, &auth).await?; + let pull = + crate::ops::pull::get_pull_record(&pds, &did, &rkey, &auth).await?; let target = resolve_merge_target(&pds, &pull, &auth).await?; crate::ops::pull::merge_pull( @@ -760,21 +821,26 @@ async fn resolve_merge_target( } else if target_repo.starts_with("did:") { let resolver_base = std::env::var("TANGLED_API_BASE") .unwrap_or_else(|_| crate::ops::DEFAULT_KNOT.to_string()); - let described = crate::ops::repo::describe_repo(&resolver_base, target_repo, None).await?; + let described = + crate::ops::repo::describe_repo(&resolver_base, target_repo, None) + .await?; (described.owner_did, described.rkey) } else { return Err(anyhow!("Invalid target repo reference: {}", target_repo)); }; - let repo = crate::ops::repo::get_repo_by_rkey(pds_base, &owner_did, &repo_rkey, auth).await?; + let repo = crate::ops::repo::get_repo_by_rkey( + pds_base, &owner_did, &repo_rkey, auth, + ) + .await?; let name = if repo.name.is_empty() { repo_rkey.clone() } else { repo.name }; - let knot = repo - .knot - .ok_or_else(|| anyhow!("target repo record {} has no knot", repo_rkey))?; + let knot = repo.knot.ok_or_else(|| { + anyhow!("target repo record {} has no knot", repo_rkey) + })?; Ok(MergeTarget { owner_did, name, @@ -794,7 +860,10 @@ fn parse_repo_at_uri(uri: &str) -> Result<(String, String)> { Ok((parts[0].to_string(), parts[2].to_string())) } -fn parse_repo_ref<'a>(spec: &'a str, default_owner: &'a str) -> (&'a str, &'a str) { +fn parse_repo_ref<'a>( + spec: &'a str, + default_owner: &'a str, +) -> (&'a str, &'a str) { if let Some((owner, name)) = spec.split_once('/') { if !owner.is_empty() { (owner, name) @@ -806,7 +875,10 @@ fn parse_repo_ref<'a>(spec: &'a str, default_owner: &'a str) -> (&'a str, &'a st } } -fn parse_record_id<'a>(id: &'a str, default_did: &'a str) -> Result<(String, String)> { +fn parse_record_id<'a>( + id: &'a str, + default_did: &'a str, +) -> Result<(String, String)> { if let Some(rest) = id.strip_prefix("at://") { let parts: Vec<&str> = rest.split('/').collect(); if parts.len() >= 4 { @@ -835,7 +907,8 @@ mod tests { ) .unwrap(); fs::create_dir(root.join("docs")).unwrap(); - fs::create_dir(root.join("docs").join("Pull_Request_Template")).unwrap(); + fs::create_dir(root.join("docs").join("Pull_Request_Template")) + .unwrap(); fs::write( root.join("docs") .join("Pull_Request_Template") @@ -843,7 +916,8 @@ mod tests { "feature", ) .unwrap(); - fs::write(root.join("docs").join("ISSUE_TEMPLATE.md"), "ignore").unwrap(); + fs::write(root.join("docs").join("ISSUE_TEMPLATE.md"), "ignore") + .unwrap(); let templates = discover_pr_templates(root).unwrap(); let paths = templates @@ -866,7 +940,8 @@ mod tests { let tmp = tempfile::tempdir().unwrap(); let root = tmp.path(); fs::create_dir(root.join(".github")).unwrap(); - fs::create_dir(root.join(".github").join("PULL_REQUEST_TEMPLATE")).unwrap(); + fs::create_dir(root.join(".github").join("PULL_REQUEST_TEMPLATE")) + .unwrap(); fs::write( root.join(".github") .join("PULL_REQUEST_TEMPLATE") @@ -886,7 +961,11 @@ mod tests { "bug template" ); assert_eq!( - read_requested_template(&templates, ".github/PULL_REQUEST_TEMPLATE/bug.md").unwrap(), + read_requested_template( + &templates, + ".github/PULL_REQUEST_TEMPLATE/bug.md" + ) + .unwrap(), "bug template" ); } @@ -921,11 +1000,14 @@ mod tests { #[test] fn parses_legacy_repo_at_uri_for_merge_target() { let (owner, rkey) = - parse_repo_at_uri("at://did:plc:owner/sh.tangled.repo/tangled-cli").unwrap(); + parse_repo_at_uri("at://did:plc:owner/sh.tangled.repo/tangled-cli") + .unwrap(); assert_eq!(owner, "did:plc:owner"); assert_eq!(rkey, "tangled-cli"); - assert!(parse_repo_at_uri("at://did:plc:owner/sh.tangled.issue/1").is_err()); + assert!( + parse_repo_at_uri("at://did:plc:owner/sh.tangled.issue/1").is_err() + ); } #[test] @@ -964,7 +1046,8 @@ mod tests { let patch = format_patch_series(&base, "HEAD", root).unwrap(); - let from_count = patch.lines().filter(|line| is_mbox_separator(line)).count(); + let from_count = + patch.lines().filter(|line| is_mbox_separator(line)).count(); assert_eq!( from_count, 2, "expected one mbox section per non-base commit:\n{}", @@ -992,7 +1075,8 @@ mod tests { for line in patch.lines() { if is_mbox_separator(line) { if seen_section { - blank_lines_before_following_sections.push(trailing_blank_lines); + blank_lines_before_following_sections + .push(trailing_blank_lines); } seen_section = true; trailing_blank_lines = 0; @@ -1048,7 +1132,8 @@ mod tests { .strip_prefix("From ") .and_then(|rest| rest.split_once(' ')) .is_some_and(|(sha, _)| { - sha.len() == 40 && sha.chars().all(|ch| ch.is_ascii_hexdigit()) + sha.len() == 40 + && sha.chars().all(|ch| ch.is_ascii_hexdigit()) }) } } diff --git a/crates/tangled-cli/src/commands/repo.rs b/crates/tangled-cli/src/commands/repo.rs index b245516..0277dd7 100644 --- a/crates/tangled-cli/src/commands/repo.rs +++ b/crates/tangled-cli/src/commands/repo.rs @@ -1,11 +1,13 @@ +use std::path::PathBuf; + use anyhow::{anyhow, Result}; -use git2::{build::RepoBuilder, Cred, FetchOptions, RemoteCallbacks}; +use git2::build::RepoBuilder; +use git2::{Cred, FetchOptions, RemoteCallbacks}; use serde_json; -use std::path::PathBuf; use crate::cli::{ - Cli, OutputFormat, RepoCloneArgs, RepoCommand, RepoCreateArgs, RepoDeleteArgs, RepoInfoArgs, - RepoListArgs, RepoRefArgs, + Cli, OutputFormat, RepoCloneArgs, RepoCommand, RepoCreateArgs, + RepoDeleteArgs, RepoInfoArgs, RepoListArgs, RepoRefArgs, }; pub async fn run(cli: &Cli, cmd: RepoCommand) -> Result<()> { @@ -31,7 +33,8 @@ async fn list(cli: &Cli, args: RepoListArgs) -> Result<()> { .or_else(|| std::env::var("TANGLED_PDS_BASE").ok()) .unwrap_or_else(|| "https://bsky.social".into()); // Default to the logged-in user handle if --user is not provided - let effective_user = args.user.as_deref().unwrap_or(session.handle.as_str()); + let effective_user = + args.user.as_deref().unwrap_or(session.handle.as_str()); let repos = crate::ops::repo::list_repos( &pds, Some(effective_user), @@ -49,7 +52,12 @@ async fn list(cli: &Cli, args: RepoListArgs) -> Result<()> { OutputFormat::Table => { println!("NAME\tKNOT\tPRIVATE"); for r in repos { - println!("{}\t{}\t{}", r.name, r.knot.unwrap_or_default(), r.private); + println!( + "{}\t{}\t{}", + r.name, + r.knot.unwrap_or_default(), + r.private + ); } } } @@ -102,7 +110,8 @@ async fn clone(args: RepoCloneArgs) -> Result<()> { .clone() .or_else(|| std::env::var("TANGLED_PDS_BASE").ok()) .unwrap_or_else(|| "https://bsky.social".into()); - let info = crate::ops::repo::get_repo_info(&pds, owner, &name, &auth).await?; + let info = + crate::ops::repo::get_repo_info(&pds, owner, &name, &auth).await?; let remote = if args.https { let owner_path = if owner.starts_with('@') { @@ -163,7 +172,8 @@ async fn info(args: RepoInfoArgs) -> Result<()> { .clone() .or_else(|| std::env::var("TANGLED_PDS_BASE").ok()) .unwrap_or_else(|| "https://bsky.social".into()); - let info = crate::ops::repo::get_repo_info(&pds, owner, &name, &auth).await?; + let info = + crate::ops::repo::get_repo_info(&pds, owner, &name, &auth).await?; println!("NAME: {}", info.name); println!("OWNER DID: {}", info.did); @@ -180,8 +190,10 @@ async fn info(args: RepoInfoArgs) -> Result<()> { } if args.stats { - if let Ok(def) = - crate::ops::repo::get_default_branch(&info.knot, &info.did, &info.name).await + if let Ok(def) = crate::ops::repo::get_default_branch( + &info.knot, &info.did, &info.name, + ) + .await { println!( "DEFAULT BRANCH: {} ({})", @@ -194,7 +206,9 @@ async fn info(args: RepoInfoArgs) -> Result<()> { } } } - if let Ok(langs) = crate::ops::repo::get_languages(&info.knot, &info.did, &info.name).await + if let Ok(langs) = + crate::ops::repo::get_languages(&info.knot, &info.did, &info.name) + .await { if !langs.languages.is_empty() { println!("LANGUAGES:"); @@ -220,8 +234,16 @@ async fn delete(args: RepoDeleteArgs) -> Result<()> { .clone() .or_else(|| std::env::var("TANGLED_PDS_BASE").ok()) .unwrap_or_else(|| "https://bsky.social".into()); - let record = crate::ops::repo::get_repo_info(&pds, owner, &name, &auth).await?; - crate::ops::repo::delete_repo(&record.knot, &record.did, &name, &pds, &auth).await?; + let record = + crate::ops::repo::get_repo_info(&pds, owner, &name, &auth).await?; + crate::ops::repo::delete_repo( + &record.knot, + &record.did, + &name, + &pds, + &auth, + ) + .await?; println!("Deleted repo '{}'", name); Ok(()) } @@ -235,7 +257,8 @@ async fn star(args: RepoRefArgs) -> Result<()> { .clone() .or_else(|| std::env::var("TANGLED_PDS_BASE").ok()) .unwrap_or_else(|| "https://bsky.social".into()); - let info = crate::ops::repo::get_repo_info(&pds, owner, &name, &auth).await?; + let info = + crate::ops::repo::get_repo_info(&pds, owner, &name, &auth).await?; let subject = format!("at://{}/sh.tangled.repo/{}", info.did, info.rkey); crate::ops::repo::star_repo(&pds, &auth, &subject, &session.did).await?; println!("Starred {}/{}", owner, name); @@ -251,14 +274,18 @@ async fn unstar(args: RepoRefArgs) -> Result<()> { .clone() .or_else(|| std::env::var("TANGLED_PDS_BASE").ok()) .unwrap_or_else(|| "https://bsky.social".into()); - let info = crate::ops::repo::get_repo_info(&pds, owner, &name, &auth).await?; + let info = + crate::ops::repo::get_repo_info(&pds, owner, &name, &auth).await?; let subject = format!("at://{}/sh.tangled.repo/{}", info.did, info.rkey); crate::ops::repo::unstar_repo(&pds, &auth, &subject, &session.did).await?; println!("Unstarred {}/{}", owner, name); Ok(()) } -fn parse_repo_ref<'a>(spec: &'a str, default_owner: &'a str) -> (&'a str, String) { +fn parse_repo_ref<'a>( + spec: &'a str, + default_owner: &'a str, +) -> (&'a str, String) { if let Some((owner, name)) = spec.split_once('/') { (owner, name.to_string()) } else { diff --git a/crates/tangled-cli/src/commands/spindle.rs b/crates/tangled-cli/src/commands/spindle.rs index 8299baf..7445728 100644 --- a/crates/tangled-cli/src/commands/spindle.rs +++ b/crates/tangled-cli/src/commands/spindle.rs @@ -1,10 +1,13 @@ -use crate::cli::{ - Cli, SpindleCommand, SpindleConfigArgs, SpindleListArgs, SpindleLogsArgs, SpindleRunArgs, - SpindleSecretAddArgs, SpindleSecretCommand, SpindleSecretListArgs, SpindleSecretRemoveArgs, -}; use anyhow::{anyhow, Result}; use futures_util::StreamExt; -use tokio_tungstenite::{connect_async, tungstenite::Message}; +use tokio_tungstenite::connect_async; +use tokio_tungstenite::tungstenite::Message; + +use crate::cli::{ + Cli, SpindleCommand, SpindleConfigArgs, SpindleListArgs, SpindleLogsArgs, + SpindleRunArgs, SpindleSecretAddArgs, SpindleSecretCommand, + SpindleSecretListArgs, SpindleSecretRemoveArgs, +}; pub async fn run(_cli: &Cli, cmd: SpindleCommand) -> Result<()> { match cmd { @@ -29,9 +32,11 @@ async fn list(args: SpindleListArgs) -> Result<()> { args.repo.as_deref().unwrap_or(&session.handle), &session.handle, ); - let info = crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; + let info = + crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; - let pipelines = crate::ops::repo::list_pipelines(&pds, &info.did, &auth).await?; + let pipelines = + crate::ops::repo::list_pipelines(&pds, &info.did, &auth).await?; if pipelines.is_empty() { println!("No pipelines found for {}/{}", owner, name); @@ -78,7 +83,8 @@ async fn config(args: SpindleConfigArgs) -> Result<()> { args.repo.as_deref().unwrap_or(&session.handle), &session.handle, ); - let info = crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; + let info = + crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; let new_spindle = if args.disable { None @@ -91,7 +97,14 @@ async fn config(args: SpindleConfigArgs) -> Result<()> { return Err(anyhow!("Invalid flags combination")); }; - crate::ops::repo::update_repo_spindle(&pds, &info.did, &info.rkey, new_spindle, &auth).await?; + crate::ops::repo::update_repo_spindle( + &pds, + &info.did, + &info.rkey, + new_spindle, + &auth, + ) + .await?; if args.disable { println!("Disabled spindle for {}/{}", owner, name); @@ -133,8 +146,13 @@ async fn logs(args: SpindleLogsArgs) -> Result<()> { .unwrap_or_else(|| "https://bsky.social".into()); // Get repo info from current directory context or default to user's handle let auth = crate::ops::auth::PdsAuth::from_session(&session)?; - let info = - crate::ops::repo::get_repo_info(&pds, &session.handle, &session.handle, &auth).await?; + let info = crate::ops::repo::get_repo_info( + &pds, + &session.handle, + &session.handle, + &auth, + ) + .await?; (info.knot, info.rkey, parts[0].to_string()) } else { return Err(anyhow!( @@ -145,7 +163,8 @@ async fn logs(args: SpindleLogsArgs) -> Result<()> { // Build WebSocket URL - spindle base is typically https://spindle.tangled.sh let spindle_base = std::env::var("TANGLED_SPINDLE_BASE") .unwrap_or_else(|_| "wss://spindle.tangled.sh".to_string()); - let ws_url = format!("{}/spindle/logs/{}/{}/{}", spindle_base, knot, rkey, name); + let ws_url = + format!("{}/spindle/logs/{}/{}/{}", spindle_base, knot, rkey, name); println!( "Connecting to logs stream for {}:{}:{}...", @@ -202,7 +221,8 @@ async fn secret_list(args: SpindleSecretListArgs) -> Result<()> { .or_else(|| std::env::var("TANGLED_PDS_BASE").ok()) .unwrap_or_else(|| "https://bsky.social".into()); let (owner, name) = parse_repo_ref(&args.repo, &session.handle); - let info = crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; + let info = + crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; let repo_at = format!("at://{}/sh.tangled.repo/{}", info.did, info.rkey); // Get spindle base from repo config or use default @@ -211,8 +231,13 @@ async fn secret_list(args: SpindleSecretListArgs) -> Result<()> { .clone() .or_else(|| std::env::var("TANGLED_SPINDLE_BASE").ok()) .unwrap_or_else(|| "https://spindle.tangled.sh".to_string()); - let secrets = - crate::ops::secrets::list_repo_secrets(&spindle_base, &pds, &auth, &repo_at).await?; + let secrets = crate::ops::secrets::list_repo_secrets( + &spindle_base, + &pds, + &auth, + &repo_at, + ) + .await?; if secrets.is_empty() { println!("No secrets configured for {}", args.repo); } else { @@ -233,7 +258,8 @@ async fn secret_add(args: SpindleSecretAddArgs) -> Result<()> { .or_else(|| std::env::var("TANGLED_PDS_BASE").ok()) .unwrap_or_else(|| "https://bsky.social".into()); let (owner, name) = parse_repo_ref(&args.repo, &session.handle); - let info = crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; + let info = + crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; let repo_at = format!("at://{}/sh.tangled.repo/{}", info.did, info.rkey); // Get spindle base from repo config or use default @@ -260,15 +286,23 @@ async fn secret_add(args: SpindleSecretAddArgs) -> Result<()> { } else { path.to_string() }; - std::fs::read_to_string(&expanded_path) - .map_err(|e| anyhow!("Failed to read file '{}': {}", expanded_path, e))? + std::fs::read_to_string(&expanded_path).map_err(|e| { + anyhow!("Failed to read file '{}': {}", expanded_path, e) + })? } else { // Use value as-is args.value }; - crate::ops::secrets::add_repo_secret(&spindle_base, &pds, &auth, &repo_at, &args.key, &value) - .await?; + crate::ops::secrets::add_repo_secret( + &spindle_base, + &pds, + &auth, + &repo_at, + &args.key, + &value, + ) + .await?; println!("Added secret '{}' to {}", args.key, args.repo); Ok(()) } @@ -282,7 +316,8 @@ async fn secret_remove(args: SpindleSecretRemoveArgs) -> Result<()> { .or_else(|| std::env::var("TANGLED_PDS_BASE").ok()) .unwrap_or_else(|| "https://bsky.social".into()); let (owner, name) = parse_repo_ref(&args.repo, &session.handle); - let info = crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; + let info = + crate::ops::repo::get_repo_info(&pds, owner, name, &auth).await?; let repo_at = format!("at://{}/sh.tangled.repo/{}", info.did, info.rkey); // Get spindle base from repo config or use default @@ -291,13 +326,22 @@ async fn secret_remove(args: SpindleSecretRemoveArgs) -> Result<()> { .clone() .or_else(|| std::env::var("TANGLED_SPINDLE_BASE").ok()) .unwrap_or_else(|| "https://spindle.tangled.sh".to_string()); - crate::ops::secrets::remove_repo_secret(&spindle_base, &pds, &auth, &repo_at, &args.key) - .await?; + crate::ops::secrets::remove_repo_secret( + &spindle_base, + &pds, + &auth, + &repo_at, + &args.key, + ) + .await?; println!("Removed secret '{}' from {}", args.key, args.repo); Ok(()) } -fn parse_repo_ref<'a>(spec: &'a str, default_owner: &'a str) -> (&'a str, &'a str) { +fn parse_repo_ref<'a>( + spec: &'a str, + default_owner: &'a str, +) -> (&'a str, &'a str) { if let Some((owner, name)) = spec.split_once('/') { (owner, name) } else { diff --git a/crates/tangled-cli/src/ops/auth.rs b/crates/tangled-cli/src/ops/auth.rs index 2152930..750e4b2 100644 --- a/crates/tangled-cli/src/ops/auth.rs +++ b/crates/tangled-cli/src/ops/auth.rs @@ -41,7 +41,10 @@ impl PdsAuth { } } - pub async fn send(&self, rb: reqwest::RequestBuilder) -> Result { + pub async fn send( + &self, + rb: reqwest::RequestBuilder, + ) -> Result { Ok(xrpc::parse(self.response(rb).await?).await?) } @@ -49,11 +52,17 @@ impl PdsAuth { Ok(xrpc::parse_unit(self.response(rb).await?).await?) } - pub async fn send_bytes(&self, rb: reqwest::RequestBuilder) -> Result> { + pub async fn send_bytes( + &self, + rb: reqwest::RequestBuilder, + ) -> Result> { Ok(xrpc::parse_bytes(self.response(rb).await?).await?) } - async fn response(&self, rb: reqwest::RequestBuilder) -> Result { + async fn response( + &self, + rb: reqwest::RequestBuilder, + ) -> Result { match self { PdsAuth::None => Ok(rb.send().await.map_err(XrpcError::from)?), PdsAuth::Bearer(token) => Ok(rb @@ -82,8 +91,8 @@ impl DpopKey { let bytes = base64::engine::general_purpose::URL_SAFE_NO_PAD .decode(encoded) .map_err(|e| anyhow!("invalid DPoP key encoding: {e}"))?; - let signing = - SigningKey::from_slice(&bytes).map_err(|e| anyhow!("invalid DPoP key: {e}"))?; + let signing = SigningKey::from_slice(&bytes) + .map_err(|e| anyhow!("invalid DPoP key: {e}"))?; Ok(Self { signing }) } @@ -131,7 +140,8 @@ impl DpopKey { payload["nonce"] = serde_json::json!(nonce); } if let Some(token) = access_token { - payload["ath"] = serde_json::json!(b64url(&Sha256::digest(token.as_bytes()))); + payload["ath"] = + serde_json::json!(b64url(&Sha256::digest(token.as_bytes()))); } let signing_input = format!( @@ -160,12 +170,15 @@ impl DpopClient { } } - async fn response(&self, rb: reqwest::RequestBuilder) -> Result { + async fn response( + &self, + rb: reqwest::RequestBuilder, + ) -> Result { let mut retried = false; loop { - let attempt = rb - .try_clone() - .ok_or_else(|| anyhow!("request body is not cloneable for DPoP retry"))?; + let attempt = rb.try_clone().ok_or_else(|| { + anyhow!("request body is not cloneable for DPoP retry") + })?; let (client, request) = attempt.build_split(); let mut request = request.map_err(XrpcError::from)?; @@ -183,7 +196,8 @@ impl DpopClient { ); headers.insert("DPoP", proof.parse()?); - let response = client.execute(request).await.map_err(XrpcError::from)?; + let response = + client.execute(request).await.map_err(XrpcError::from)?; let new_nonce = response .headers() @@ -236,8 +250,10 @@ mod tests { .create_async() .await; - let client = DpopClient::new("token123".to_string(), DpopKey::generate()); - let rb = reqwest::Client::new().get(format!("{}/xrpc/test.method", server.url())); + let client = + DpopClient::new("token123".to_string(), DpopKey::generate()); + let rb = reqwest::Client::new() + .get(format!("{}/xrpc/test.method", server.url())); // The server keeps answering 401, so after one nonce retry the call // fails; the mock's expect(2) proves exactly one retry happened. diff --git a/crates/tangled-cli/src/ops/issue.rs b/crates/tangled-cli/src/ops/issue.rs index 98ffd89..7c97c45 100644 --- a/crates/tangled-cli/src/ops/issue.rs +++ b/crates/tangled-cli/src/ops/issue.rs @@ -52,7 +52,8 @@ pub async fn list_issues( repo_at_uri: Option<&str>, auth: &PdsAuth, ) -> Result> { - let records = list_collection(pds_base, author_did, ISSUE_COLLECTION, auth).await?; + let records = + list_collection(pds_base, author_did, ISSUE_COLLECTION, auth).await?; let mut out = vec![]; for it in records { let issue: Issue = serde_json::from_value(it.value)?; @@ -117,7 +118,11 @@ pub async fn create_issue( ) .await .map_err(|legacy_err| { - anyhow!("{}; legacy repo reference also failed: {}", err, legacy_err) + anyhow!( + "{}; legacy repo reference also failed: {}", + err, + legacy_err + ) })?, }; uri_rkey(&res.uri).ok_or_else(|| anyhow!("missing rkey in issue uri")) @@ -143,7 +148,8 @@ pub async fn comment_issue( record, ) .await?; - uri_rkey(&res.uri).ok_or_else(|| anyhow!("missing rkey in issue comment uri")) + uri_rkey(&res.uri) + .ok_or_else(|| anyhow!("missing rkey in issue comment uri")) } pub async fn get_issue_record( @@ -212,8 +218,13 @@ pub async fn list_issue_states( author_did: &str, auth: &PdsAuth, ) -> Result> { - let records = - list_collection(pds_base, author_did, "sh.tangled.repo.issue.state", auth).await?; + let records = list_collection( + pds_base, + author_did, + "sh.tangled.repo.issue.state", + auth, + ) + .await?; let mut out = vec![]; for it in records { out.push(serde_json::from_value(it.value)?); @@ -223,10 +234,11 @@ pub async fn list_issue_states( #[cfg(test)] mod tests { - use super::*; use mockito::{Matcher, Server}; use serde_json::json; + use super::*; + #[tokio::test] async fn create_issue_writes_repo_did_shape() { let mut pds = Server::new_async().await; @@ -268,7 +280,8 @@ mod tests { } #[tokio::test] - async fn create_issue_falls_back_to_legacy_repo_at_uri_when_current_shape_is_rejected() { + async fn create_issue_falls_back_to_legacy_repo_at_uri_when_current_shape_is_rejected( + ) { let mut pds = Server::new_async().await; let _current_shape_rejected = pds .mock("POST", "/xrpc/com.atproto.repo.createRecord") diff --git a/crates/tangled-cli/src/ops/oauth.rs b/crates/tangled-cli/src/ops/oauth.rs index 106900c..b756baa 100644 --- a/crates/tangled-cli/src/ops/oauth.rs +++ b/crates/tangled-cli/src/ops/oauth.rs @@ -68,7 +68,8 @@ async fn resolve_identity(input: &str) -> Result<(String, String)> { } else { bail!("unsupported DID method: {did}"); }; - let doc: serde_json::Value = http().get(&doc_url).send().await?.json().await?; + let doc: serde_json::Value = + http().get(&doc_url).send().await?.json().await?; let pds = doc["service"] .as_array() .and_then(|services| { @@ -78,7 +79,9 @@ async fn resolve_identity(input: &str) -> Result<(String, String)> { }) }) .and_then(|s| s["serviceEndpoint"].as_str()) - .ok_or_else(|| anyhow!("DID document for {did} has no PDS service endpoint"))? + .ok_or_else(|| { + anyhow!("DID document for {did} has no PDS service endpoint") + })? .to_string(); Ok((did, pds)) } @@ -219,7 +222,8 @@ pub async fn login(handle_or_did: &str) -> Result { let _ = open::that(&authorize_url); // Wait for the redirect. - let (code, returned_state, returned_iss) = wait_for_callback(listener).await?; + let (code, returned_state, returned_iss) = + wait_for_callback(listener).await?; if returned_state != state { bail!("OAuth state mismatch; aborting"); } diff --git a/crates/tangled-cli/src/ops/pull.rs b/crates/tangled-cli/src/ops/pull.rs index 9ce7547..c7fbdb2 100644 --- a/crates/tangled-cli/src/ops/pull.rs +++ b/crates/tangled-cli/src/ops/pull.rs @@ -3,9 +3,10 @@ use std::io::{Read, Write}; use anyhow::{anyhow, Result}; -use flate2::{read::GzDecoder, write::GzEncoder, Compression}; -use tangled_api::lexicon::com::atproto::repo as atproto_repo; -use tangled_api::lexicon::com::atproto::sync; +use flate2::read::GzDecoder; +use flate2::write::GzEncoder; +use flate2::Compression; +use tangled_api::lexicon::com::atproto::{repo as atproto_repo, sync}; use tangled_api::lexicon::sh::tangled::repo as tangled_repo; use tangled_api::types::BlobRef; @@ -83,12 +84,21 @@ pub async fn get_pull_record( Ok(serde_json::from_value(out.value)?) } -async fn upload_gzip_blob(pds_base: &str, auth: &PdsAuth, bytes: Vec) -> Result { +async fn upload_gzip_blob( + pds_base: &str, + auth: &PdsAuth, + bytes: Vec, +) -> Result { #[derive(serde::Deserialize)] struct Res { blob: BlobRef, } - let rb = atproto_repo::upload_blob(http(), pds_base, bytes.into(), "application/gzip"); + let rb = atproto_repo::upload_blob( + http(), + pds_base, + bytes.into(), + "application/gzip", + ); let res: Res = auth.send(rb).await?; Ok(res.blob) } @@ -213,7 +223,8 @@ pub async fn comment_pull( }; let rb = atproto_repo::create_record(http(), pds_base, &input); let out: atproto_repo::create_record::Output = auth.send(rb).await?; - uri_rkey(&out.uri).ok_or_else(|| anyhow!("missing rkey in pull comment uri")) + uri_rkey(&out.uri) + .ok_or_else(|| anyhow!("missing rkey in pull comment uri")) } pub async fn merge_pull( @@ -228,7 +239,13 @@ pub async fn merge_pull( // Fetch the pull request to get patch and target branch let pull = get_pull_record(pds_base, pull_did, pull_rkey, auth).await?; - let token = service_auth::mint(pds_base, auth, knot_base, tangled_repo::merge::NSID).await?; + let token = service_auth::mint( + pds_base, + auth, + knot_base, + tangled_repo::merge::NSID, + ) + .await?; let patch = pull_patch(pds_base, pull_did, &pull, auth).await?; let input = tangled_repo::merge::Input { @@ -252,10 +269,11 @@ pub async fn merge_pull( #[cfg(test)] mod tests { - use super::*; use mockito::{Matcher, Server}; use serde_json::json; + use super::*; + #[tokio::test] async fn create_pull_uploads_gzipped_patch_blob_for_repo_did_targets() { let mut pds = Server::new_async().await; diff --git a/crates/tangled-cli/src/ops/repo.rs b/crates/tangled-cli/src/ops/repo.rs index 410212f..d8e7133 100644 --- a/crates/tangled-cli/src/ops/repo.rs +++ b/crates/tangled-cli/src/ops/repo.rs @@ -1,19 +1,23 @@ //! Repository operations: PDS record CRUD plus knot orchestration. use anyhow::{anyhow, Result}; -use tangled_api::lexicon::com::atproto::identity; -use tangled_api::lexicon::com::atproto::repo as atproto_repo; +use tangled_api::lexicon::com::atproto::{identity, repo as atproto_repo}; use tangled_api::lexicon::sh::tangled::repo as tangled_repo; use tangled_api::xrpc; use super::auth::PdsAuth; use super::types::{ - CreateRepoOptions, DefaultBranch, Language, Languages, Pipeline, PipelineRecord, RepoDescribe, - RepoRecord, Repository, StarRecord, REPO_COLLECTION, + CreateRepoOptions, DefaultBranch, Language, Languages, Pipeline, + PipelineRecord, RepoDescribe, RepoRecord, Repository, StarRecord, + REPO_COLLECTION, }; use super::{http, service_auth, uri_did, uri_rkey}; -pub async fn resolve_handle_to_did(pds_base: &str, user: &str, auth: &PdsAuth) -> Result { +pub async fn resolve_handle_to_did( + pds_base: &str, + user: &str, + auth: &PdsAuth, +) -> Result { if user.starts_with("did:") { return Ok(user.to_string()); } @@ -50,10 +54,13 @@ pub async fn list_repos( starred: bool, auth: &PdsAuth, ) -> Result> { - let user = user.ok_or_else(|| anyhow!("missing user for list_repos; provide handle or DID"))?; + let user = user.ok_or_else(|| { + anyhow!("missing user for list_repos; provide handle or DID") + })?; let did = resolve_handle_to_did(pds_base, user, auth).await?; - let records = list_collection_records(pds_base, &did, REPO_COLLECTION, auth).await?; + let records = + list_collection_records(pds_base, &did, REPO_COLLECTION, auth).await?; let mut repos: Vec = Vec::new(); for record in records { let mut val: Repository = serde_json::from_value(record.value)?; @@ -83,7 +90,10 @@ pub async fn list_repos( Ok(repos) } -pub async fn create_repo(knot_base: &str, opts: CreateRepoOptions<'_>) -> Result<()> { +pub async fn create_repo( + knot_base: &str, + opts: CreateRepoOptions<'_>, +) -> Result<()> { // 1) Create the sh.tangled.repo record on the user's PDS let record = tangled_repo::Record { r#type: Some(REPO_COLLECTION.to_string()), @@ -102,10 +112,12 @@ pub async fn create_repo(knot_base: &str, opts: CreateRepoOptions<'_>) -> Result swap_commit: None, }; let rb = atproto_repo::create_record(http(), opts.pds_base, &input); - let created: atproto_repo::create_record::Output = opts.auth.send(rb).await?; + let created: atproto_repo::create_record::Output = + opts.auth.send(rb).await?; // Extract rkey from at-uri: at://did/collection/rkey - let rkey = uri_rkey(&created.uri).ok_or_else(|| anyhow!("failed to parse rkey from uri"))?; + let rkey = uri_rkey(&created.uri) + .ok_or_else(|| anyhow!("failed to parse rkey from uri"))?; // 2) Obtain a service auth token for the knot (aud = did:web:) let token = service_auth::mint( @@ -124,7 +136,8 @@ pub async fn create_repo(knot_base: &str, opts: CreateRepoOptions<'_>) -> Result source: opts.source.map(str::to_string), repo_did: None, }; - let rb = tangled_repo::create(http(), knot_base, &input).bearer_auth(&token); + let rb = + tangled_repo::create(http(), knot_base, &input).bearer_auth(&token); let created_repo: tangled_repo::create::Output = xrpc::send(rb).await?; if let Some(repo_did) = created_repo.repo_did.as_deref() { update_repo_record(opts.pds_base, opts.did, &rkey, opts.auth, |obj| { @@ -191,12 +204,14 @@ pub async fn get_repo_info( auth: &PdsAuth, ) -> Result { let did = resolve_handle_to_did(pds_base, owner, auth).await?; - let records = list_collection_records(pds_base, &did, REPO_COLLECTION, auth).await?; + let records = + list_collection_records(pds_base, &did, REPO_COLLECTION, auth).await?; for item in records { let value: Repository = serde_json::from_value(item.value)?; let record_name = repo_record_name(&item.uri, &value); if record_name == name { - let rkey = uri_rkey(&item.uri).ok_or_else(|| anyhow!("missing rkey in uri"))?; + let rkey = uri_rkey(&item.uri) + .ok_or_else(|| anyhow!("missing rkey in uri"))?; return Ok(RepoRecord { did: did.clone(), name: record_name, @@ -229,7 +244,11 @@ pub async fn get_repo_by_rkey( Ok(serde_json::from_value(out.value)?) } -pub async fn resolve_did_to_handle(pds_base: &str, did: &str, auth: &PdsAuth) -> Result { +pub async fn resolve_did_to_handle( + pds_base: &str, + did: &str, + auth: &PdsAuth, +) -> Result { let params = atproto_repo::describe_repo::Params { repo: did.to_string(), }; @@ -272,13 +291,20 @@ pub async fn delete_repo( let rb = atproto_repo::delete_record(http(), pds_base, &input); auth.send_unit(rb).await?; - let token = service_auth::mint(pds_base, auth, knot_base, tangled_repo::delete::NSID).await?; + let token = service_auth::mint( + pds_base, + auth, + knot_base, + tangled_repo::delete::NSID, + ) + .await?; let input = tangled_repo::delete::Input { did: did.to_string(), name: name.to_string(), rkey: info.rkey, }; - let rb = tangled_repo::delete(http(), knot_base, &input).bearer_auth(&token); + let rb = + tangled_repo::delete(http(), knot_base, &input).bearer_auth(&token); xrpc::send_unit(rb).await?; Ok(()) } @@ -313,7 +339,11 @@ pub async fn update_repo_spindle( .await } -pub async fn get_default_branch(knot_host: &str, did: &str, name: &str) -> Result { +pub async fn get_default_branch( + knot_host: &str, + did: &str, + name: &str, +) -> Result { let params = tangled_repo::get_default_branch::Params { repo: format!("{}/{}", did, name), }; @@ -328,7 +358,11 @@ pub async fn get_default_branch(knot_host: &str, did: &str, name: &str) -> Resul }) } -pub async fn get_languages(knot_host: &str, did: &str, name: &str) -> Result { +pub async fn get_languages( + knot_host: &str, + did: &str, + name: &str, +) -> Result { let params = tangled_repo::languages::Params { repo: format!("{}/{}", did, name), r#ref: None, @@ -376,7 +410,13 @@ pub async fn unstar_repo( subject_at_uri: &str, user_did: &str, ) -> Result<()> { - let records = list_collection_records(pds_base, user_did, "sh.tangled.feed.star", auth).await?; + let records = list_collection_records( + pds_base, + user_did, + "sh.tangled.feed.star", + auth, + ) + .await?; let mut rkey = None; for item in records { let value: StarRecord = match serde_json::from_value(item.value) { @@ -408,7 +448,13 @@ pub async fn list_pipelines( repo_did: &str, auth: &PdsAuth, ) -> Result> { - let records = list_collection_records(pds_base, repo_did, "sh.tangled.pipeline", auth).await?; + let records = list_collection_records( + pds_base, + repo_did, + "sh.tangled.pipeline", + auth, + ) + .await?; let mut out = vec![]; for item in records { let pipeline: Pipeline = serde_json::from_value(item.value)?; @@ -422,10 +468,11 @@ pub async fn list_pipelines( #[cfg(test)] mod tests { - use super::*; use mockito::{Matcher, Server}; use serde_json::json; + use super::*; + #[tokio::test] async fn get_repo_info_uses_rkey_when_live_record_has_no_name() { let mut pds = Server::new_async().await; @@ -433,7 +480,10 @@ mod tests { .mock("GET", "/xrpc/com.atproto.repo.listRecords") .match_query(Matcher::AllOf(vec![ Matcher::UrlEncoded("repo".into(), "did:plc:owner".into()), - Matcher::UrlEncoded("collection".into(), REPO_COLLECTION.into()), + Matcher::UrlEncoded( + "collection".into(), + REPO_COLLECTION.into(), + ), ])) .with_status(200) .with_body( @@ -465,7 +515,8 @@ mod tests { } #[tokio::test] - async fn create_repo_sends_current_knot_shape_and_preserves_record_fields() { + async fn create_repo_sends_current_knot_shape_and_preserves_record_fields() + { let mut pds = Server::new_async().await; let mut knot = Server::new_async().await; let knot_host = knot.url().trim_start_matches("http://").to_string(); @@ -498,8 +549,14 @@ mod tests { .mock("GET", "/xrpc/com.atproto.server.getServiceAuth") .match_header("authorization", "Bearer access") .match_query(Matcher::AllOf(vec![ - Matcher::UrlEncoded("aud".into(), format!("did:web:{knot_host}")), - Matcher::UrlEncoded("lxm".into(), "sh.tangled.repo.create".into()), + Matcher::UrlEncoded( + "aud".into(), + format!("did:web:{knot_host}"), + ), + Matcher::UrlEncoded( + "lxm".into(), + "sh.tangled.repo.create".into(), + ), ])) .with_status(200) .with_body(json!({"token": "service"}).to_string()) diff --git a/crates/tangled-cli/src/ops/secrets.rs b/crates/tangled-cli/src/ops/secrets.rs index a71db17..021c9a2 100644 --- a/crates/tangled-cli/src/ops/secrets.rs +++ b/crates/tangled-cli/src/ops/secrets.rs @@ -24,7 +24,8 @@ pub async fn list_repo_secrets( let params = tangled_repo::list_secrets::Params { repo: repo_at.to_string(), }; - let rb = tangled_repo::list_secrets(http(), service_base, ¶ms).bearer_auth(&token); + let rb = tangled_repo::list_secrets(http(), service_base, ¶ms) + .bearer_auth(&token); let res: tangled_repo::list_secrets::Output = xrpc::send(rb).await?; Ok(res.secrets) } @@ -37,14 +38,20 @@ pub async fn add_repo_secret( key: &str, value: &str, ) -> Result<()> { - let token = - service_auth::mint(pds_base, auth, service_base, tangled_repo::add_secret::NSID).await?; + let token = service_auth::mint( + pds_base, + auth, + service_base, + tangled_repo::add_secret::NSID, + ) + .await?; let input = tangled_repo::add_secret::Input { repo: repo_at.to_string(), key: key.to_string(), value: value.to_string(), }; - let rb = tangled_repo::add_secret(http(), service_base, &input).bearer_auth(&token); + let rb = tangled_repo::add_secret(http(), service_base, &input) + .bearer_auth(&token); xrpc::send_unit(rb).await?; Ok(()) } @@ -67,7 +74,8 @@ pub async fn remove_repo_secret( repo: repo_at.to_string(), key: key.to_string(), }; - let rb = tangled_repo::remove_secret(http(), service_base, &input).bearer_auth(&token); + let rb = tangled_repo::remove_secret(http(), service_base, &input) + .bearer_auth(&token); xrpc::send_unit(rb).await?; Ok(()) } diff --git a/crates/tangled-cli/src/ops/service_auth.rs b/crates/tangled-cli/src/ops/service_auth.rs index 3ef8d96..0aafe56 100644 --- a/crates/tangled-cli/src/ops/service_auth.rs +++ b/crates/tangled-cli/src/ops/service_auth.rs @@ -8,7 +8,12 @@ use super::auth::PdsAuth; /// Mints a ServiceAuth token on the PDS for the service at `service_base` /// (a knot or spindle base URL); the audience is `did:web:` and the /// token is bound to the XRPC method `lxm` (knots reject unbound tokens). -pub async fn mint(pds_base: &str, auth: &PdsAuth, service_base: &str, lxm: &str) -> Result { +pub async fn mint( + pds_base: &str, + auth: &PdsAuth, + service_base: &str, + lxm: &str, +) -> Result { let trimmed = service_base.trim_end_matches('/'); let host = trimmed .strip_prefix("https://") diff --git a/crates/tangled-cli/src/ops/session.rs b/crates/tangled-cli/src/ops/session.rs index 9112b07..53727a0 100644 --- a/crates/tangled-cli/src/ops/session.rs +++ b/crates/tangled-cli/src/ops/session.rs @@ -5,7 +5,11 @@ use tangled_api::lexicon::com::atproto::server; use tangled_api::xrpc; use tangled_config::session::Session; -pub async fn login_with_password(pds_base: &str, handle: &str, password: &str) -> Result { +pub async fn login_with_password( + pds_base: &str, + handle: &str, + password: &str, +) -> Result { let input = server::create_session::Input { identifier: handle.to_string(), password: password.to_string(), @@ -22,8 +26,12 @@ pub async fn login_with_password(pds_base: &str, handle: &str, password: &str) - }) } -pub async fn refresh_session(pds_base: &str, refresh_jwt: &str) -> Result { - let rb = server::refresh_session(super::http(), pds_base).bearer_auth(refresh_jwt); +pub async fn refresh_session( + pds_base: &str, + refresh_jwt: &str, +) -> Result { + let rb = server::refresh_session(super::http(), pds_base) + .bearer_auth(refresh_jwt); let out: server::refresh_session::Output = xrpc::send(rb).await?; Ok(Session { access_jwt: out.access_jwt, diff --git a/crates/tangled-cli/src/ops/types.rs b/crates/tangled-cli/src/ops/types.rs index e9afb75..7cf9c4a 100644 --- a/crates/tangled-cli/src/ops/types.rs +++ b/crates/tangled-cli/src/ops/types.rs @@ -135,9 +135,9 @@ pub struct RepoRecord { impl RepoRecord { pub fn issue_repo_ref(&self) -> String { - self.repo_did - .clone() - .unwrap_or_else(|| format!("at://{}/{}/{}", self.did, REPO_COLLECTION, self.rkey)) + self.repo_did.clone().unwrap_or_else(|| { + format!("at://{}/{}/{}", self.did, REPO_COLLECTION, self.rkey) + }) } pub fn repo_at_uri(&self) -> String { @@ -146,7 +146,8 @@ impl RepoRecord { } /// Knot-authoritative metadata for a repo DID (`sh.tangled.repo.describeRepo`). -pub type RepoDescribe = tangled_api::lexicon::sh::tangled::repo::describe_repo::Output; +pub type RepoDescribe = + tangled_api::lexicon::sh::tangled::repo::describe_repo::Output; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct DefaultBranch { diff --git a/crates/tangled-cli/src/util.rs b/crates/tangled-cli/src/util.rs index dc07b7f..e0071b5 100644 --- a/crates/tangled-cli/src/util.rs +++ b/crates/tangled-cli/src/util.rs @@ -84,13 +84,18 @@ impl GitRepoContext { pub fn current_git_repo_context() -> Result { let repo = Repository::discover(".")?; let current_branch = current_branch(&repo); - let (remote_name, remote) = select_tangled_remote(&repo, current_branch.as_deref())?; + let (remote_name, remote) = + select_tangled_remote(&repo, current_branch.as_deref())?; let remote_url = remote .url() - .ok_or_else(|| anyhow!("could not infer repository: remote has no URL"))? + .ok_or_else(|| { + anyhow!("could not infer repository: remote has no URL") + })? .to_string(); let (owner, name, host) = parse_tangled_remote_url(&remote_url) - .ok_or_else(|| anyhow!("could not parse Tangled remote URL: {}", remote_url))?; + .ok_or_else(|| { + anyhow!("could not parse Tangled remote URL: {}", remote_url) + })?; Ok(GitRepoContext { owner, @@ -111,16 +116,21 @@ pub fn parse_tangled_remote_url(url: &str) -> Option<(String, String, String)> { if !is_tangled_host(&host) { return None; } - return parse_remote_path(path).map(|(owner, name)| (owner, name, host)); + return parse_remote_path(path) + .map(|(owner, name)| (owner, name, host)); } - if url.starts_with("http://") || url.starts_with("https://") || url.starts_with("ssh://") { + if url.starts_with("http://") + || url.starts_with("https://") + || url.starts_with("ssh://") + { let parsed = url::Url::parse(url).ok()?; let host = normalize_host(parsed.host_str()?); if !is_tangled_host(&host) { return None; } - return parse_remote_path(parsed.path()).map(|(owner, name)| (owner, name, host)); + return parse_remote_path(parsed.path()) + .map(|(owner, name)| (owner, name, host)); } None @@ -149,11 +159,15 @@ fn select_tangled_remote<'repo>( current_branch: Option<&str>, ) -> Result<(String, git2::Remote<'repo>)> { if let Some(branch) = current_branch { - if let Ok(local_branch) = repo.find_branch(branch, git2::BranchType::Local) { + if let Ok(local_branch) = + repo.find_branch(branch, git2::BranchType::Local) + { if let Ok(upstream) = local_branch.upstream() { - if let Some(remote_name) = upstream_remote_name(repo, &upstream) { + if let Some(remote_name) = upstream_remote_name(repo, &upstream) + { let remote = repo.find_remote(&remote_name)?; - if remote.url().and_then(parse_tangled_remote_url).is_some() { + if remote.url().and_then(parse_tangled_remote_url).is_some() + { return Ok((remote_name, remote)); } } @@ -168,9 +182,9 @@ fn select_tangled_remote<'repo>( } let mut tangled = vec![]; - let remotes = repo - .remotes() - .map_err(|_| anyhow!("could not infer repository: no git remotes configured"))?; + let remotes = repo.remotes().map_err(|_| { + anyhow!("could not infer repository: no git remotes configured") + })?; for name in remotes.iter().flatten() { let remote = repo.find_remote(name)?; if remote.url().and_then(parse_tangled_remote_url).is_some() { @@ -190,7 +204,10 @@ fn select_tangled_remote<'repo>( } } -fn upstream_remote_name(repo: &Repository, upstream: &git2::Branch<'_>) -> Option { +fn upstream_remote_name( + repo: &Repository, + upstream: &git2::Branch<'_>, +) -> Option { let upstream_ref = upstream.get().name()?; let remotes = repo.remotes().ok()?; for remote in remotes.iter().flatten() { @@ -211,7 +228,9 @@ fn current_branch(repo: &Repository) -> Option { fn default_branch(repo: &Repository) -> Option { repo.find_reference("refs/remotes/origin/HEAD") .ok() - .and_then(|reference| reference.symbolic_target().map(ToOwned::to_owned)) + .and_then(|reference| { + reference.symbolic_target().map(ToOwned::to_owned) + }) .and_then(|target| { target .strip_prefix("refs/remotes/origin/") @@ -221,8 +240,11 @@ fn default_branch(repo: &Repository) -> Option { ["main", "master"] .into_iter() .find(|branch| { - repo.find_reference(&format!("refs/remotes/origin/{}", branch)) - .is_ok() + repo.find_reference(&format!( + "refs/remotes/origin/{}", + branch + )) + .is_ok() }) .map(ToOwned::to_owned) }) @@ -235,7 +257,9 @@ mod tests { #[test] fn parses_tangled_https_remotes() { assert_eq!( - parse_tangled_remote_url("https://tangled.org/@alice.example/demo.git"), + parse_tangled_remote_url( + "https://tangled.org/@alice.example/demo.git" + ), Some(( "alice.example".to_string(), "demo".to_string(), @@ -255,7 +279,9 @@ mod tests { #[test] fn parses_tangled_ssh_remotes() { assert_eq!( - parse_tangled_remote_url("git@knot1.tangled.sh:alice.example/demo.git"), + parse_tangled_remote_url( + "git@knot1.tangled.sh:alice.example/demo.git" + ), Some(( "alice.example".to_string(), "demo".to_string(), @@ -267,7 +293,9 @@ mod tests { #[test] fn parses_tangled_ssh_url_remotes() { assert_eq!( - parse_tangled_remote_url("ssh://git@knot1.tangled.sh/alice.example/demo.git"), + parse_tangled_remote_url( + "ssh://git@knot1.tangled.sh/alice.example/demo.git" + ), Some(( "alice.example".to_string(), "demo".to_string(), diff --git a/crates/tangled-config/src/config.rs b/crates/tangled-config/src/config.rs index d5f2fa6..377f749 100644 --- a/crates/tangled-config/src/config.rs +++ b/crates/tangled-config/src/config.rs @@ -71,9 +71,11 @@ pub fn load_config(path: Option<&Path>) -> Result> { if !path.exists() { return Ok(None); } - let content = fs::read_to_string(&path) - .with_context(|| format!("Failed reading config file: {}", path.display()))?; - let cfg: RootConfig = toml::from_str(&content).context("Invalid TOML in config")?; + let content = fs::read_to_string(&path).with_context(|| { + format!("Failed reading config file: {}", path.display()) + })?; + let cfg: RootConfig = + toml::from_str(&content).context("Invalid TOML in config")?; Ok(Some(cfg)) } @@ -85,7 +87,8 @@ pub fn save_config(cfg: &RootConfig, path: Option<&Path>) -> Result<()> { std::fs::create_dir_all(parent)?; } let toml = toml::to_string_pretty(cfg)?; - fs::write(&path, toml) - .with_context(|| format!("Failed writing config file: {}", path.display()))?; + fs::write(&path, toml).with_context(|| { + format!("Failed writing config file: {}", path.display()) + })?; Ok(()) } diff --git a/crates/tangled-config/src/keychain.rs b/crates/tangled-config/src/keychain.rs index f0691f8..3035c20 100644 --- a/crates/tangled-config/src/keychain.rs +++ b/crates/tangled-config/src/keychain.rs @@ -15,7 +15,8 @@ impl Keychain { } fn entry(&self) -> Result { - Entry::new(&self.service, &self.account).map_err(|e| anyhow!("keyring error: {e}")) + Entry::new(&self.service, &self.account) + .map_err(|e| anyhow!("keyring error: {e}")) } pub fn set_password(&self, secret: &str) -> Result<()> { @@ -25,9 +26,9 @@ impl Keychain { } pub fn get_password(&self) -> Result { - self.entry()? - .get_password() - .map_err(|e| anyhow!("Failed to load credentials from keychain: {e}")) + self.entry()?.get_password().map_err(|e| { + anyhow!("Failed to load credentials from keychain: {e}") + }) } pub fn delete_password(&self) -> Result<()> { diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..ae08a00 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,4 @@ +unstable_features = true +max_width = 80 +group_imports = "StdExternalCrate" +imports_granularity = "Module" diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index f9e9826..1751750 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs @@ -19,13 +19,16 @@ use std::path::{Path, PathBuf}; use anyhow::{Context, Result}; use heck::{ToSnakeCase, ToUpperCamelCase}; -use crate::lexicon::{BodyDef, LexDef, LexType, LexiconDoc, ObjectDef, ParamsDef, XrpcDef}; +use crate::lexicon::{ + BodyDef, LexDef, LexType, LexiconDoc, ObjectDef, ParamsDef, XrpcDef, +}; const RUST_KEYWORDS: &[&str] = &[ - "as", "break", "const", "continue", "crate", "dyn", "else", "enum", "extern", "false", "fn", - "for", "if", "impl", "in", "let", "loop", "match", "mod", "move", "mut", "pub", "ref", - "return", "static", "struct", "super", "trait", "true", "type", "unsafe", "use", "where", - "while", "async", "await", "box", "try", "self", + "as", "break", "const", "continue", "crate", "dyn", "else", "enum", + "extern", "false", "fn", "for", "if", "impl", "in", "let", "loop", "match", + "mod", "move", "mut", "pub", "ref", "return", "static", "struct", "super", + "trait", "true", "type", "unsafe", "use", "where", "while", "async", + "await", "box", "try", "self", ]; /// Generated output: file paths relative to the `lexicon/` module root. @@ -130,10 +133,10 @@ pub fn generate(lexicons_dir: &Path) -> Result { json_files.sort(); for path in &json_files { - let text = - std::fs::read_to_string(path).with_context(|| format!("reading {}", path.display()))?; - let doc: LexiconDoc = - serde_json::from_str(&text).with_context(|| format!("parsing {}", path.display()))?; + let text = std::fs::read_to_string(path) + .with_context(|| format!("reading {}", path.display()))?; + let doc: LexiconDoc = serde_json::from_str(&text) + .with_context(|| format!("parsing {}", path.display()))?; let source = path .strip_prefix(lexicons_dir) .unwrap() @@ -227,10 +230,16 @@ pub fn generate(lexicons_dir: &Path) -> Result { }; let mut out = String::new(); - out.push_str("// @generated by `cargo xtask codegen` \u{2014} do not edit.\n"); + out.push_str( + "// @generated by `cargo xtask codegen` \u{2014} do not edit.\n", + ); if let Some(i) = node.doc { let d = &docs[i]; - let _ = writeln!(out, "// source: lexicons/{} ({})", d.source, d.doc.id); + let _ = writeln!( + out, + "// source: lexicons/{} ({})", + d.source, d.doc.id + ); } out.push('\n'); out.push_str("#![allow(clippy::all)]\n\n"); @@ -268,7 +277,9 @@ pub fn generate(lexicons_dir: &Path) -> Result { // Root mod.rs. { let mut out = String::new(); - out.push_str("// @generated by `cargo xtask codegen` \u{2014} do not edit.\n\n"); + out.push_str( + "// @generated by `cargo xtask codegen` \u{2014} do not edit.\n\n", + ); for seg in root.children.keys() { let _ = writeln!(out, "pub mod {seg};"); } @@ -289,7 +300,9 @@ pub fn generate(lexicons_dir: &Path) -> Result { } fn collect_json_files(dir: &Path, out: &mut Vec) -> Result<()> { - for entry in std::fs::read_dir(dir).with_context(|| format!("reading {}", dir.display()))? { + for entry in std::fs::read_dir(dir) + .with_context(|| format!("reading {}", dir.display()))? + { let entry = entry?; let path = entry.path(); if path.is_dir() { @@ -301,7 +314,12 @@ fn collect_json_files(dir: &Path, out: &mut Vec) -> Result<()> { Ok(()) } -fn emit_doc(d: &Doc, index: &TypeIndex, out: &mut String, warnings: &mut Vec) { +fn emit_doc( + d: &Doc, + index: &TypeIndex, + out: &mut String, + warnings: &mut Vec, +) { let mut used_names: BTreeSet = BTreeSet::new(); // Reserve names for all defs up front so nested-struct synthesis can't // collide with them. @@ -321,7 +339,8 @@ fn emit_doc(d: &Doc, index: &TypeIndex, out: &mut String, warnings: &mut Vec { - let _ = writeln!(out, "pub const NSID: &str = \"{}\";\n", d.doc.id); + let _ = + writeln!(out, "pub const NSID: &str = \"{}\";\n", d.doc.id); doc_comment(out, r.description.as_deref()); emit_struct( d, @@ -354,7 +373,11 @@ fn emit_doc(d: &Doc, index: &TypeIndex, out: &mut String, warnings: &mut Vec { doc_comment(out, t.description.as_deref()); if name == "main" { - let _ = writeln!(out, "pub const NSID: &str = \"{}\";\n", d.doc.id); + let _ = writeln!( + out, + "pub const NSID: &str = \"{}\";\n", + d.doc.id + ); } else { let const_name = name.to_snake_case().to_uppercase(); let _ = writeln!( @@ -373,16 +396,28 @@ fn emit_doc(d: &Doc, index: &TypeIndex, out: &mut String, warnings: &mut Vec { - warnings.push(format!("{}: subscription def {name} skipped", d.doc.id)); + warnings.push(format!( + "{}: subscription def {name} skipped", + d.doc.id + )); } LexDef::Type(t) => { let type_name = pascal(name); doc_comment(out, t.description()); let mut nested = Vec::new(); - let rust = rust_type(d, index, t, &type_name, warnings, &mut nested); + let rust = + rust_type(d, index, t, &type_name, warnings, &mut nested); let _ = writeln!(out, "pub type {type_name} = {rust};\n"); emit_nested( d, @@ -448,9 +483,11 @@ fn emit_struct( for (prop, lex) in &def.properties { let ident = field_ident(prop); - let optional = !def.required.contains(prop) || def.nullable.contains(prop); + let optional = + !def.required.contains(prop) || def.nullable.contains(prop); let parent_hint = format!("{name}{}", pascal(prop)); - let base_ty = rust_type(d, index, lex, &parent_hint, warnings, &mut nested); + let base_ty = + rust_type(d, index, lex, &parent_hint, warnings, &mut nested); let ty = if optional { format!("Option<{base_ty}>") } else { @@ -467,7 +504,8 @@ fn emit_struct( serde_parts.push(format!("rename = \"{prop}\"")); } if optional { - serde_parts.push("skip_serializing_if = \"Option::is_none\"".to_string()); + serde_parts + .push("skip_serializing_if = \"Option::is_none\"".to_string()); serde_parts.push("default".to_string()); } if !serde_parts.is_empty() { @@ -479,7 +517,9 @@ fn emit_struct( if kind != StructKind::Io { out.push_str(" /// Unknown fields, preserved across read-modify-write round-trips.\n"); out.push_str(" #[serde(flatten)]\n"); - out.push_str(" pub extra: serde_json::Map,\n"); + out.push_str( + " pub extra: serde_json::Map,\n", + ); } out.push_str("}\n\n"); @@ -550,9 +590,9 @@ fn rust_type<'a>( // TODO: unions could become $type-tagged enums. LexType::Union { .. } => "serde_json::Value".to_string(), LexType::Blob { .. } => "crate::types::BlobRef".to_string(), - LexType::Unknown { .. } | LexType::Bytes { .. } | LexType::CidLink { .. } => { - "serde_json::Value".to_string() - } + LexType::Unknown { .. } + | LexType::Bytes { .. } + | LexType::CidLink { .. } => "serde_json::Value".to_string(), LexType::Other(v) => { warnings.push(format!( "{}: unsupported lexicon type {}; using serde_json::Value", @@ -602,7 +642,8 @@ fn emit_params( serde_parts.push(format!("rename = \"{prop}\"")); } if optional { - serde_parts.push("skip_serializing_if = \"Option::is_none\"".to_string()); + serde_parts + .push("skip_serializing_if = \"Option::is_none\"".to_string()); } if !serde_parts.is_empty() { let _ = writeln!(out, " #[serde({})]", serde_parts.join(", ")); @@ -650,11 +691,20 @@ fn body_kind( } Some(other) => { let mut nested = Vec::new(); - let rust = rust_type(d, index, other, type_name, warnings, &mut nested); + let rust = + rust_type(d, index, other, type_name, warnings, &mut nested); if rust != type_name { let _ = writeln!(out, "pub type {type_name} = {rust};\n"); } - emit_nested(d, index, out, warnings, used_names, nested, StructKind::Io); + emit_nested( + d, + index, + out, + warnings, + used_names, + nested, + StructKind::Io, + ); BodyKind::Json(type_name.to_string()) } None => { @@ -662,7 +712,8 @@ fn body_kind( "{}: application/json body without schema; treating as untyped", d.doc.id )); - let _ = writeln!(out, "pub type {type_name} = serde_json::Value;\n"); + let _ = + writeln!(out, "pub type {type_name} = serde_json::Value;\n"); BodyKind::Json(type_name.to_string()) } } @@ -685,8 +736,10 @@ fn emit_xrpc( } used_names.insert("Input".to_string()); used_names.insert("Output".to_string()); - let input = body_kind(d, index, out, warnings, used_names, &x.input, "Input"); - let output = body_kind(d, index, out, warnings, used_names, &x.output, "Output"); + let input = + body_kind(d, index, out, warnings, used_names, &x.input, "Input"); + let output = + body_kind(d, index, out, warnings, used_names, &x.output, "Output"); let fn_name = snake(d.doc.id.rsplit('.').next().unwrap()); diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 4f70589..b6d62d3 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -9,13 +9,12 @@ //! the command exits non-zero if the committed generated code is out of date //! (or contains stray files). -use xtask::codegen; - use std::collections::BTreeMap; use std::path::{Path, PathBuf}; use std::process::Command; use anyhow::{bail, Context, Result}; +use xtask::codegen; fn main() -> Result<()> { let args: Vec = std::env::args().skip(1).collect(); @@ -89,7 +88,8 @@ fn run_codegen(check: bool) -> Result<()> { } for p in &stray { let full = out_dir.join(p); - std::fs::remove_file(&full).with_context(|| format!("removing {}", full.display()))?; + std::fs::remove_file(&full) + .with_context(|| format!("removing {}", full.display()))?; } remove_empty_dirs(&out_dir)?; println!( @@ -102,11 +102,14 @@ fn run_codegen(check: bool) -> Result<()> { } /// Formats each generated file with rustfmt so output is stable and readable. -fn rustfmt_all(files: BTreeMap) -> Result> { +fn rustfmt_all( + files: BTreeMap, +) -> Result> { let mut out = BTreeMap::new(); for (path, content) in files { - let formatted = rustfmt(&content) - .with_context(|| format!("rustfmt failed on generated file {}", path.display()))?; + let formatted = rustfmt(&content).with_context(|| { + format!("rustfmt failed on generated file {}", path.display()) + })?; out.insert(path, formatted); } Ok(out) @@ -138,7 +141,11 @@ fn read_tree(dir: &Path) -> Result> { if !dir.exists() { return Ok(out); } - fn walk(root: &Path, dir: &Path, out: &mut BTreeMap) -> Result<()> { + fn walk( + root: &Path, + dir: &Path, + out: &mut BTreeMap, + ) -> Result<()> { for entry in std::fs::read_dir(dir)? { let path = entry?.path(); if path.is_dir() { diff --git a/xtask/tests/golden.rs b/xtask/tests/golden.rs index 8803aa5..bf397c3 100644 --- a/xtask/tests/golden.rs +++ b/xtask/tests/golden.rs @@ -9,7 +9,8 @@ use std::path::{Path, PathBuf}; #[test] fn generated_output_matches_golden_files() { let fixtures = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures"); - let generated = xtask::codegen::generate(&fixtures.join("lexicons")).unwrap(); + let generated = + xtask::codegen::generate(&fixtures.join("lexicons")).unwrap(); assert!( generated.warnings.is_empty(), "unexpected warnings: {:#?}",