Skip to content

Repository files navigation

Clean Git History

crates.ioConventional CommitsLicense

A Git history linter to ensure it stays clean for those who prefer a linear history without merge commits.

Usage

Clean Git History checks the commits from the current HEAD(inclusively) till a provided Git reference(exclusively). This reference can be a branch, commit or tag, just provide it as the final argument.

e.g.

clean_git_history "origin/main"
clean_git_history "v0.2.0"
clean_git_history "bac789b4cc5fce9a26d6805c5da4bf17241523f1"

Examples

GitHub Actions

name: Git Historyon: pull_requestjobs:
clean:
name: Cleanruns-on: ubuntu-latestcontainer:
image: ghcr.io/developerc286/clean_git_history:v1.2.0steps:
- name: Checkout code.uses: actions/checkout@v5with:
ref: ${{ github.event.pull_request.head.sha }}fetch-depth: 0
- name: Check clean Git history.run: clean_git_history "origin/${{ github.base_ref }}"

GitLab CI

clean-git-history-checking:
stage: clean-git-history-checkingimage: ghcr.io/developerc286/clean_git_history:v1.2.0script:
- clean_git_history "origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}"rules:
- if: $CI_MERGE_REQUEST_ID

Installation

Binary

Statically linked compiled binaries are available for download. Visit the releases page at https://github.com/DeveloperC286/clean_git_history/releases to see all the releases, the release notes contains links to binary downloads for various architectures.

version="v1.2.0"&& wget -O - "https://github.com/DeveloperC286/clean_git_history/releases/download/${version}/x86_64-unknown-linux-musl.tar.gz"| tar xz --directory "/usr/bin/"

Cargo

Cargo is the Rust package manager, the install sub-command pulls from crates.io and then compiles the binary locally, placing the compiled binary at ${HOME}/.cargo/bin/clean_git_history.

cargo install clean_git_history

By default it installs the latest version at the time of execution. You can specify a specific version to install using the --version argument. For certain environments such as CICD etc you may want to pin the version.

e.g.

cargo install clean_git_history --version "1.2.0"

See https://doc.rust-lang.org/cargo/commands/cargo-install.html#install-options for more detailed documentation.

Docker

You can use the Docker image published to ghcr.io/developerc286/clean_git_history.

docker run --rm -v $(pwd):/workspace -w /workspace ghcr.io/developerc286/clean_git_history:v1.2.0 origin/HEAD

Issues/Feature Requests

Report issues or request features on our GitHub Issues.

About

A Git history linter to ensure it stays clean for those who prefer a linear history without merge commits.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages