Skip to content

Commit 0e90f76

Browse files
Add pre-push hook
Issue gh-15028
1 parent 33a108f commit 0e90f76

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

git/hooks/pre-push

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
# .git/hooks/pre-push
3+
4+
echo "Verifying if the target branch matches the version in gradle.properties"
5+
6+
# Get the current branch name
7+
branch_name=$(git symbolic-ref --short HEAD)
8+
9+
# Verify if branch name ends with '.x'
10+
if [[ ! "$branch_name" =~ \.x$ ]]; then
11+
echo "Branch name '$branch_name' does not end with '.x', skipping verification."
12+
exit 0
13+
fi
14+
15+
# Extract version from gradle.properties
16+
version=$(cat gradle.properties | grep 'version=' | awk -F'=' '{print $2}')
17+
18+
# Extract the version prefix from the version
19+
version_prefix=$(echo $version | cut -d'-' -f1 | sed 's/\.[0-9]*$//')
20+
21+
# Check if branch starts with the version prefix
22+
if [[ "$branch_name" != "$version_prefix"* ]]; then
23+
echo "Branch name '$branch_name' does not match the version prefix '$version_prefix' in gradle.properties. Make sure you are pushing to the right branch."
24+
exit 1
25+
fi
26+
27+
exit 0

0 commit comments

Comments
 (0)