routa_core/models/
worktree.rs1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5#[serde(rename_all = "camelCase")]
6pub struct Worktree {
7 pub id: String,
8 pub codebase_id: String,
9 pub workspace_id: String,
10 pub worktree_path: String,
11 pub branch: String,
12 pub base_branch: String,
13 pub status: String,
14 #[serde(skip_serializing_if = "Option::is_none")]
15 pub session_id: Option<String>,
16 #[serde(skip_serializing_if = "Option::is_none")]
17 pub label: Option<String>,
18 #[serde(skip_serializing_if = "Option::is_none")]
19 pub error_message: Option<String>,
20 pub created_at: DateTime<Utc>,
21 pub updated_at: DateTime<Utc>,
22}
23
24impl Worktree {
25 pub fn new(
26 id: String,
27 codebase_id: String,
28 workspace_id: String,
29 worktree_path: String,
30 branch: String,
31 base_branch: String,
32 label: Option<String>,
33 ) -> Self {
34 let now = Utc::now();
35 Self {
36 id,
37 codebase_id,
38 workspace_id,
39 worktree_path,
40 branch,
41 base_branch,
42 status: "creating".to_string(),
43 session_id: None,
44 label,
45 error_message: None,
46 created_at: now,
47 updated_at: now,
48 }
49 }
50}