···78787979Commits should conform to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard.
80808181+A script to help create conforming commits is provided in `bin/commit.sh`, or via `task commit`.
8282+8183### Test Coverage
82848385PRs that improve the test coverage are encouraged.
···11+#!/usr/bin/env bash
22+33+set -euo pipefail
44+55+# Create commit interactively
66+77+# conforms commits to https://www.conventionalcommits.org/en/v1.0.0/ standards
88+99+# TODO: add support for breaking change
1010+1111+# Check if there are any staged changes
1212+if [[ -z $(git diff --staged --name-only) ]]; then
1313+ gum style --foreground=1 --bold "No staged changes."
1414+ exit 0
1515+fi
1616+1717+# Print the staged files
1818+gum style --foreground=5 "Staged files:"
1919+git diff --staged --name-status
2020+2121+gum confirm "Show full diff?" && git diff --staged
2222+2323+# Runs pre-commit on all staged files
2424+if [ -x "$(command -v pre-commit)" ]; then
2525+ gum style --foreground=5 "Run pre-commit:"
2626+ pre-commit run
2727+fi
2828+2929+gum style --foreground=5 "Configure commit message:"
3030+3131+TYPE=$(gum choose "help" "breaking" "build" "change" "chore" "ci" "deprecate" "docs" "feat" "fix" "perf" "refactor" "remove" "revert" "security" "style" "test")
3232+if [ "$TYPE" = "help" ]; then
3333+ # Descriptions largely taken from: https://medium.com/neudesic-innovation/conventional-commits-a-better-way-78d6785c2e08
3434+ echo "# Commit types
3535+## breaking
3636+A commit that has a footer BREAKING CHANGE:, or appends a ! after the
3737+type/scope, introduces a breaking API change (correlating with MAJOR in
3838+semantic versioning). A BREAKING CHANGE can be part of commits of any type.
3939+4040+## build
4141+Changes that affect the build system or external dependencies (example scopes:
4242+nix, rust)
4343+4444+## change
4545+The commit changes the implementation of an existing feature.
4646+4747+## chore
4848+The commit includes a technical or preventative maintenance task that is
4949+necessary for managing the product or the repository, but it is not tied to any
5050+specific feature or user story. For example, releasing the product can be
5151+considered a chore. Regenerating generated code that must be included in the
5252+repository could be a chore.
5353+5454+## ci
5555+Changes to our CI configuration files and scripts
5656+5757+## deprecate
5858+The commit deprecates existing functionality, but does not remove it from the
5959+product.
6060+6161+## docs
6262+The commit adds, updates, or revises documentation that is stored in the
6363+repository.
6464+6565+## feat
6666+A new feature
6767+6868+## fix
6969+A bug fix
7070+7171+## perf
7272+A code change that improves performance, but not functionality.
7373+7474+## refactor
7575+A code change that neither fixes a bug nor adds a feature
7676+7777+## remove
7878+The commit removes a feature from the product. Typically features are
7979+deprecated first for a period of time before being removed. Removing a feature
8080+from the product may be considered a breaking change that will require a major
8181+version number increment.
8282+8383+## revert
8484+Reverts a previous commit
8585+8686+## security
8787+The commit improves the security of the product or resolves a security issue
8888+that has been reported.
8989+9090+## style
9191+Changes that do not affect the meaning of the code (comments, white-space,
9292+formatting, missing semi-colons, etc)
9393+9494+## test
9595+The commit enhances, adds to, revised, or otherwise changes the suite of
9696+automated tests for the product." | gum format | gum pager
9797+9898+ TYPE=$(gum choose "breaking" "build" "change" "chore" "ci" "deprecate" "docs" "feat" "fix" "perf" "refactor" "remove" "revert" "security" "style" "test")
9999+fi
100100+101101+SCOPE=$(gum input --placeholder "scope")
102102+103103+# Since the scope is optional, wrap it in parentheses if it has a value.
104104+test -n "$SCOPE" && SCOPE="($SCOPE)"
105105+106106+# Pre-populate the input with the type(scope): so that the user may change it
107107+SUMMARY=$(gum input --value "$TYPE$SCOPE: " --placeholder "Summary of this change")
108108+DESCRIPTION=$(gum write --placeholder "Details of this change (CTRL+D to finish)")
109109+110110+# Commit these changes
111111+gum confirm "Commit changes?" && git commit -m "$SUMMARY" -m "$DESCRIPTION"