fix: add --all to cargo fmt in script/test and autoformat codebase
cargo fmt without --all fails with "Failed to find targets" in workspace repos. This was blocking every story's gates. Also ran cargo fmt --all to fix all existing formatting issues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+37
-45
@@ -16,8 +16,8 @@
|
||||
/// no filesystem scan is needed after migration.
|
||||
use crate::io::story_metadata::parse_front_matter;
|
||||
use crate::slog;
|
||||
use sqlx::sqlite::SqliteConnectOptions;
|
||||
use sqlx::SqlitePool;
|
||||
use sqlx::sqlite::SqliteConnectOptions;
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
use std::sync::{Mutex, OnceLock};
|
||||
@@ -86,14 +86,18 @@ pub fn read_content(story_id: &str) -> Option<String> {
|
||||
///
|
||||
/// Updates the in-memory store immediately.
|
||||
pub fn write_content(story_id: &str, content: &str) {
|
||||
if let Some(store) = get_content_store() && let Ok(mut map) = store.lock() {
|
||||
if let Some(store) = get_content_store()
|
||||
&& let Ok(mut map) = store.lock()
|
||||
{
|
||||
map.insert(story_id.to_string(), content.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove a story's content from the in-memory store.
|
||||
pub fn delete_content(story_id: &str) {
|
||||
if let Some(store) = get_content_store() && let Ok(mut map) = store.lock() {
|
||||
if let Some(store) = get_content_store()
|
||||
&& let Ok(mut map) = store.lock()
|
||||
{
|
||||
map.remove(story_id);
|
||||
}
|
||||
}
|
||||
@@ -103,7 +107,9 @@ pub fn delete_content(story_id: &str) {
|
||||
/// Safe to call multiple times — the `OnceLock` is set at most once.
|
||||
pub fn ensure_content_store() {
|
||||
#[cfg(not(test))]
|
||||
{ let _ = CONTENT_STORE.set(Mutex::new(HashMap::new())); }
|
||||
{
|
||||
let _ = CONTENT_STORE.set(Mutex::new(HashMap::new()));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
{
|
||||
@@ -222,11 +228,7 @@ pub async fn init(db_path: &Path) -> Result<(), sqlx::Error> {
|
||||
///
|
||||
/// This is the primary write path for the DB-backed pipeline. It updates
|
||||
/// the CRDT, the in-memory content store, and the SQLite shadow table.
|
||||
pub fn write_item_with_content(
|
||||
story_id: &str,
|
||||
stage: &str,
|
||||
content: &str,
|
||||
) {
|
||||
pub fn write_item_with_content(story_id: &str, stage: &str, content: &str) {
|
||||
let (name, agent, retry_count, blocked, depends_on) = match parse_front_matter(content) {
|
||||
Ok(meta) => (
|
||||
meta.name,
|
||||
@@ -389,7 +391,9 @@ pub fn next_item_number() -> u32 {
|
||||
.chars()
|
||||
.take_while(|c| c.is_ascii_digit())
|
||||
.collect();
|
||||
if let Ok(n) = num_str.parse::<u32>() && n > max_num {
|
||||
if let Ok(n) = num_str.parse::<u32>()
|
||||
&& n > max_num
|
||||
{
|
||||
max_num = n;
|
||||
}
|
||||
}
|
||||
@@ -397,7 +401,9 @@ pub fn next_item_number() -> u32 {
|
||||
// Also scan the content store (might have items not yet in CRDT).
|
||||
for id in all_content_ids() {
|
||||
let num_str: String = id.chars().take_while(|c| c.is_ascii_digit()).collect();
|
||||
if let Ok(n) = num_str.parse::<u32>() && n > max_num {
|
||||
if let Ok(n) = num_str.parse::<u32>()
|
||||
&& n > max_num
|
||||
{
|
||||
max_num = n;
|
||||
}
|
||||
}
|
||||
@@ -405,7 +411,6 @@ pub fn next_item_number() -> u32 {
|
||||
max_num + 1
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -427,10 +432,7 @@ mod tests {
|
||||
.filename(&db_path)
|
||||
.create_if_missing(true);
|
||||
let pool = SqlitePool::connect_with(options).await.unwrap();
|
||||
sqlx::migrate!("./migrations")
|
||||
.run(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
sqlx::migrate!("./migrations").run(&pool).await.unwrap();
|
||||
|
||||
// Write a story file in a temp stage dir.
|
||||
let stage_dir = tmp.path().join("2_current");
|
||||
@@ -472,13 +474,12 @@ mod tests {
|
||||
.unwrap();
|
||||
|
||||
// Query back and verify.
|
||||
let row: (String, Option<String>, String) = sqlx::query_as(
|
||||
"SELECT id, name, stage FROM pipeline_items WHERE id = ?1",
|
||||
)
|
||||
.bind("10_story_shadow_test")
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let row: (String, Option<String>, String) =
|
||||
sqlx::query_as("SELECT id, name, stage FROM pipeline_items WHERE id = ?1")
|
||||
.bind("10_story_shadow_test")
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(row.0, "10_story_shadow_test");
|
||||
assert_eq!(row.1.as_deref(), Some("Shadow Test"));
|
||||
@@ -512,10 +513,7 @@ mod tests {
|
||||
.filename(&db_path)
|
||||
.create_if_missing(true);
|
||||
let pool = SqlitePool::connect_with(options).await.unwrap();
|
||||
sqlx::migrate!("./migrations")
|
||||
.run(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
sqlx::migrate!("./migrations").run(&pool).await.unwrap();
|
||||
|
||||
// Verify content column exists by inserting a full row.
|
||||
let now = chrono::Utc::now().to_rfc3339();
|
||||
@@ -538,13 +536,12 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let row: (Option<String>,) = sqlx::query_as(
|
||||
"SELECT content FROM pipeline_items WHERE id = ?1",
|
||||
)
|
||||
.bind("99_story_col_test")
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let row: (Option<String>,) =
|
||||
sqlx::query_as("SELECT content FROM pipeline_items WHERE id = ?1")
|
||||
.bind("99_story_col_test")
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(row.0.as_deref(), Some(content));
|
||||
}
|
||||
|
||||
@@ -556,10 +553,7 @@ mod tests {
|
||||
.filename(&db_path)
|
||||
.create_if_missing(true);
|
||||
let pool = SqlitePool::connect_with(options).await.unwrap();
|
||||
sqlx::migrate!("./migrations")
|
||||
.run(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
sqlx::migrate!("./migrations").run(&pool).await.unwrap();
|
||||
|
||||
let now = chrono::Utc::now().to_rfc3339();
|
||||
|
||||
@@ -610,12 +604,11 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let row: (String,) =
|
||||
sqlx::query_as("SELECT stage FROM pipeline_items WHERE id = ?1")
|
||||
.bind("5_story_move")
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let row: (String,) = sqlx::query_as("SELECT stage FROM pipeline_items WHERE id = ?1")
|
||||
.bind("5_story_move")
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(row.0, "2_current");
|
||||
}
|
||||
@@ -709,5 +702,4 @@ mod tests {
|
||||
row.map(|r| r.0)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user