pub struct CommitSubject {
pub text: String,
pub scopes: Option<Vec<String>>,
pub paths: Option<Vec<String>>,
pub records: Vec<String>,
}Expand description
Everything the judge is allowed to look at.
A struct rather than five arguments, because the two halves that are optional are
exactly the two a caller may not have: a hook running on commit-msg knows the staged
files, a gate reading history does not, and a judge that demanded both would have to be
two judges.
use majordomus_cli::commit::{judge, CommitPolicy, CommitSubject};
// the two optional halves are the two a caller may not have: a hook knows the staged
// files, a gate reading history does not
let hook = CommitSubject {
text: "fix(a): a thing".into(),
paths: Some(vec!["src/a.rs".into()]),
..CommitSubject::default()
};
assert_eq!(judge(&hook, &CommitPolicy::default()).findings.len(), 1);
let gate = CommitSubject::of("fix(a): a thing");
assert!(judge(&gate, &CommitPolicy::default()).findings.is_empty());Fields§
§text: StringThe message as it will be stored.
scopes: Option<Vec<String>>The scope vocabulary this repository yields, when it has been derived.
paths: Option<Vec<String>>The paths this commit will contain, when they are known.
records: Vec<String>The record ids the layer holds, for resolving what the message names.
Implementations§
Source§impl CommitSubject
impl CommitSubject
Sourcepub fn of(text: &str) -> CommitSubject
pub fn of(text: &str) -> CommitSubject
A subject that is only a message: the judgements that need no other evidence.
use majordomus_cli::commit::CommitSubject;
let s = CommitSubject::of("feat(a): a thing");
assert!(s.paths.is_none(), "a judgement needing paths is not made rather than guessed");
assert!(s.scopes.is_none());Trait Implementations§
Source§impl Clone for CommitSubject
impl Clone for CommitSubject
Source§fn clone(&self) -> CommitSubject
fn clone(&self) -> CommitSubject
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CommitSubject
impl Debug for CommitSubject
Source§impl Default for CommitSubject
impl Default for CommitSubject
Source§fn default() -> CommitSubject
fn default() -> CommitSubject
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CommitSubject
impl RefUnwindSafe for CommitSubject
impl Send for CommitSubject
impl Sync for CommitSubject
impl Unpin for CommitSubject
impl UnsafeUnpin for CommitSubject
impl UnwindSafe for CommitSubject
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more