Last active
April 16, 2023 12:09
-
-
Save Xrayez/607f1e84170381148567b23559a042b4 to your computer and use it in GitHub Desktop.
An example git hook which shows how to append an arbitrary bit of information to a commit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# An example git hook which shows how to append an arbitrary bit of information to a commit. | |
# The following appends some version number to a commit message. | |
# | |
VERSION=$(command --version) # `command` is any executable | |
BUILD="Xrayez" # Some arbitrary name | |
# Ensure that version contains some build name | |
if [[ $VERSION = *"$BUILD"* ]]; then | |
# Append only if not already present in the commit message | |
grep -qs $BUILD "$1" || printf "\n$VERSION" >> "$1" | |
else | |
# Build name is not configured | |
exit -1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment