Skip fixup commits in changelog

This change Makes the changelog generator ignore fixup commits.

`git commit --fixup` can be used to mark that a commit should be
squashed before merging, which can be done automatically with
`git rebase --autosquash`. Fixup commits have a summary that starts with
`fixup!`

type: development
This commit is contained in:
Casey Rodarmor 2020-04-07 22:21:59 -07:00
parent a395052f7c
commit 03a9935164
No known key found for this signature in database
GPG Key ID: 556186B153EC6FE0
10 changed files with 93 additions and 54 deletions

View File

@ -90,20 +90,20 @@ jobs:
profile: minimal
components: rustfmt
- name: Format
- name: Check Formatting
run: cargo +nightly fmt --all -- --check
- name: Completion Scripts
- name: Check Completion Scripts
if: matrix.os != 'windows-latest'
run: |
./bin/generate-completions
git diff --no-ext-diff --quiet --exit-code
git diff --no-ext-diff --exit-code
- name: Readme
- name: Check Readme Table of Contents
if: matrix.os != 'windows-latest'
run: |
cargo run --package update-readme toc
git diff --no-ext-diff --quiet --exit-code
git diff --no-ext-diff --exit-code
- name: Install `mdbook`
uses: peaceiris/actions-mdbook@v1

View File

@ -4,7 +4,10 @@ Changelog
UNRELEASED - 2020-04-08
-----------------------
- :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: [`xxxxxxxxxxxx`](https://github.com/casey/intermodal/commits/master) Skip fixup commits in changelog - _Casey Rodarmor <casey@rodarmor.com>_
- :art: [`a395052f7c22`](https://github.com/casey/intermodal/commit/a395052f7c226a934cf1b0d75294b1a3146cbeae) Deduplicate progress style string - _Casey Rodarmor <casey@rodarmor.com>_
- :wrench: [`db2a2ac4f556`](https://github.com/casey/intermodal/commit/db2a2ac4f556e7a1a450f9a18d212f082d18fb9d) Refactor demo recipe in justfile into multiple recipes - _Casey Rodarmor <casey@rodarmor.com>_
- :zap: [`92748f9fd4e6`](https://github.com/casey/intermodal/commit/92748f9fd4e6e65c25e82f2a6e41a0b9b82cf4dd) 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>_

28
Cargo.lock generated
View File

@ -369,9 +369,9 @@ dependencies = [
[[package]]
name = "hermit-abi"
version = "0.1.8"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8"
checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e"
dependencies = [
"libc",
]
@ -604,9 +604,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
[[package]]
name = "openssl-sys"
version = "0.9.54"
version = "0.9.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1024c0a59774200a555087a6da3f253a9095a5f344e353b212ac4c8b8e450986"
checksum = "7717097d810a0f2e2323f9e5d11e71608355e24828410b55b9d4f18aa5f9a5d8"
dependencies = [
"autocfg",
"cc",
@ -692,9 +692,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.9"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435"
checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3"
dependencies = [
"unicode-xid",
]
@ -899,9 +899,9 @@ checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc"
[[package]]
name = "snafu"
version = "0.6.3"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48492e4f51c6e679217e80c11290edfdedf3133e358f4f432a6296f4c820f95b"
checksum = "b1ec0ae2ed980f26e1ad62e717feb01df90731df56887b5391a2c79f9f6805be"
dependencies = [
"doc-comment",
"snafu-derive",
@ -909,9 +909,9 @@ dependencies = [
[[package]]
name = "snafu-derive"
version = "0.6.3"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5d1c41856cbfa99befda5034c72539dd9d7dd6f3e61058bdb804ac40715bc2a"
checksum = "0ec32ba84a7a86aeb0bc32fd0c46d31b0285599f68ea72e87eff6127889d99e1"
dependencies = [
"proc-macro2",
"quote",
@ -1051,9 +1051,9 @@ dependencies = [
[[package]]
name = "termios"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625"
checksum = "6f0fcee7b24a25675de40d5bb4de6e41b0df07bc9856295e7e2b3a3600c400c2"
dependencies = [
"libc",
]
@ -1219,9 +1219,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.3"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80"
checksum = "fa515c5163a99cc82bab70fd3bfdd36d827be85de63737b40fcef2ce084a436e"
dependencies = [
"winapi 0.3.8",
]

View File

@ -14,6 +14,13 @@ impl Changelog {
let mut head = true;
loop {
let summary_bytes = current
.summary_bytes()
.ok_or_else(|| anyhow!("Commit had no summary"))?;
let summary = String::from_utf8_lossy(summary_bytes);
if !summary.starts_with("fixup!") {
let manifest_bytes = current
.tree()?
.get_path("Cargo.toml".as_ref())?
@ -27,14 +34,15 @@ impl Changelog {
let entry = Entry::new(&current, manifest.package.unwrap().version.as_ref(), head)?;
head = false;
entries.push(entry);
}
head = false;
match current.parent_count() {
0 => break,
1 => current = current.parent(0)?,
count => panic!("Commit has {} parents", count),
_ => throw!(anyhow!("Commit had multiple parents!")),
}
}

View File

@ -8,11 +8,12 @@ pub(crate) use std::{
pub(crate) use anyhow::{anyhow, Error};
pub(crate) use cargo_toml::Manifest;
pub(crate) use chrono::{DateTime, NaiveDateTime, Utc};
pub(crate) use fehler::throws;
pub(crate) use fehler::{throw, throws};
pub(crate) use git2::{Commit, Repository};
pub(crate) use serde::{Deserialize, Serialize};
pub(crate) use structopt::StructOpt;
pub(crate) use strum_macros::IntoStaticStr;
pub(crate) use strum::VariantNames;
pub(crate) use strum_macros::{EnumVariantNames, IntoStaticStr};
pub(crate) use url::Url;
pub(crate) use crate::{

View File

@ -58,7 +58,7 @@ impl Display for Entry {
write!(
f,
"{} [`{}`]({}) {}",
self.metadata.emoji(),
self.metadata.kind.emoji(),
shorthash,
url,
self.summary

View File

@ -1,13 +1,25 @@
use crate::common::*;
#[derive(
Deserialize, Serialize, Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, IntoStaticStr,
Deserialize,
Serialize,
Debug,
Clone,
Copy,
Eq,
PartialEq,
Ord,
PartialOrd,
IntoStaticStr,
EnumVariantNames,
)]
#[serde(rename_all = "kebab-case")]
#[strum(serialize_all = "kebab-case")]
pub(crate) enum Kind {
Added,
Breaking,
Changed,
Dependencies,
Development,
Distribution,
Documentation,
@ -16,3 +28,21 @@ pub(crate) enum Kind {
Release,
Testing,
}
impl Kind {
pub(crate) fn emoji(self) -> &'static str {
match self {
Self::Added => ":sparkles:",
Self::Breaking => ":boom:",
Self::Changed => ":zap:",
Self::Dependencies => ":arrow_up:",
Self::Development => ":wrench:",
Self::Distribution => ":package:",
Self::Documentation => ":books:",
Self::Fixed => ":bug:",
Self::Reform => ":art:",
Self::Release => ":bookmark:",
Self::Testing => ":white_check_mark:",
}
}
}

View File

@ -27,21 +27,6 @@ impl Metadata {
metadata
}
pub(crate) fn emoji(&self) -> &'static str {
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:",
}
}
}
impl Default for Metadata {

View File

@ -3,6 +3,7 @@ use crate::common::*;
#[derive(StructOpt)]
pub(crate) enum Opt {
IssueTemplate,
Types,
Update,
}
@ -10,6 +11,11 @@ impl Opt {
#[throws]
pub(crate) fn run(self) {
match self {
Self::Types => {
for kind in Kind::VARIANTS {
println!("{}", kind)
}
}
Self::IssueTemplate => {
println!("{}", Metadata::default().to_string());
}

View File

@ -86,7 +86,7 @@ check-man: man
check-minimal-versions:
./bin/check-minimal-versions
check: test clippy lint check-minimal-versions changelog
check: test clippy lint check-minimal-versions changelog-update
git diff --no-ext-diff --quiet --exit-code
cargo +nightly fmt --all -- --check
cargo run --package update-readme toc
@ -116,9 +116,15 @@ publish: publish-check
git push github {{version}}
cargo publish
changelog:
changelog-update:
cargo run --package changelog update
changelog-types:
cargo run --package changelog types
changelog-issue-template:
cargo run --package changelog issue-template
# record, upload, and render demo animation
demo: demo-record demo-upload demo-render