git_checks_core/
impl_prelude.rs

1// Copyright Kitware, Inc.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9//! Module for importing all types and traits for implementing checks.
10
11pub use std::error::Error;
12
13pub use git_workarea::CommitId;
14pub use git_workarea::GitError;
15pub use git_workarea::Identity;
16
17pub use crate::check::BranchCheck;
18pub use crate::check::Check;
19pub use crate::check::CheckResult;
20pub use crate::check::ContentCheck;
21pub use crate::check::TopicCheck;
22pub use crate::commit::Commit;
23pub use crate::commit::CommitError;
24pub use crate::commit::Content;
25pub use crate::commit::DiffInfo;
26pub use crate::commit::FileName;
27pub use crate::commit::StatusChange;
28pub use crate::commit::Topic;
29pub use crate::context::AttributeState;
30pub use crate::context::CheckGitContext;
31pub use crate::utils::SubmoduleContext;
32
33/// Create a prefix to a message referencing the associated.
34pub fn commit_prefix(content: &dyn Content) -> String {
35    if let Some(sha1) = content.sha1() {
36        format!("commit {} ", sha1)
37    } else {
38        String::new()
39    }
40}
41
42/// Create a prefix to a message referencing the associated with a description string.
43pub fn commit_prefix_str<M>(content: &dyn Content, msg: M) -> String
44where
45    M: AsRef<str>,
46{
47    if let Some(sha1) = content.sha1() {
48        format!("commit {} {} ", sha1, msg.as_ref())
49    } else {
50        String::new()
51    }
52}