Skip to main content

routa_core/models/
codebase.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5#[serde(rename_all = "camelCase")]
6pub struct Codebase {
7    pub id: String,
8    pub workspace_id: String,
9    pub repo_path: String,
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub branch: Option<String>,
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub label: Option<String>,
14    pub is_default: bool,
15    pub created_at: DateTime<Utc>,
16    pub updated_at: DateTime<Utc>,
17}
18
19impl Codebase {
20    pub fn new(
21        id: String,
22        workspace_id: String,
23        repo_path: String,
24        branch: Option<String>,
25        label: Option<String>,
26        is_default: bool,
27    ) -> Self {
28        let now = Utc::now();
29        Self {
30            id,
31            workspace_id,
32            repo_path,
33            branch,
34            label,
35            is_default,
36            created_at: now,
37            updated_at: now,
38        }
39    }
40}