Skip to content

Commit

Permalink
fix(cosmos): add upgradegaia.sh to apply Gaia source upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Dec 13, 2021
1 parent 2fe7008 commit b9669c5
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions golang/cosmos/upgradegaia.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#! /bin/bash
# 3-way-merge changes from current repo to agoric-sdk/golang/cosmos
#
# Usage: ./upgradegaia.sh <FROM_BRANCH> <TO_BRANCH>
# Such as:
# cd ~/src/gaia
# /path/to/agoric-sdk/golang/cosmos/upgradegaia.sh release/v6.0.0-rc3 release/v6.0.0
set -ueo pipefail

test $# -eq 2 || {
echo "Usage: $0 <FROM_BRANCH> <TO_BRANCH>" 1>&2
exit 1
}

FROM_BRANCH="$1"
TO_BRANCH="$2"

thisdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"
tmp="$(mktemp -dt upgradegaia.XXXXXX)"

echo "Get the Gaia files from $FROM_BRANCH and $TO_BRANCH"
for tag in "$FROM_BRANCH" "$TO_BRANCH"; do
qtag=${tag//\//_}
for root in Makefile app cmd/gaiad; do
case "$root" in
Makefile) echo "$root" ;;
*) git ls-tree --name-only --full-tree -r "$tag:$root" | sed -e "s!^!$root/!" ;;
esac
done | while read -r src; do
# echo "$src"
dst="$tmp/$qtag/$src"
echo "extracting $dst"
mkdir -p "$(dirname "$dst")"
git cat-file blob "$tag:$src" > "$dst"
done
done

echo "Compute 3-way diffs between Gaia and us"
(cd "$tmp/${FROM_BRANCH//\//_}" && find . -type f -print) | \
while read -r src; do
# echo "$src"
case "$src" in
./cmd/gaiad/*) our=${src//cmd\/gaiad/daemon} ;;
*) our=$src ;;
esac

new="$tmp/diff3/$our"
echo "creating $new"
mkdir -p "$(dirname "$new")"
status=0
diff3 -mE \
"$thisdir/$our" \
"$tmp/${FROM_BRANCH//\//_}/$src" \
"$tmp/${TO_BRANCH//\//_}/$src" \
> "$new" || status=$?
if [ $status -ge 2 ]; then
exit "$status"
fi
done

# Display some hints.
echo "=== Now you can run:"
set -x
: cp -a "$tmp/diff3/." "$thisdir/"
: git diff --stat
: git commit -am "Upgrade to \`$TO_BRANCH\`"

0 comments on commit b9669c5

Please sign in to comment.