在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:orhun/git-cliff开源软件地址:https://github.com/orhun/git-cliff开源编程语言:Rust 92.1%开源软件介绍:Aboutgit-cliff can generate changelog files from the Git history by utilizing conventional commits as well as regex-powered custom parsers. The changelog template can be customized with a configuration file to match the desired format. Table of ContentsInstallationFrom crates.iogit-cliff can be installed from crates.io: cargo install git-cliff Minimum supported Rust version is Using pacmanIf you are using Arch Linux, git-cliff can be installed from the community repository: pacman -S git-cliff Binary releasesSee the available binaries for different operating systems/architectures from the releases page. * Release tarballs are signed with the following PGP key: 1D2D410A741137EBC544826F4A92FA17B6619297 Build from source
# binary will be located at `target/release/git-cliff`
CARGO_TARGET_DIR=target cargo build --release UsageCommand Line Arguments
Flags:
Options:
Args:
ExamplesThe default configuration file ( # create cliff.toml
git cliff --init Then simply create a changelog at your projects git root directory: # same as running `git-cliff --config cliff.toml --repository .`
# same as running `git-cliff --workdir .`
git cliff Set a tag for the "unreleased" changes: # it doesn't have to be an existing tag
git cliff --tag 1.0.0 Generate a changelog for a certain part of git history: # only takes the latest tag into account
git cliff --latest
# only takes the current tag into account
# useful if you checkout a specific tag (e.g. `git checkout v0.0.1`)
# (requires a tag to be present for the current commit (i.e. HEAD))
git cliff --current
# generate changelog for unreleased commits
git cliff --unreleased
git cliff --unreleased --tag 1.0.0
# generate changelog for a specific commit range
git cliff 4c7b043..a440c6e
git cliff 4c7b043..HEAD
git cliff HEAD~2.. Generate a changelog scoped to a specific directory (useful for monorepos): git cliff --include-path "**/*.toml" --include-path "*.md"
git cliff --exclude-path ".github/*" Generate a changelog that includes yet unexisting commit messages: commit_msg="chore(release): update CHANGELOG.md for 1.0.0"
# You might need to include the commit messages that do not exist
# for testing purposes or solving the chicken-egg problem.
git cliff --with-commit "$commit_msg" -o CHANGELOG.md
git add CHANGELOG.md && git commit -m "$commit_msg" Sort the commits inside sections: # The oldest commit will be on top.
# (default)
git cliff --sort oldest
# The newest commit will be on top.
git cliff --sort newest Sort the tags in chronological order: # Process in chronological order instead of topological.
git cliff --date-order Save the changelog file to the specified file: git cliff --output CHANGELOG.md Print the changelog context as JSON: # print context to stdout
git cliff --context
# save context to a file
git cliff --context --output context.json Prepend new changes to an existing changelog file: # 1- changelog header is removed from CHANGELOG.md
# 2- new entries are prepended to CHANGELOG.md without footer part
git cliff --unreleased --tag 1.0.0 --prepend CHANGELOG.md Set/remove the changelog parts: git cliff --body $template --strip footer Also, see the release script of this project which sets the changelog as a message of an annotated tag. DockerThe easiest way of running git-cliff (in the git root directory with configuration file present) is to use the available tags from Docker Hub: docker run -t -v "$(pwd)/.git":/app/ orhunp/git-cliff:latest Or you can use the image from the GitHub Package Registry: docker run -t -v "$(pwd)/.git":/app/ docker.pkg.github.com/orhun/git-cliff/git-cliff:latest Also, you can build the image yourself using GitHub Actionsgit-cliff-actionIt is possible to generate changelogs using GitHub Actions via git-cliff-action. - name: Generate a changelog
uses: orhun/git-cliff-action@v1
with:
config: cliff.toml
args: --verbose
env:
OUTPUT: CHANGELOG.md See the repository for other examples. Also, see the continuous deployment workflow of this project which sets the release notes for GitHub releases using this action. setup-git-cliffThere is also another GitHub Action which is setup-git-cliff. While - name: Check out repository
uses: actions/checkout@v2
- name: Set up git-cliff
uses: kenji-miyake/setup-git-cliff@v1
- name: Run git-cliff
run: |
git cliff See a practical example here. GitLab CI/CDIt is possible to generate changelogs using GitLab CI/CD. This minimal example creates artifacts that can be used on another job. - changelog:
image:
name: orhunp/git-cliff:latest
entrypoint: [""]
variables:
GIT_STRATEGY: clone # clone entire repo instead of reusing workspace
GIT_DEPTH: 0 # avoid shallow clone to give cliff all the info it needs
stage: doc
script:
- git-cliff -r . > CHANGELOG.md
artifacts:
paths:
- CHANGELOG.md Please note that the stage is Configuration Filegit-cliff configuration file supports TOML (preferred) and YAML formats. The configuration file is read from
See config/cliff.toml for the default configuration values. changelogThis section contains the configuration options for changelog generation. [changelog]
header = "Changelog"
body = """
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {{ commit.message | upper_first }}
{% endfor %}
{% endfor %}
"""
trim = true
footer = "<!-- generated by git-cliff -->" headerHeader text that will be added to the beginning of the changelog. bodyBody template that represents a single release in the changelog. See templating for more detail. trimIf set to It is useful for adding indentation to the template for readability, as shown in the example. footerFooter text that will be added to the end of the changelog. gitThis section contains the parsing and git related configuration options. [git]
conventional_commits = true
filter_unconventional = true
commit_parsers = [
{ message = "^feat", group = "Features"},
{ message = "^fix", group = "Bug Fixes"},
{ message = "^doc", group = "Documentation"},
{ message = "^perf", group = "Performance"},
{ message = "^refactor", group = "Refactor"},
{ message = "^style", group = "Styling"},
{ message = "^test", group = "Testing"},
]
filter_commits = false
tag_pattern = "v[0-9]*"
skip_tags = "v0.1.0-beta.1"
ignore_tags = ""
date_order = false
sort_commits = "oldest"
link_parsers = [
{ pattern = "#(\\d+)", href = "https://github.com/orhun/git-cliff/issues/$1"},
{ pattern = "RFC(\\d+)", text = "ietf-rfc$1", href = "https://datatracker.ietf.org/doc/html/rfc$1"},
] conventional_commitsIf set to
e.g. filter_unconventionalIf set to conventional_commits = true
filter_unconventional = false
commit_parsers = [
{ message = ".*", group = "Other", default_scope = "other"},
] With the configuration above, conventional commits are parsed as usual and unconventional commits will be also included in the changelog as "Other". To completely exclude unconventional commits from the changelog: # default behaviour
conventional_commits = true
filter_unconventional = true To include any type of commit in the changelog without parsing: conventional_commits = false
filter_unconventional = false commit_preprocessorsAn array of commit preprocessors for manipulating the commit messages before parsing/grouping them. These regex-based preprocessors can be used for removing or selecting certain parts of the commit message/body to be used in the following processes. Examples:
Custom OS commands can also be used for modifying the commit messages:
This is useful when you want to filter/encode messages using external commands. In the example above, pandoc is used to convert each commit message that matches the given A more fun example would be reversing the each commit message:
commit_parsersAn array of commit parsers for determining the commit groups by using regex. Examples:
filter_commitsIf set to tag_patternA glob pattern for matching the git tags. e.g. It processes the same tags as the output of the following git command: git tag --list 'v[0-9]*' skip_tagsA regex for skip processing the matched tags. ignore_tagsA regex for ignore processing the matched tags. While |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论