This repository has been archived by the owner on Jan 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Git commit automation #146
Comments
We can even dispense with the template if we just use the #!/bin/bash
# get branch name which should be formatted as <project id>-<ticket number>-<friendly name with words delimited by hyphens>, remove any fix|feat|etc/<username> path prefixes
BRANCH_NAME=$(basename $(git rev-parse --abbrev-ref HEAD))
# separated by hyphens, get the first two groups, which should be project id and ticket number, leave as hyphenated
TICKET_ID=$(echo $BRANCH_NAME | cut -d'-' -f 1,2)
# separated by hyphens, remove first two groups (project id, ticket number) and for the remainder, replace hyphens with spaces
TICKET_NAME=$(echo $BRANCH_NAME | cut -d'-' -f3- | sed s/\-/\ /g)
TICKET_URL="https://raizlabs.atlassian.net/browse/$TICKET_ID"
PREPENDED_MSG=$(cat <<COMMIT_MESSAGE_TEMPLATE
##################################
# So, you want to make a commit? #
##################################
# Please take the time to create a great commit for the benefit of
# future you and other maintainers! See the guidelines for more
# information at https://rpo365.sharepoint.com/:w:/r/sites/RP-Practices/Shared%20Documents/Product%20Engineering/Development%20Guides/Git%20Workflow.docx?d=wfb5201b4c39947b5b5f20a98a2760033&csf=1&e=479EbP.
###########################################################################################
# Commit Subject (50 chars): <feat|fix|test|refact|style|docs|chore>: <short description> #
###########################################################################################
subject
################################################################
# Commit Body (long-form description wrapped to 72 characters) #
################################################################
# <body here>
######################################################################################
# Automated ticket info/url injection (from .git/hooks/prepare-commit-msg, #
# maintained at https://github.com/raizlabs/ios-template/scripts/prepare-commit-msg) #
######################################################################################
$TICKET_NAME: $TICKET_URL
COMMIT_MESSAGE_TEMPLATE
)
echo "$PREPENDED_MSG" > $1 which prepopulated the commit message like so running on my branch: ##################################
# So, you want to make a commit? #
##################################
# Please take the time to create a great commit for the benefit of
# future you and other maintainers! See the guidelines at for more
# information at https://rpo365.sharepoint.com/:w:/r/sites/RP-Practices/Shared%20Documents/Product%20Engineering/Development%20Guides/Git%20Workflow.docx?d=wfb5201b4c39947b5b5f20a98a2760033&csf=1&e=479EbP.
###########################################################################################
# Commit Subject (50 chars): <feat|fix|test|refact|style|docs|chore>: <short description> #
###########################################################################################
subject
################################################################
# Commit Body (long-form description wrapped to 72 characters) #
################################################################
# <body here>
######################################################################################
# Automated ticket info/url injection (from .git/hooks/prepare-commit-msg, #
# maintained at https://github.com/raizlabs/ios-template/scripts/prepare-commit-msg) #
######################################################################################
roundtrip success: https://raizlabs.atlassian.net/browse/XCI-4179 |
Need to do more work on the above to work with the following:
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
.git/hooks/prepare-commit-msg
:... we would need a way to bootstrap these into a developer's local clone, via e.g. a
make init
as mentioned in #129The text was updated successfully, but these errors were encountered: