Crates.io | gen-changelog |
lib.rs | gen-changelog |
version | 0.1.0 |
created_at | 2025-08-22 07:04:27.266119+00 |
updated_at | 2025-09-16 21:48:47.259109+00 |
description | Generate a change log based on the git commits compatible with keep-a-changelog and using conventional commits to categorise commits. |
homepage | |
repository | https://github.com/jerus-org/gen-changelog |
max_upload_size | |
id | 1805991 |
size | 237,514 |
Gen-changelog is a release tool that generates changelogs in the Keep a Changelog format. It analyses a repository's commit history and uses conventional commit types to categorise and filter commits for inclusion in the changelog.
The gen-changelog
library provides comprehensive changelog generation from Git repositories using conventional commit messages. The library centres around the ChangeLogConfig
and ChangeLog
structs for configuring and constructing changelog documents.
Add the library to your program's Cargo.toml
using cargo add
:
$ cargo add gen-changelog
Or by configuring the dependencies manually in Cargo.toml
:
[dependencies]
gen-changelog = "0.0.8"
The library provides sensible defaults for conventional commit types:
Group | Commit Types | Published |
---|---|---|
Added | feat | ✓ |
Fixed | fix | ✓ |
Changed | refactor | ✓ |
Security | security, dependency | ✗ |
Build | build | ✗ |
Documentation | doc, docs | ✗ |
Chore | chore | ✗ |
Continuous Integration | ci | ✗ |
Testing | test | ✗ |
Deprecated | deprecated | ✗ |
Removed | removed | ✗ |
Miscellaneous | misc | ✗ |
By default, only Added
, Fixed
, Changed
, and Security
groups are published in the changelog.
The library looks for a gen-changelog.toml
configuration file. Example structure:
## Controls the number of changelog sections to display.
display-sections = "all"
## Defines the display order of groups in the changelog.
[headings]
1 = "Added"
2 = "Fixed"
3 = "Changed"
4 = "Security"
## Group tables define the third-level headings used to organize commits.
[groups.Added]
name = "Added"
publish = true
cc-types = ["feat"]
[groups.Fixed]
name = "Fixed"
publish = true
cc-types = ["fix"]
## ... additional groups
use gen_changelog::{ChangeLog, ChangeLogConfig};
use git2::Repository;
fn generate_changelog() -> Result<(), Box<dyn std::error::Error>> {
let repo = Repository::open(".")?;
let config = ChangeLogConfig::from_file_or_default()?;
let changelog = ChangeLog::builder()
.with_config(config)
.with_header("Changelog", &[
"All notable changes to this project will be documented in this file.",
"The format is based on Keep a Changelog."
])
.with_repository(&repo)?
.build();
changelog.save()?;
Ok(())
}
use gen_changelog::{ChangeLog, ChangeLogConfig};
use git2::Repository;
fn generate_custom_changelog() -> Result<(), Box<dyn std::error::Error>> {
let repo = Repository::open(".")?;
let mut config = ChangeLogConfig::from_file_or_default()?;
// Add custom groups to be published
config.add_commit_groups(&["Documentation".to_string(), "Testing".to_string()]);
// Limit to last 5 releases
config.set_display_sections(Some(5));
let changelog = ChangeLog::builder()
.with_config(config)
.with_summary_flag(true)
.with_repository(&repo)?
.build();
changelog.save()?;
Ok(())
}
use gen_changelog::{ChangeLog, ChangeLogConfig};
use git2::Repository;
fn prepare_release(version: &str) -> Result<(), Box<dyn std::error::Error>> {
let repo = Repository::open(".")?;
let config = ChangeLogConfig::from_file_or_default()?;
let changelog = ChangeLog::builder()
.with_config(config)
.with_repository(&repo)?
.update_unreleased_to_next_version(Some(&version.to_string()))
.build();
changelog.save()?;
Ok(())
}
The library automatically detects GitHub repositories and generates appropriate comparison and release links in the changelog output.## Gen-changelog CLI
A command-line tool that generates changelogs from git commits using conventional commit messages and keep-a-changelog formatting.
Install gen-changelog using Cargo:
cargo install gen-changelog
Gen-changelog CLI automatically generates changelogs by analysing your git commit history. It uses conventional commit patterns to categorize changes and outputs them in a format compatible with Keep a Changelog.
gen-changelog --help
Generate a change log based on the git commits compatible
with keep-a-changelog and using conventional commits to categorise commits.
Usage: gen-changelog [OPTIONS] [COMMAND]
Commands:
generate Generate changelog from git commits
config Manage configuration settings
help Print this message or the help of the given subcommand(s)
Options:
-v, --verbose... Increase logging verbosity
-q, --quiet... Decrease logging verbosity
-h, --help Print help
-V, --version Print version
generate
- Generate ChangelogCreates a changelog file based on your repository's commit history.
gen-changelog generate [OPTIONS]
Option | Description | Default |
---|---|---|
-n, --next-version <VERSION> |
Version number for unreleased changes | - |
-s, --sections <NUMBER> |
Number of version sections to include in changelog | All |
-c, --config-file <FILE> |
Path to configuration file | - |
-r, --repo-dir <PATH> |
Path to git repository | . (current directory) |
-d, --display-summaries |
Show commit summaries in output | - |
--add-groups <GROUPS> |
Include additional commit type groups | - |
--remove-groups <GROUPS> |
Exclude specific commit type groups | - |
Generate a changelog for the current repository:
gen-changelog generate
Generate with a specific next version:
gen-changelog generate --next-version "2.1.0"
Limit to the last 3 releases and show commit summaries:
gen-changelog generate --sections 3 --display-summaries
config
- Configuration ManagementManage configuration settings for gen-changelog.
gen-changelog config [OPTIONS]
Option | Description | Default |
---|---|---|
-s, --save |
Save current configuration to file | - |
-f, --file <FILE> |
Configuration file name | gen-changelog.toml |
-p, --show |
Display current configuration | - |
Show the current configuration:
gen-changelog config --show
Save configuration to the default file:
gen-changelog config --save
Save configuration to a custom file:
gen-changelog config --save --file my-config.toml
Gen-changelog CLI uses a TOML configuration file to customize its behaviour. The default configuration file is gen-changelog.toml
in your project root.
To generate a configuration file with default settings and helpful comments:
gen-changelog config --save
gen-changelog recognizes standard conventional commit types:
Control output verbosity with logging options:
-v, --verbose
: Increase verbosity (can be used multiple times: -vv
, -vvv
)-q, --quiet
: Decrease verbosity (can be used multiple times: -qq
, -qqq
)For command-specific help, use:
gen-changelog <command> --help
For general help and available commands:
gen-changelog --help
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.