clog_enum!{
#[derive(Debug)]
pub enum LinkStyle {
Github,
Gitlab,
Stash,
Cgit
}
}
impl LinkStyle {
pub fn issue_link<S: AsRef<str>>(&self, issue: S, repo: S) -> String {
match repo.as_ref() {
"" => format!("{}", issue.as_ref()),
link => {
match *self {
LinkStyle::Github => format!("{}/issues/{}", link, issue.as_ref()),
LinkStyle::Gitlab => format!("{}/issues/{}", link, issue.as_ref()),
LinkStyle::Stash => format!("{}", issue.as_ref()),
LinkStyle::Cgit => format!("{}", issue.as_ref()),
}
}
}
}
pub fn commit_link<S: AsRef<str>>(&self, hash: S, repo: S) -> String {
match repo.as_ref() {
"" => format!("{}", &hash.as_ref()[0..8]),
link => {
match *self {
LinkStyle::Github => format!("{}/commit/{}", link, hash.as_ref()),
LinkStyle::Gitlab => format!("{}/commit/{}", link, hash.as_ref()),
LinkStyle::Stash => format!("{}/commits/{}", link, hash.as_ref()),
LinkStyle::Cgit => format!("{}/commit/?id={}", link, hash.as_ref()),
}
}
}
}
}