Make changelog generator strict
Make the changelog generator fail if commits don't contain metadata. type: changed pr: https://github.com/casey/intermodal/pull/341
This commit is contained in:
parent
c33446b481
commit
92748f9fd4
|
@ -4,7 +4,8 @@ Changelog
|
|||
|
||||
UNRELEASED - 2020-04-08
|
||||
-----------------------
|
||||
- :wrench: [`xxxxxxxxxxxx`](https://github.com/casey/intermodal/commits/master) Generate changelog from git history ([#337](https://github.com/casey/intermodal/pull/337)) - Fixes [#336](https://github.com/casey/intermodal/issues/336) - _Casey Rodarmor <casey@rodarmor.com>_
|
||||
- :zap: [`xxxxxxxxxxxx`](https://github.com/casey/intermodal/commits/master) Make changelog generator strict ([#341](https://github.com/casey/intermodal/pull/341)) - _Casey Rodarmor <casey@rodarmor.com>_
|
||||
- :wrench: [`c33446b48135`](https://github.com/casey/intermodal/commit/c33446b481351009fc16335cbcd66ff2c2b7985e) Generate changelog from git history ([#337](https://github.com/casey/intermodal/pull/337)) - Fixes [#336](https://github.com/casey/intermodal/issues/336) - _Casey Rodarmor <casey@rodarmor.com>_
|
||||
- :art: [`6edab1fa3fa8`](https://github.com/casey/intermodal/commit/6edab1fa3fa8461ac4ca02466a04b0f14e42dfc0) Use `TestEnv::assert_ok` everywhere - Fixes [#330](https://github.com/casey/intermodal/issues/330) - _Casey Rodarmor <casey@rodarmor.com>_
|
||||
- :zap: [`8e3f5516aff8`](https://github.com/casey/intermodal/commit/8e3f5516aff8c89289203a2bc1b46505410c5f1f) Use attractive paths in user-facing messages - Fixes [#252](https://github.com/casey/intermodal/issues/252), [#332](https://github.com/casey/intermodal/issues/332) - _Casey Rodarmor <casey@rodarmor.com>_
|
||||
- :bug: [`1cfc0214536c`](https://github.com/casey/intermodal/commit/1cfc0214536c607fff7c29d9e878cbcd7f3a9ffc) Forbid empty input, output, and path targets - _Casey Rodarmor <casey@rodarmor.com>_
|
||||
|
|
|
@ -5,7 +5,7 @@ pub(crate) use std::{
|
|||
fs, str,
|
||||
};
|
||||
|
||||
pub(crate) use anyhow::Error;
|
||||
pub(crate) use anyhow::{anyhow, Error};
|
||||
pub(crate) use cargo_toml::Manifest;
|
||||
pub(crate) use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
pub(crate) use fehler::throws;
|
||||
|
|
|
@ -18,7 +18,7 @@ impl Entry {
|
|||
Utc,
|
||||
);
|
||||
|
||||
let metadata = Metadata::from_commit(commit).unwrap_or_default();
|
||||
let metadata = Metadata::from_commit(commit)?;
|
||||
|
||||
Entry {
|
||||
version: version.into(),
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
// TODO:
|
||||
// - parse URL in fixed:
|
||||
// - figure out how to check labels before merge
|
||||
|
||||
use crate::common::*;
|
||||
|
||||
mod changelog;
|
||||
|
|
|
@ -2,8 +2,8 @@ use crate::common::*;
|
|||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub(crate) struct Metadata {
|
||||
#[serde(default, rename = "type")]
|
||||
pub(crate) kind: Option<Kind>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: Kind,
|
||||
#[serde(default)]
|
||||
pub(crate) pr: Option<Url>,
|
||||
#[serde(default)]
|
||||
|
@ -11,37 +11,35 @@ pub(crate) struct Metadata {
|
|||
}
|
||||
|
||||
impl Metadata {
|
||||
#[throws(as Option)]
|
||||
#[throws]
|
||||
pub(crate) fn from_commit(commit: &Commit) -> Metadata {
|
||||
const BLANK: &str = "\n\n";
|
||||
|
||||
let message = String::from_utf8_lossy(commit.message_bytes());
|
||||
|
||||
let blank = message.rfind(BLANK)?;
|
||||
let blank = message
|
||||
.rfind(BLANK)
|
||||
.ok_or_else(|| anyhow!("Commit message missing metadata: {}", message))?;
|
||||
|
||||
let yaml = &message[blank + BLANK.len()..];
|
||||
|
||||
let metadata = serde_yaml::from_str(yaml).ok()?;
|
||||
let metadata = serde_yaml::from_str(yaml)?;
|
||||
|
||||
metadata
|
||||
}
|
||||
|
||||
pub(crate) fn emoji(&self) -> &'static str {
|
||||
if let Some(kind) = self.kind {
|
||||
match kind {
|
||||
Kind::Added => ":sparkles:",
|
||||
Kind::Breaking => ":boom:",
|
||||
Kind::Changed => ":zap:",
|
||||
Kind::Development => ":wrench:",
|
||||
Kind::Distribution => ":package:",
|
||||
Kind::Documentation => ":books:",
|
||||
Kind::Fixed => ":bug:",
|
||||
Kind::Reform => ":art:",
|
||||
Kind::Release => ":bookmark:",
|
||||
Kind::Testing => ":white_check_mark:",
|
||||
}
|
||||
} else {
|
||||
":construction:"
|
||||
match self.kind {
|
||||
Kind::Added => ":sparkles:",
|
||||
Kind::Breaking => ":boom:",
|
||||
Kind::Changed => ":zap:",
|
||||
Kind::Development => ":wrench:",
|
||||
Kind::Distribution => ":package:",
|
||||
Kind::Documentation => ":books:",
|
||||
Kind::Fixed => ":bug:",
|
||||
Kind::Reform => ":art:",
|
||||
Kind::Release => ":bookmark:",
|
||||
Kind::Testing => ":white_check_mark:",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +47,7 @@ impl Metadata {
|
|||
impl Default for Metadata {
|
||||
fn default() -> Metadata {
|
||||
Metadata {
|
||||
kind: None,
|
||||
kind: Kind::Changed,
|
||||
pr: None,
|
||||
fixes: Vec::new(),
|
||||
}
|
||||
|
|
12
justfile
12
justfile
|
@ -24,7 +24,7 @@ push: check
|
|||
git push github
|
||||
|
||||
# clean up feature branch BRANCH
|
||||
done BRANCH=`git rev-parse --abbrev-ref HEAD`:
|
||||
done BRANCH=`git rev-parse --abbrev-ref HEAD`: check
|
||||
git diff --no-ext-diff --quiet --exit-code
|
||||
git push github {{BRANCH}}:master
|
||||
git checkout master
|
||||
|
@ -86,16 +86,19 @@ check-man: man
|
|||
check-minimal-versions:
|
||||
./bin/check-minimal-versions
|
||||
|
||||
check: test clippy lint check-minimal-versions
|
||||
check: test clippy lint check-minimal-versions changelog
|
||||
git diff --no-ext-diff --quiet --exit-code
|
||||
cargo +nightly fmt --all -- --check
|
||||
cargo run --package update-readme toc
|
||||
git diff --no-ext-diff --quiet --exit-code
|
||||
|
||||
draft: push
|
||||
hub pull-request -o --draft
|
||||
|
||||
pr: push
|
||||
hub pull-request -o
|
||||
|
||||
merge:
|
||||
merge: check
|
||||
#!/usr/bin/env bash
|
||||
set -euxo pipefail
|
||||
while ! hub ci-status --verbose; do
|
||||
|
@ -113,6 +116,9 @@ publish: publish-check
|
|||
git push github {{version}}
|
||||
cargo publish
|
||||
|
||||
changelog:
|
||||
cargo run --package changelog update
|
||||
|
||||
# record demo animation
|
||||
record:
|
||||
#!/usr/bin/env bash
|
||||
|
|
Loading…
Reference in New Issue
Block a user