generated from PlexSheep/rs-base
changelog until last tag
cargo devel CI / cargo CI (push) Successful in 4m14s
Details
cargo devel CI / cargo CI (push) Successful in 4m14s
Details
This commit is contained in:
parent
15d11edac7
commit
6701e86c38
|
@ -22,15 +22,36 @@ impl Changelog {
|
|||
return Ok(None);
|
||||
}
|
||||
let mut cmd = Command::new("git");
|
||||
cmd.arg("log").arg("--oneline").arg("--decorate");
|
||||
cmd.arg("log").arg(format!("{}..HEAD", Self::get_last_tag()?,)).arg("--oneline");
|
||||
let out = cmd.output()?;
|
||||
// FIXME: this does not catch fancy colors
|
||||
let buf = String::from_utf8(out.stdout).map_err(|err|{
|
||||
ChangelogError::GitUTF8Error(err)
|
||||
})?;
|
||||
if !out.status.success() {
|
||||
return Err(
|
||||
ChangelogError::GitBadStatus(out.status, buf).into()
|
||||
)
|
||||
}
|
||||
|
||||
Ok(Some(buf))
|
||||
}
|
||||
|
||||
fn get_last_tag() -> Result<String> {
|
||||
let mut cmd = Command::new("git");
|
||||
cmd.arg("describe").arg("--tags").arg("--abbrev=0");
|
||||
let out = cmd.output()?;
|
||||
let buf = String::from_utf8(out.stdout).map_err(|err|{
|
||||
ChangelogError::GitUTF8Error(err)
|
||||
})?;
|
||||
if !out.status.success() {
|
||||
return Err(
|
||||
ChangelogError::GitBadStatus(out.status, buf).into()
|
||||
)
|
||||
}
|
||||
let buf = buf.replace("\n", "");
|
||||
return Ok(buf)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Changelog {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{path::PathBuf, string::FromUtf8Error};
|
||||
use std::{path::PathBuf, process::ExitStatus, string::FromUtf8Error};
|
||||
|
||||
use anyhow;
|
||||
use thiserror::Error;
|
||||
|
@ -30,6 +30,8 @@ pub enum ChangelogError {
|
|||
GitCommandError,
|
||||
#[error("error while using `git log`, could not format stdout with utf8")]
|
||||
GitUTF8Error(#[from] FromUtf8Error),
|
||||
#[error("git exited with status {0}: {1}")]
|
||||
GitBadStatus(ExitStatus, String),
|
||||
}
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ConfigError {
|
||||
|
|
Loading…
Reference in New Issue