1use std::fmt;
2
3use schemars::JsonSchema;
4use serde::Deserialize;
5use serde::Serialize;
6use ts_rs::TS;
7
8mod errors;
9mod ghost_commits;
10mod operations;
11mod platform;
12
13pub use errors::GitToolingError;
14pub use ghost_commits::CreateGhostCommitOptions;
15pub use ghost_commits::create_ghost_commit;
16pub use ghost_commits::restore_ghost_commit;
17pub use ghost_commits::restore_to_commit;
18pub use platform::create_symlink;
19
20#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema, TS)]
22pub struct GhostCommit {
23 id: String,
24 parent: Option<String>,
25}
26
27impl GhostCommit {
28 pub fn new(id: String, parent: Option<String>) -> Self {
30 Self { id, parent }
31 }
32
33 pub fn id(&self) -> &str {
35 &self.id
36 }
37
38 pub fn parent(&self) -> Option<&str> {
40 self.parent.as_deref()
41 }
42}
43
44impl fmt::Display for GhostCommit {
45 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
46 write!(f, "{}", self.id)
47 }
48}