huskies: merge 870
This commit is contained in:
@@ -5,9 +5,7 @@
|
||||
//! and returns a confirmation.
|
||||
|
||||
use super::CommandContext;
|
||||
use crate::io::story_metadata::{
|
||||
clear_front_matter_field_in_content, parse_front_matter, set_front_matter_field,
|
||||
};
|
||||
use crate::io::story_metadata::{clear_front_matter_field_in_content, parse_front_matter};
|
||||
use std::path::Path;
|
||||
|
||||
/// Handle the `unblock` command.
|
||||
@@ -73,7 +71,8 @@ fn unblock_by_story_id(story_id: &str) -> String {
|
||||
if has_merge_failure {
|
||||
updated = clear_front_matter_field_in_content(&updated, "merge_failure");
|
||||
}
|
||||
updated = set_front_matter_field(&updated, "retry_count", "0");
|
||||
// retry_count lives in the CRDT; clear any stale copy from front-matter.
|
||||
updated = clear_front_matter_field_in_content(&updated, "retry_count");
|
||||
|
||||
crate::db::write_content(story_id, &updated);
|
||||
let stage = crate::pipeline_state::read_typed(story_id)
|
||||
@@ -82,6 +81,7 @@ fn unblock_by_story_id(story_id: &str) -> String {
|
||||
.map(|i| i.stage.dir_name().to_string())
|
||||
.unwrap_or_else(|| "2_current".to_string());
|
||||
crate::db::write_item_with_content(story_id, &stage, &updated);
|
||||
crate::crdt_state::set_retry_count(story_id, 0);
|
||||
|
||||
let mut cleared = Vec::new();
|
||||
if has_blocked {
|
||||
@@ -189,6 +189,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn unblock_command_clears_blocked_and_resets_retry_count() {
|
||||
crate::crdt_state::init_for_test();
|
||||
let tmp = tempfile::TempDir::new().unwrap();
|
||||
// Use a high story number (9903) to avoid collisions with other tests in the
|
||||
// global content store.
|
||||
@@ -198,6 +199,19 @@ mod tests {
|
||||
"9903_story_stuck.md",
|
||||
"---\nname: Stuck Story\nblocked: true\nretry_count: 5\n---\n# Story\n",
|
||||
);
|
||||
// Seed the story in the CRDT with retry_count=5 so set_retry_count can reset it.
|
||||
crate::crdt_state::write_item(
|
||||
"9903_story_stuck",
|
||||
"2_current",
|
||||
Some("Stuck Story"),
|
||||
None,
|
||||
Some(5),
|
||||
Some(true),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
let output = unblock_cmd_with_root(tmp.path(), "9903").unwrap();
|
||||
assert!(
|
||||
@@ -209,7 +223,7 @@ mod tests {
|
||||
"should include story_id in response: {output}"
|
||||
);
|
||||
|
||||
// The unblock command writes back via the content store; read from there.
|
||||
// The unblock command writes back via the content store; blocked field should be gone.
|
||||
let contents = crate::db::read_content("9903_story_stuck")
|
||||
.or_else(|| {
|
||||
std::fs::read_to_string(
|
||||
@@ -223,9 +237,17 @@ mod tests {
|
||||
!contents.contains("blocked:"),
|
||||
"blocked field should be removed: {contents}"
|
||||
);
|
||||
// retry_count is now in the CRDT, not in front-matter.
|
||||
assert!(
|
||||
contents.contains("retry_count: 0"),
|
||||
"retry_count should be reset to 0: {contents}"
|
||||
!contents.contains("retry_count:"),
|
||||
"retry_count should be cleared from front-matter after unblock: {contents}"
|
||||
);
|
||||
let item = crate::crdt_state::read_item("9903_story_stuck")
|
||||
.expect("story should be in CRDT after unblock");
|
||||
assert_eq!(
|
||||
item.retry_count,
|
||||
Some(0),
|
||||
"retry_count should be reset to 0 in CRDT after unblock"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user