workyard_git/
repository.rs1mod effects;
2mod inspection;
3mod planning;
4pub(crate) mod remote;
5
6use std::path::PathBuf;
7use workyard_core::Problem;
8
9#[derive(Clone, Debug)]
11pub struct Repository {
12 pub source: PathBuf,
14 pub common_dir: PathBuf,
16 pub remote: Option<String>,
18 pub identity: String,
20}
21
22fn utf8(bytes: &[u8]) -> Result<&str, Problem> {
23 std::str::from_utf8(bytes).map_err(|_| {
24 Problem::new(
25 workyard_core::ProblemCode::InvalidGitOutput,
26 "Git returned non-Unicode ref metadata.",
27 )
28 })
29}
30
31fn decode_path(bytes: &[u8]) -> Result<PathBuf, Problem> {
32 crate::output::path_line(bytes).map_err(|_| {
33 Problem::new(
34 workyard_core::ProblemCode::InvalidGitOutput,
35 "Git returned non-Unicode ref metadata.",
36 )
37 })
38}
39
40impl From<Repository> for workyard_core::Repository {
41 fn from(repository: Repository) -> Self {
42 Self {
43 source: repository.source,
44 common_dir: repository.common_dir,
45 remote: repository.remote,
46 identity: repository.identity,
47 }
48 }
49}
50
51impl From<&workyard_core::Repository> for Repository {
52 fn from(repository: &workyard_core::Repository) -> Self {
53 Self {
54 source: repository.source.clone(),
55 common_dir: repository.common_dir.clone(),
56 remote: repository.remote.clone(),
57 identity: repository.identity.clone(),
58 }
59 }
60}