Skip to content

Commit

Permalink
devtools: add pre-push hook check for version mismatch (#112)
Browse files Browse the repository at this point in the history
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
jba committed May 10, 2024
1 parent 9748c02 commit badcf7f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
File renamed without changes.
18 changes: 18 additions & 0 deletions devtools/pre-push-hook.sh
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
2 changes: 1 addition & 1 deletion genai/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package genai

//go:generate ./generate_discovery_client.sh
//go:generate ../devtools/generate_discovery_client.sh

import (
"context"
Expand Down

0 comments on commit badcf7f

Please sign in to comment.