-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from ethereum-optimism/tip/check-optimism-vers…
…ion-match Check optimism version match
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
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,41 @@ | ||
#!/bin/bash | ||
|
||
module_name="github.com/ethereum-optimism/optimism" | ||
submodule_path="rvsol/lib/optimism" | ||
|
||
# Fetch the version from go.mod | ||
go_list_version=$(go list -m -f '{{.Version}}' $module_name) | ||
echo "Version in go.mod: $go_list_version" | ||
|
||
# Go to the submodule directory and get the full commit hash | ||
cd $submodule_path | ||
submodule_version=$(git rev-parse HEAD) | ||
echo "Submodule commit: $submodule_version" | ||
cd .. | ||
|
||
# Extract the commit hash from the go_list_version | ||
# This regex assumes the hash is always after the last hyphen, which is typical for pseudo-versions | ||
go_list_commit=$(echo $go_list_version | sed 's/.*-//') | ||
|
||
# Check if go_list_commit is empty or not | ||
if [ -z "$go_list_commit" ]; then | ||
echo "Error: Extracted commit hash is empty." | ||
exit 1 | ||
fi | ||
|
||
# Ensure that the submodule version is compared properly by extracting only the necessary part | ||
# Adjust the length of submodule_version to match the length of go_list_commit for comparison | ||
length=${#go_list_commit} | ||
if [ $length -eq 0 ]; then | ||
echo "Error: Length of the extracted commit hash is zero." | ||
exit 1 | ||
fi | ||
submodule_commit_part=$(echo $submodule_version | cut -c 1-$length) | ||
|
||
# Compare the two commit parts | ||
if [ "$go_list_commit" == "$submodule_commit_part" ]; then | ||
echo "Versions match." | ||
else | ||
echo "Versions do not match." | ||
exit 1 | ||
fi |
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