-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
devtools: add pre-push hook check for version mismatch (#112)
Move existing script into a devtools directory. Add a script that when used as a pre-push hook, will check that the version in the code matches the latest version tag.
- Loading branch information
Showing
3 changed files
with
19 additions
and
1 deletion.
There are no files selected for viewing
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
|
||
# This script checks that the version in the code matches the latest version | ||
# tag. | ||
# | ||
# Install as a pre-push hook from the repo root with: | ||
# cp devtools/pre-push-hook.sh .git/hooks/pre-push | ||
|
||
version_file=genai/internal/version.go | ||
latest_tag=$(git tag -l 'v*' | sort -V | tail -1) | ||
code_version=v$(awk '/^const Version/ {print substr($4, 2, length($4)-2)}' $version_file) | ||
|
||
if [[ $latest_tag == $code_version ]]; then | ||
exit 0 | ||
fi | ||
|
||
echo "version $code_version in $version_file does not match latest tag $latest_tag." | ||
exit 1 |
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