generated from PlexSheep/rs-base
we got basic git log
cargo devel CI / cargo CI (push) Successful in 4m17s
Details
cargo devel CI / cargo CI (push) Successful in 4m17s
Details
This commit is contained in:
parent
d31befe195
commit
15d11edac7
|
@ -28,6 +28,7 @@ git2 = "0.18.1"
|
||||||
libpt = { version = "0.3.11", features = ["log"] }
|
libpt = { version = "0.3.11", features = ["log"] }
|
||||||
serde = { version = "1.0.195", features = ["derive"] }
|
serde = { version = "1.0.195", features = ["derive"] }
|
||||||
serde_yaml = "0.9.30"
|
serde_yaml = "0.9.30"
|
||||||
|
tempfile = "3.9.0"
|
||||||
thiserror = "1.0.56"
|
thiserror = "1.0.56"
|
||||||
url = { version = "2.5.0", features = ["serde"] }
|
url = { version = "2.5.0", features = ["serde"] }
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::fmt::Display;
|
use std::{fmt::Display, process::Command};
|
||||||
|
|
||||||
use crate::{config::Config, error::*};
|
use crate::{config::Config, error::*};
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ pub struct Changelog {
|
||||||
impl Changelog {
|
impl Changelog {
|
||||||
pub fn build(cfg: &Config) -> Result<Self> {
|
pub fn build(cfg: &Config) -> Result<Self> {
|
||||||
if !cfg.yaml.changelog.enable {
|
if !cfg.yaml.changelog.enable {
|
||||||
return Err(ConfigError::IsDisabledButUsed("changelog").into());
|
return Err(ChangelogError::IsDisabledButUsed.into());
|
||||||
}
|
}
|
||||||
let git_log = Self::make_git_log(cfg)?;
|
let git_log = Self::make_git_log(cfg)?;
|
||||||
Ok(Changelog { git_log })
|
Ok(Changelog { git_log })
|
||||||
|
@ -21,7 +21,15 @@ impl Changelog {
|
||||||
if !cfg.yaml.changelog.enable {
|
if !cfg.yaml.changelog.enable {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
Ok(Some(format!("todo")))
|
let mut cmd = Command::new("git");
|
||||||
|
cmd.arg("log").arg("--oneline").arg("--decorate");
|
||||||
|
let out = cmd.output()?;
|
||||||
|
// FIXME: this does not catch fancy colors
|
||||||
|
let buf = String::from_utf8(out.stdout).map_err(|err|{
|
||||||
|
ChangelogError::GitUTF8Error(err)
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok(Some(buf))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
src/error.rs
15
src/error.rs
|
@ -1,4 +1,4 @@
|
||||||
use std::path::PathBuf;
|
use std::{path::PathBuf, string::FromUtf8Error};
|
||||||
|
|
||||||
use anyhow;
|
use anyhow;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
@ -18,8 +18,19 @@ pub enum Error {
|
||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
#[error("Yaml error")]
|
#[error("Yaml error")]
|
||||||
SerdeYaml(#[from] serde_yaml::Error),
|
SerdeYaml(#[from] serde_yaml::Error),
|
||||||
|
#[error("Could not generate the changelog")]
|
||||||
|
ChangelogError(#[from] ChangelogError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
pub enum ChangelogError {
|
||||||
|
#[error("changelog has 'enabled = false' in the yaml config")]
|
||||||
|
IsDisabledButUsed,
|
||||||
|
#[error("error while using `git log`, is git installed?")]
|
||||||
|
GitCommandError,
|
||||||
|
#[error("error while using `git log`, could not format stdout with utf8")]
|
||||||
|
GitUTF8Error(#[from] FromUtf8Error),
|
||||||
|
}
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum ConfigError {
|
pub enum ConfigError {
|
||||||
#[error("could not find git repository")]
|
#[error("could not find git repository")]
|
||||||
|
@ -30,8 +41,6 @@ pub enum ConfigError {
|
||||||
YamlFileIsNotFile,
|
YamlFileIsNotFile,
|
||||||
#[error("api {0:?} provides both a `pass` and a `pass_file`")]
|
#[error("api {0:?} provides both a `pass` and a `pass_file`")]
|
||||||
YamlApiAuthBothPass(ApiAuth),
|
YamlApiAuthBothPass(ApiAuth),
|
||||||
#[error("{0} has 'enabled = false' in the yaml config")]
|
|
||||||
IsDisabledButUsed(&'static str),
|
|
||||||
#[error("password provided as file, but does not exist: {0}")]
|
#[error("password provided as file, but does not exist: {0}")]
|
||||||
PassFileDoesNotExist(PathBuf),
|
PassFileDoesNotExist(PathBuf),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue