Skip to main content

changeset_git/
types.rs

1use std::path::PathBuf;
2
3use gset::Getset;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub enum FileStatus {
7    Added,
8    Modified,
9    Deleted,
10    Renamed,
11    Copied,
12    Typechange,
13}
14
15#[derive(Debug, Clone, PartialEq, Eq, Getset)]
16pub struct FileChange {
17    #[getset(get, vis = "pub")]
18    path: PathBuf,
19    #[getset(get_copy, vis = "pub")]
20    status: FileStatus,
21    #[getset(get_as_ref, vis = "pub", ty = "Option<&PathBuf>")]
22    old_path: Option<PathBuf>,
23}
24
25impl FileChange {
26    #[must_use]
27    pub fn new(path: PathBuf, status: FileStatus) -> Self {
28        Self {
29            path,
30            status,
31            old_path: None,
32        }
33    }
34
35    #[must_use]
36    pub fn with_old_path(mut self, old_path: PathBuf) -> Self {
37        self.old_path = Some(old_path);
38        self
39    }
40}
41
42#[derive(Debug, Clone, PartialEq, Eq, Getset)]
43pub struct TagInfo {
44    #[getset(get, vis = "pub")]
45    name: String,
46    #[getset(get, vis = "pub")]
47    target_sha: String,
48}
49
50impl TagInfo {
51    #[must_use]
52    pub fn new(name: String, target_sha: String) -> Self {
53        Self { name, target_sha }
54    }
55}
56
57#[derive(Debug, Clone, PartialEq, Eq, Getset)]
58pub struct CommitInfo {
59    #[getset(get, vis = "pub")]
60    sha: String,
61    #[getset(get, vis = "pub")]
62    message: String,
63}
64
65impl CommitInfo {
66    #[must_use]
67    pub fn new(sha: String, message: String) -> Self {
68        Self { sha, message }
69    }
70}