From a912aad8f71921e4f1d808794496efa3efaeb9cf Mon Sep 17 00:00:00 2001 From: Coenraad Human Date: Tue, 4 Jun 2024 11:39:17 +0200 Subject: [PATCH] feat: commit-git-hook option functionality on changelog --- CHANGELOG.md | 641 ++++++++++++++++++++++++++++++++++---- Cargo.toml | 2 +- README.md | 9 +- src/commands/changelog.rs | 29 +- 4 files changed, 611 insertions(+), 70 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75bccf9..cdb9bf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,64 +1,581 @@ # Changelog -## 1.9.0 - -|Version|Commit Type|Description|Breaking Change|Deprecation|Author|Committer| -|---|---|---|---|---|---|---| -|1.9.0|Feature|More accurate release headers for changelog.| | |Coenraad Human |Coenraad Human | -|1.8.0|Feature|Release categories for changelog.| | |Coenraad Human |Coenraad Human | -|1.7.0|Feature|Use gib entrypoint as alias for gib in container.| | |Coenraad Human |Coenraad Human | -|1.6.0|CI|Use entrypoint sh instead of gib directly.| | |Coenraad Human |Coenraad Human | -|1.6.0|Feature|Author and committer on changelog.| | |Coenraad Human |Coenraad Human | -|1.5.3|CI|Manual trigger for version and changelog job.| | |Coenraad Human |Coenraad Human | -|1.5.3|Documentation|Docker information.| | |Coenraad Human |Coenraad Human | -|1.5.2|Fix|Docker permission issues regarding repositories and pipelines.| | |Coenraad Human |Coenraad Human | -|1.5.1|Documentation|New badges and use gib for changelog generation.| | |Coenraad Human |Coenraad Human | -|1.5.0|CI|Remove riscv64 build temporarily.| | |Coenraad Human |Coenraad Human | -|1.5.0|CI|Fix shell being used on changelog job.| | |Coenraad Human |Coenraad Human | -|1.5.0|Feature|Simple changelog generation.| | |Coenraad Human |Coenraad Human | -|1.4.1|Documentation|Changelog.| | |Coenraad Human |Coenraad Human | -|1.4.0|Testing|Conventional commit creation testing.| | |Coenraad Human |Coenraad Human | -|1.4.0|Feature|Conventional commit creation from regex groups.| | |Coenraad Human |Coenraad Human | -|1.3.3|Refactor|Single source of semantic version calculation.| | |Coenraad Human |Coenraad Human | -|1.3.2|Refactor|Share logic between version and changelog commands.| | |Coenraad Human |Coenraad Human | -|1.3.1|Documentation|Changelog addition to readme.| | |Coenraad Human |Coenraad Human | -|1.3.0|Feature|Initial changelog files.| | |Coenraad Human |Coenraad Human | -|1.2.2|Fix|Docker build supported archs for base images.| | |Coenraad Human |Coenraad Human | -|1.2.1|Chore|Better descriptor for scope filter in help menu.| | |Coenraad Human |Coenraad Human | -|1.2.0|Feature|Scope filter to support monorepos.| | |Coenraad Human |Coenraad Human | -|1.1.1|CI|Multi arch build docker tag filtering on jobs new changelog for release.| | |Coenraad Human |Coenraad Human | -|1.1.1|Documentation|Readme.| | |Coenraad Human |Coenraad Human | -|1.1.0|Feature|Alpine docker image for extremely small image size.| | |Coenraad Human |Coenraad Human | -|1.0.3|CI|Cross compile binaries job.| | |Coenraad Human |Coenraad Human | -|1.0.3|CI|Use rust version of gib.| | |Coenraad Human |Coenraad Human | -|1.0.3|CI|Workflow updates.| | |Coenraad Human |Coenraad Human | -|1.0.3|CI|Build and test.| | |Coenraad Human |Coenraad Human | -|1.0.3|Testing|Commit regex and version calculation.| | |Coenraad Human |Coenraad Human | -|1.0.3|Fix|Regular expression for filtering commits.| | |Coenraad Human |Coenraad Human | -|1.0.2|Fix|Regular expression for filtering commits.| | |Coenraad Human |Coenraad Human | -|1.0.1|Refactor|Rust modules.| | |Coenraad Human |Coenraad Human | -|1.0.0|Chore|Licence and recognition of gib introducing breaking changes with move to rust.|X| |Coenraad Human |Coenraad Human | -|0.10.1|Documentation|Docker.| | |Coenraad Human |Coenraad Human | -|0.10.0|Feature|Auto use current directory when p not supplied.| | |Coenraad Human |Coenraad Human | -|0.9.0|CI|Add workflow for calculating version automatically.| | |Coenraad Human |Coenraad Human | -|0.9.0|Feature|Smaller docker image using debian slim.| | |Coenraad Human |Coenraad Human | -|0.8.0|Feature|Regex for ensuring string is valid before processing.| | |Coenraad Human |Coenraad Human | -|0.7.1|Chore|Clean up macos nonsense.| | |Coenraad Human |Coenraad Human | -|0.7.0|Feature|Use rust instead of java.| | |Coenraad Human |Coenraad Human | -|0.6.5|Documentation|Update to include new clap default help option.| | |Coenraad Human |Coenraad Human | -|0.6.4|Chore|Update clap version.| | |Coenraad Human |Coenraad Human | -|0.6.3|Fix|Commit regex filter.| | |Coenraad Human |Coenraad Human | -|0.6.2|Documentation|Readme update.| | |Coenraad Human |Coenraad Human | -|0.6.1|Documentation|Update readme.| | |Coenraad Human |Coenraad Human | -|0.6.0|Feature|Add in major minor and patch option functionality.| | |Coenraad Human |Coenraad Human | -|0.5.1|Fix|Commit returning wrong normalised version.| | |Coenraad Human |Coenraad Human | -|0.5.0|Feature|Utilise clap.| | |Coenraad Human |Coenraad Human | -|0.4.1|Refactor|Remove dead code.| | |Coenraad Human |Coenraad Human | -|0.4.0|Styling|Checkstyle accommodation for long string lines.| | |Coenraad Human |Coenraad Human | -|0.4.0|Feature|Dockerfile and action.| | |Coenraad Human |Coenraad Human | -|0.3.1|Chore|Change logging level.| | |Coenraad Human |Coenraad Human | -|0.3.0|Feature|Add argument for providing git hook commit message.| | |Coenraad Human |Coenraad Human | -|0.2.1|Refactor|Remove unused and clean up.| | |Coenraad Human |Coenraad Human | -|0.2.0|Feature|Improved cli argument parser.| | |Coenraad Human |Coenraad Human | -|0.1.1|Chore|Improve binary build script.| | |Coenraad Human |Coenraad Human | -|0.1.0|Feature|Initial project.| | |Coenraad Human |Coenraad Human | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VersionCommit TypeDescriptionBreaking ChangeDeprecationAuthorCommitter
Unreleased +
1.10.0FeatureCommit git hook option functionality on changelog. Coenraad HumanCoenraad Human
Release: 1.9.0
1.9.0FeatureMore accurate release headers for changelog. Coenraad HumanCoenraad Human
1.8.0FeatureRelease categories for changelog. Coenraad HumanCoenraad Human
1.7.0FeatureUse gib entrypoint as alias for gib in container. Coenraad HumanCoenraad Human
1.6.0CIUse entrypoint sh instead of gib directly. Coenraad HumanCoenraad Human
1.6.0FeatureAuthor and committer on changelog. Coenraad HumanCoenraad Human
1.5.3CIManual trigger for version and changelog job. Coenraad HumanCoenraad Human
1.5.3DocumentationDocker information. Coenraad HumanCoenraad Human
1.5.2FixDocker permission issues regarding repositories and pipelines. Coenraad HumanCoenraad Human
1.5.1DocumentationNew badges and use gib for changelog generation. Coenraad HumanCoenraad Human
1.5.0CIRemove riscv64 build temporarily. Coenraad HumanCoenraad Human
Release: 1.5.0
1.5.0CIFix shell being used on changelog job. Coenraad HumanCoenraad Human
1.5.0FeatureSimple changelog generation. Coenraad HumanCoenraad Human
1.4.1DocumentationChangelog. Coenraad HumanCoenraad Human
1.4.0TestingConventional commit creation testing. Coenraad HumanCoenraad Human
1.4.0FeatureConventional commit creation from regex groups. Coenraad HumanCoenraad Human
1.3.3RefactorSingle source of semantic version calculation. Coenraad HumanCoenraad Human
1.3.2RefactorShare logic between version and changelog commands. Coenraad HumanCoenraad Human
1.3.1DocumentationChangelog addition to readme. Coenraad HumanCoenraad Human
1.3.0FeatureInitial changelog files. Coenraad HumanCoenraad Human
Release: 1.2.2
1.2.2FixDocker build supported archs for base images. Coenraad HumanCoenraad Human
1.2.1ChoreBetter descriptor for scope filter in help menu. Coenraad HumanCoenraad Human
1.2.0FeatureScope filter to support monorepos. Coenraad HumanCoenraad Human
1.1.1CIMulti arch build docker tag filtering on jobs new changelog for release. Coenraad HumanCoenraad Human
1.1.1DocumentationReadme. Coenraad HumanCoenraad Human
1.1.0FeatureAlpine docker image for extremely small image size. Coenraad HumanCoenraad Human
Release: 1.0.4
1.0.3CICross compile binaries job. Coenraad HumanCoenraad Human
1.0.3CIUse rust version of gib. Coenraad HumanCoenraad Human
1.0.3CIWorkflow updates. Coenraad HumanCoenraad Human
1.0.3CIBuild and test. Coenraad HumanCoenraad Human
1.0.3TestingCommit regex and version calculation. Coenraad HumanCoenraad Human
1.0.3FixRegular expression for filtering commits. Coenraad HumanCoenraad Human
1.0.2FixRegular expression for filtering commits. Coenraad HumanCoenraad Human
1.0.1RefactorRust modules. Coenraad HumanCoenraad Human
Release: 1.0.0
1.0.0ChoreLicence and recognition of gib introducing breaking changes with move to rust.X Coenraad HumanCoenraad Human
Release: 0.10.1
0.10.1DocumentationDocker. Coenraad HumanCoenraad Human
0.10.0FeatureAuto use current directory when p not supplied. Coenraad HumanCoenraad Human
0.9.0CIAdd workflow for calculating version automatically. Coenraad HumanCoenraad Human
0.9.0FeatureSmaller docker image using debian slim. Coenraad HumanCoenraad Human
0.8.0FeatureRegex for ensuring string is valid before processing. Coenraad HumanCoenraad Human
0.7.1ChoreClean up macos nonsense. Coenraad HumanCoenraad Human
0.7.0FeatureUse rust instead of java. Coenraad HumanCoenraad Human
Release: 0.6.5
0.6.5DocumentationUpdate to include new clap default help option. Coenraad HumanCoenraad Human
0.6.4ChoreUpdate clap version. Coenraad HumanCoenraad Human
Release: 0.6.3
0.6.3FixCommit regex filter. Coenraad HumanCoenraad Human
0.6.2DocumentationReadme update. Coenraad HumanCoenraad Human
Release: 0.6.1
0.6.1DocumentationUpdate readme. Coenraad HumanCoenraad Human
0.6.0FeatureAdd in major minor and patch option functionality. Coenraad HumanCoenraad Human
0.5.1FixCommit returning wrong normalised version. Coenraad HumanCoenraad Human
0.5.0FeatureUtilise clap. Coenraad HumanCoenraad Human
0.4.1RefactorRemove dead code. Coenraad HumanCoenraad Human
0.4.0StylingCheckstyle accommodation for long string lines. Coenraad HumanCoenraad Human
0.4.0FeatureDockerfile and action. Coenraad HumanCoenraad Human
0.3.1ChoreChange logging level. Coenraad HumanCoenraad Human
0.3.0FeatureAdd argument for providing git hook commit message. Coenraad HumanCoenraad Human
0.2.1RefactorRemove unused and clean up. Coenraad HumanCoenraad Human
0.2.0FeatureImproved cli argument parser. Coenraad HumanCoenraad Human
0.1.1ChoreImprove binary build script. Coenraad HumanCoenraad Human
Release: 0.1.0
0.1.0FeatureInitial project. Coenraad HumanCoenraad Human
diff --git a/Cargo.toml b/Cargo.toml index 978ab99..c0c0934 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gib" -version = "1.9.0" +version = "1.10.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/README.md b/README.md index 1a069a2..6d9f4ff 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ ![Open Source Love](https://badges.frapsoft.com/os/v2/open-source.svg?v=103) [![GitHub license](https://img.shields.io/badge/licence-GPL--3.0-blue)](LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)](.github/CONTRIBUTING.md)[![Image of github-profile-views-counter](https://github.com/coenraadhuman/github-profile-views-counter/blob/master/svg/613868422/badge.svg)](https://github.com/coenraadhuman/github-profile-views-counter/blob/master/readme/613868422/year.md)![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/coenraadhuman/gib/total?label=Github%20Downloads) ![Docker Pulls](https://img.shields.io/docker/pulls/coenraadhuman/gib?label=Docker%20Hub%20Pulls) - - # gib Gibberish git history analyser, a terminal utility that uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) to analyse your git history. @@ -107,14 +105,13 @@ $ docker run -v $PWD:/app ghcr.io/coenraadhuman/gib:latest version $ 0.10.1 ``` -User run example: ```bash -$ docker run --user $UID -v $PWD:/app ghcr.io/coenraadhuman/gib:latest version -p /app -$ 0.10.1 +# The default work directory is /app +$ docker run -v $PWD:/app ghcr.io/coenraadhuman/gib:latest changelog > CHANGELOG.md ``` ### Further Reading - [Semantic Version](https://semver.org/) - [Conventional Commits](https://www.conventionalcommits.org/en/) -- [Conventional Commit Types](https://github.com/semantic-gitlog/semantic-gitlog/blob/master/docs/en-us/fundamentals/commit-types.md) +- [Conventional Commit Types](https://github.com/semantic-gitlog/semantic-gitlog/blob/master/docs/en-us/fundamentals/commit-types.md) \ No newline at end of file diff --git a/src/commands/changelog.rs b/src/commands/changelog.rs index 4fcc94f..32df06a 100644 --- a/src/commands/changelog.rs +++ b/src/commands/changelog.rs @@ -7,7 +7,7 @@ use crate::semantic::{add_commit_to_version, Version}; // Todo: find a nice template engine for Rust to create the changelog document: // Todo: use map for tag associated with commits on current branch: -pub fn run(path: Option, _commit_git_hook: Option, scope_filter: Option) { +pub fn run(path: Option, commit_git_hook: Option, scope_filter: Option) { let commits = retrieve_branch_commits(path.clone()); let optional_oid_commit_tag_map = retrieve_commit_tag_map(path); @@ -63,6 +63,33 @@ pub fn run(path: Option, _commit_git_hook: Option, scope_filter: } } + match commit_git_hook { + Some(ref user_commit) => { + match create_conventional_commit(user_commit) { + Some(user_conventional_commit) => { + version = add_commit_to_version(&version, create_conventional_commit(user_commit), scope_filter.clone()); + + // Add commit to log: + simple_changelog.insert_str(0, " \n"); + simple_changelog.insert_str(0, &format!(" {}\n", "Unknown")); + simple_changelog.insert_str(0, &format!(" {}\n", "Unknown")); + simple_changelog.insert_str(0, &format!(" {}\n", if user_conventional_commit.is_deprecrated { 'X' } else { ' ' })); + simple_changelog.insert_str(0, &format!(" {}\n", if user_conventional_commit.is_breaking { 'X' } else { ' ' })); + simple_changelog.insert_str(0, &format!(" {}.\n", user_conventional_commit.commit_description.to_sentence_case())); + simple_changelog.insert_str(0, &format!(" {}\n", user_conventional_commit.commit_type)); + simple_changelog.insert_str(0, &format!(" {}\n", version.format())); + simple_changelog.insert_str(0, " \n"); + + // Will always be unreleased: + unreleased_count = unreleased_count + 1; + }, + // Commit invalid ignore: + None => {}, + } + }, + None => todo!(), + } + if unreleased_count != 0 { simple_changelog.insert_str(0, " \n"); simple_changelog.insert_str(0, " Unreleased\n");