Add staged file check for commit example

This commit is contained in:
Mathew Payne 2023-01-28 14:23:09 +00:00 committed by Maas Lalani
parent 46dee843db
commit 214a9f8b88
No known key found for this signature in database
GPG key ID: 5A6ED5CBF1A0A000

View file

@ -20,5 +20,11 @@ test -n "$SCOPE" && SCOPE="($SCOPE)"
SUMMARY=$(gum input --value "$TYPE$SCOPE: " --placeholder "Summary of this change")
DESCRIPTION=$(gum write --placeholder "Details of this change")
# Check if any staged files are present. If there are non, ask the user if
# they want to commit all files
if [ -z "$(git status -s -uno | grep -v '^ ' | awk '{print $2}')" ]; then
gum confirm "No staged files. Commit all?" && git add .
fi
# Commit these changes if user confirms
gum confirm "Commit changes?" && git commit -m "$SUMMARY" -m "$DESCRIPTION"