1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use std::convert::Infallible;
use miette::{Diagnostic, Result};
use thiserror::Error;
pub trait Vcs {
fn entries(&self, glob: Option<&str>) -> Result<Vec<String>>;
fn get_bool(&self, name: &str) -> Result<Option<bool>>;
fn get_str(&self, name: &str) -> Result<Option<&str>>;
fn get_i64(&self, name: &str) -> Result<Option<i64>>;
fn set_str(&mut self, name: &str, value: &str) -> Result<()>;
fn set_i64(&mut self, name: &str, value: i64) -> Result<()>;
fn remove(&mut self, name: &str) -> Result<()>;
}
#[derive(Error, Debug, Diagnostic)]
pub enum Error {
#[error("failed to interact with git repository: {0}")]
#[diagnostic(
url(docsrs),
code(mit_commit_message_lints::external::vcs::error::git2_io)
)]
Git2Io(git2::Error),
#[error("failed to read int from in memory datastore: {0}")]
#[diagnostic(
url(docsrs),
code(mit_commit_message_lints::external::vcs::error::in_memory_parse_int)
)]
InMemoryParseInt(std::num::ParseIntError),
#[error("failed to read bool from in memory datastore: {0}")]
#[diagnostic(
url(docsrs),
code(mit_commit_message_lints::external::vcs::error::in_memory_parse_bool)
)]
InMemoryParseBool(std::str::ParseBoolError),
#[error("failed to read git-mit config")]
#[diagnostic(url(docsrs), code(mit_commit_message_lints::external::vcs::error::io))]
Io(std::io::Error),
#[error("failed to parse glob {0}")]
#[diagnostic(
url(docsrs),
code(mit_commit_message_lints::external::vcs::error::glob)
)]
Glob(glob::PatternError),
#[error(transparent)]
#[diagnostic(
url(docsrs),
code(mit_commit_message_lints::external::vcs::error::infallible)
)]
Infallible(Infallible),
}