-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
424 additions
and
1 deletion.
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,61 @@ | ||
#!/bin/bash | ||
|
||
set -oue pipefail | ||
|
||
COSMOSSDK_BRANCH=${COSMOSSDK_BRANCH:-refs/heads/release/v0.50.x} | ||
|
||
# Function to get the latest commit SHA for a given repo and branch | ||
get_latest_commit() { | ||
local repo=$1 | ||
local branch=$2 | ||
git ls-remote "https://github.com/${repo}.git" "${branch}" | cut -f1 | ||
} | ||
|
||
# Function to get pseudo-version from commit SHA | ||
get_pseudo_version() { | ||
local repo=$1 | ||
local commit_sha=$2 | ||
|
||
pseudo_version=$(go list -m -f '{{.Version}}' $module@$commit_sha) | ||
|
||
echo "${pseudo_version}" | ||
} | ||
|
||
# Extract module paths and versions from go.mod on current folder | ||
modules=$(go mod edit --json | jq -r '.Require[] | select(.Path | contains("/")) | .Path') | ||
|
||
latest_commit_main=$(get_latest_commit "cosmos/cosmos-sdk" "main") | ||
echo "cosmos/cosmos-sdk main latest_commit: $latest_commit_main" | ||
latest_commit_branch=$(get_latest_commit "cosmos/cosmos-sdk" "$COSMOSSDK_BRANCH") | ||
echo "cosmos/cosmos-sdk $COSMOSSDK_BRANCH latest_commit: $latest_commit_branch" | ||
|
||
# Version override logic | ||
for module in $modules; do | ||
|
||
echo "module: $module" | ||
|
||
if [[ $module =~ "cosmossdk.io" ]]; then | ||
# modules that need to follow HEAD on main | ||
if [[ $module =~ "log" ]] || [[ $module =~ "math" ]] || [[ $module =~ "depinject" ]] || [[ $module =~ "core/testing" ]] || [[ $module =~ "x/accounts" ]] | [[ $module =~ "x/authz" ]]; then | ||
pseudo_version=$(get_pseudo_version "cosmos/cosmos-sdk" $latest_commit_main) | ||
echo "Updating $module to pseudo-version $pseudo_version" | ||
go mod edit -replace=$module=$module@$pseudo_version | ||
go mod download $module@$pseudo_version | ||
else | ||
# modules that need to follow HEAD on release branch | ||
pseudo_version=$(get_pseudo_version "cosmos/cosmos-sdk" $latest_commit_branch) | ||
echo "Updating $module to pseudo-version $pseudo_version" | ||
go mod edit -replace=$module=$module@$pseudo_version | ||
go mod download $module@$pseudo_version | ||
fi | ||
elif [[ $module == "github.com/cosmos/cosmos-sdk" ]]; then | ||
# modules that need to follow HEAD on release branch | ||
pseudo_version=$(get_pseudo_version "cosmos/cosmos-sdk" $latest_commit_branch) | ||
echo "Updating $module to pseudo-version $pseudo_version" | ||
go mod edit -replace=$module=$module@$pseudo_version | ||
go mod download $module@$pseudo_version | ||
fi | ||
done | ||
|
||
go mod verify | ||
go mod tidy |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.