commit.sh
This file
Path
examples/commit.sh
28 lines · 1.1 KiB · Shell
Last changed by
Not known.
History of this fileTake it
1234567891011121314151617181920212223242526272829#!/bin/sh
# This script is used to write a conventional commit message.# It prompts the user to choose the type of commit as specified in the# conventional commit spec. And then prompts for the summary and detailed# description of the message and uses the values provided. as the summary and# details of the message.## If you want to add a simpler version of this script to your dotfiles, use:## alias gcm='git commit -m "$(gum input)" -m "$(gum write)"'
# if [ -z "$(git status -s -uno | grep -v '^ ' | awk '{print $2}')" ]; then# gum confirm "Stage all?" && git add .# fi
TYPE=$(gum choose "fix" "feat" "docs" "style" "refactor" "test" "chore" "revert")SCOPE=$(gum input --placeholder "scope")
# Since the scope is optional, wrap it in parentheses if it has a value.test -n "$SCOPE" && SCOPE="($SCOPE)"
# Pre-populate the input with the type(scope): so that the user may change itSUMMARY=$(gum input --value "$TYPE$SCOPE: " --placeholder "Summary of this change")DESCRIPTION=$(gum write --placeholder "Details of this change")
# Commit these changes if user confirmsgum confirm "Commit changes?" && git commit -m "$SUMMARY" -m "$DESCRIPTION"