this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at f7bbb7638e8ed85d5c92d23cfdcf38ed665b3b21 111 lines 3.6 kB view raw
1#!/usr/bin/env bash 2 3set -euo pipefail 4 5# Create commit interactively 6 7# conforms commits to https://www.conventionalcommits.org/en/v1.0.0/ standards 8 9# TODO: add support for breaking change 10 11# Check if there are any staged changes 12if [[ -z $(git diff --staged --name-only) ]]; then 13 gum style --foreground=1 --bold "No staged changes." 14 exit 0 15fi 16 17# Print the staged files 18gum style --foreground=5 "Staged files:" 19git diff --staged --name-status 20 21gum confirm "Show full diff?" && git diff --staged 22 23# Runs pre-commit on all staged files 24if [ -x "$(command -v pre-commit)" ]; then 25 gum style --foreground=5 "Run pre-commit:" 26 pre-commit run 27fi 28 29gum style --foreground=5 "Configure commit message:" 30 31TYPE=$(gum choose "help" "breaking" "build" "change" "chore" "ci" "deprecate" "docs" "feat" "fix" "perf" "refactor" "remove" "revert" "security" "style" "test") 32if [ "$TYPE" = "help" ]; then 33 # Descriptions largely taken from: https://medium.com/neudesic-innovation/conventional-commits-a-better-way-78d6785c2e08 34 echo "# Commit types 35## breaking 36A commit that has a footer BREAKING CHANGE:, or appends a ! after the 37type/scope, introduces a breaking API change (correlating with MAJOR in 38semantic versioning). A BREAKING CHANGE can be part of commits of any type. 39 40## build 41Changes that affect the build system or external dependencies (example scopes: 42nix, rust) 43 44## change 45The commit changes the implementation of an existing feature. 46 47## chore 48The commit includes a technical or preventative maintenance task that is 49necessary for managing the product or the repository, but it is not tied to any 50specific feature or user story. For example, releasing the product can be 51considered a chore. Regenerating generated code that must be included in the 52repository could be a chore. 53 54## ci 55Changes to our CI configuration files and scripts 56 57## deprecate 58The commit deprecates existing functionality, but does not remove it from the 59product. 60 61## docs 62The commit adds, updates, or revises documentation that is stored in the 63repository. 64 65## feat 66A new feature 67 68## fix 69A bug fix 70 71## perf 72A code change that improves performance, but not functionality. 73 74## refactor 75A code change that neither fixes a bug nor adds a feature 76 77## remove 78The commit removes a feature from the product. Typically features are 79deprecated first for a period of time before being removed. Removing a feature 80from the product may be considered a breaking change that will require a major 81version number increment. 82 83## revert 84Reverts a previous commit 85 86## security 87The commit improves the security of the product or resolves a security issue 88that has been reported. 89 90## style 91Changes that do not affect the meaning of the code (comments, white-space, 92formatting, missing semi-colons, etc) 93 94## test 95The commit enhances, adds to, revised, or otherwise changes the suite of 96automated tests for the product." | gum format | gum pager 97 98 TYPE=$(gum choose "breaking" "build" "change" "chore" "ci" "deprecate" "docs" "feat" "fix" "perf" "refactor" "remove" "revert" "security" "style" "test") 99fi 100 101SCOPE=$(gum input --placeholder "scope") 102 103# Since the scope is optional, wrap it in parentheses if it has a value. 104test -n "$SCOPE" && SCOPE="($SCOPE)" 105 106# Pre-populate the input with the type(scope): so that the user may change it 107SUMMARY=$(gum input --value "$TYPE$SCOPE: " --placeholder "Summary of this change") 108DESCRIPTION=$(gum write --placeholder "Details of this change (CTRL+D to finish)") 109 110# Commit these changes 111gum confirm "Commit changes?" && git commit -m "$SUMMARY" -m "$DESCRIPTION"