Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions crates/kild-core/src/sessions/destroy.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use kild_paths::KildPaths;
use tracing::{debug, error, info, warn};

use crate::forge::types::PrCheckResult;
use crate::git;
use crate::git::get_worktree_status;
use crate::sessions::{errors::SessionError, persistence, types::*};
Expand Down Expand Up @@ -179,11 +180,8 @@ pub fn destroy_session(name: &str, force: bool) -> Result<(), SessionError> {
);
}

let &(first_pid, ref first_msg) = kill_errors.first().unwrap();
let error_count = kill_errors.len();
let (first_pid, first_msg) = {
let (p, m) = kill_errors.first().unwrap();
(*p, m.clone())
};

let message = if error_count == 1 {
format!(
Expand Down
2 changes: 1 addition & 1 deletion crates/kild-core/src/sessions/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ mod tests;
pub use agent_process::AgentProcess;
pub use kild_protocol::AgentStatus;
pub use request::{CreateSessionRequest, ValidatedRequest};
pub use safety::{CompleteRequest, CompleteResult, DestroySafetyInfo, PrCheckResult};
pub use safety::{CompleteRequest, CompleteResult, DestroySafetyInfo};
pub use session::Session;
pub use status::{AgentStatusInfo, GitStatus, ProcessStatus, SessionStatus};
28 changes: 14 additions & 14 deletions crates/kild-core/src/sessions/types/safety.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub use crate::forge::types::PrCheckResult;
use crate::forge::types::{MergeStrategy, PrCheckResult};
use crate::git::types::WorktreeStatus;

/// Safety information for a destroy operation.
Expand Down Expand Up @@ -59,16 +59,16 @@ impl DestroySafetyInfo {
// Skip if status check failed (already showed critical message)
if self.git_status.has_uncommitted_changes && !self.git_status.status_check_failed {
let message = if let Some(details) = &self.git_status.uncommitted_details {
let parts: Vec<String> = [
(details.staged_files > 0).then(|| format!("{} staged", details.staged_files)),
(details.modified_files > 0)
.then(|| format!("{} modified", details.modified_files)),
(details.untracked_files > 0)
.then(|| format!("{} untracked", details.untracked_files)),
]
.into_iter()
.flatten()
.collect();
let mut parts = Vec::new();
if details.staged_files > 0 {
parts.push(format!("{} staged", details.staged_files));
}
if details.modified_files > 0 {
parts.push(format!("{} modified", details.modified_files));
}
if details.untracked_files > 0 {
parts.push(format!("{} untracked", details.untracked_files));
}
format!("Uncommitted changes: {}", parts.join(", "))
} else {
"Uncommitted changes detected".to_string()
Expand Down Expand Up @@ -106,7 +106,7 @@ pub struct CompleteRequest {
/// Branch name of the kild to complete.
pub name: String,
/// Merge strategy (squash, merge, rebase).
pub merge_strategy: crate::forge::types::MergeStrategy,
pub merge_strategy: MergeStrategy,
/// Skip merging — just clean up (old behavior, requires PR already merged).
pub no_merge: bool,
/// Force through safety checks (uncommitted changes, CI failures, pending reviews).
Expand All @@ -122,7 +122,7 @@ impl CompleteRequest {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
merge_strategy: crate::forge::types::MergeStrategy::default(),
merge_strategy: MergeStrategy::default(),
no_merge: false,
force: false,
dry_run: false,
Expand All @@ -137,7 +137,7 @@ pub enum CompleteResult {
/// PR was merged by this command, remote branch deleted, session destroyed.
Merged {
/// The merge strategy used.
strategy: crate::forge::types::MergeStrategy,
strategy: MergeStrategy,
/// Whether remote branch was deleted (false if deletion failed, non-fatal).
remote_deleted: bool,
},
Expand Down
33 changes: 1 addition & 32 deletions crates/kild-core/src/sessions/types/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::*;
use crate::forge::types::PrCheckResult;
use std::path::PathBuf;

#[test]
Expand Down Expand Up @@ -325,38 +326,6 @@ fn test_is_worktree_valid_with_missing_path() {
assert!(!session.is_worktree_valid());
}

// --- PrCheckResult tests ---

#[test]
fn test_pr_check_result_exists() {
let result = PrCheckResult::Exists;
assert!(result.exists());
assert!(!result.not_found());
assert!(!result.is_unavailable());
}

#[test]
fn test_pr_check_result_not_found() {
let result = PrCheckResult::NotFound;
assert!(!result.exists());
assert!(result.not_found());
assert!(!result.is_unavailable());
}

#[test]
fn test_pr_check_result_unavailable() {
let result = PrCheckResult::Unavailable;
assert!(!result.exists());
assert!(!result.not_found());
assert!(result.is_unavailable());
}

#[test]
fn test_pr_check_result_default() {
let result = PrCheckResult::default();
assert!(result.is_unavailable());
}

// --- DestroySafetyInfo tests ---

#[test]
Expand Down