Skip to content

Commit 7561a5e

Browse files
Update githook
1 parent b8deccf commit 7561a5e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

.githooks/pre-commit

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/bin/bash
22
# Get latest git tag
33
latest_tag=$(git describe --tags --abbrev=0)
4-
version_from_tag=$(echo "$latest_tag" | grep -o -E '[0-9]+\.[0-9]+\.[0-9]+')
4+
latest_tag_without_v=${latest_tag#"v"}
5+
version_from_tag=$(echo "$latest_tag_without_v" | grep -P '^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$')
56

67
# Get the version from package.json
78
version=$(jq -r '.version' package.json)
89

9-
echo "Latest tag: $latest_tag"
10+
echo "Latest tag: $latest_tag_without_v"
1011
echo "Version from tag: $version_from_tag"
1112
echo "Version from package.json: $version"
1213

@@ -15,3 +16,5 @@ if [ "$version" != "$version_from_tag" ]; then
1516
echo "Version in package.json and tag are not the same"
1617
exit 1
1718
fi
19+
20+
echo "Version in package.json and tag are the same"

0 commit comments

Comments
 (0)