Add script for updating go.mod to use local plugeth-statediff #3

Merged
roysc merged 5 commits from telackey/ci into main 2023-09-27 07:48:33 +00:00
2 changed files with 11 additions and 6 deletions
Showing only changes of commit 59444de62d - Show all commits

View File

@ -1,6 +1,8 @@
# Note: Top-level package code is shared, but commands are in separate modules to prevent # Note: Top-level package code is shared, but commands are in separate modules to prevent
# go-ethereum import conflicts # go-ethereum import conflicts
ALL := dumpdiff.geth dumpdiff.plugeth dumpdiff.plugeth-parallel
dumpdiff.geth: dumpdiff-geth/* dumpdiff.geth: dumpdiff-geth/*
cd dumpdiff-geth && go build -tags geth -o ../$@ . cd dumpdiff-geth && go build -tags geth -o ../$@ .
@ -11,7 +13,7 @@ dumpdiff.plugeth-parallel:
cd dumpdiff-plugeth-parallel && go build -tags plugeth_parallel -o ../$@ . cd dumpdiff-plugeth-parallel && go build -tags plugeth_parallel -o ../$@ .
clean: clean:
rm -f dumpdiff.geth dumpdiff.plugeth dumpdiff.plugeth-parallel rm -f $(ALL)
all: dumpdiff.geth dumpdiff.plugeth dumpdiff.plugeth-parallel all: $(ALL)
.PHONY: all .PHONY: all

View File

@ -1,7 +1,10 @@
#!/bin/sh #!/bin/sh
# Usage: update-mod.sh <plugeth-statediff-dir> <target-go.mod-dir>
Review

What does cd dir; pwd do here (vs. just dir)?

What does `cd dir; pwd` do here (vs. just `dir`)?
PLUGETH_STATEDIFF_DIR=`echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"` set -u
TARGET_GOMOD_DIR=${2}
PLUGETH_STATEDIFF_DIR=$(readlink -f "$1")
TARGET_GOMOD_DIR=${2}
cd $TARGET_GOMOD_DIR cd $TARGET_GOMOD_DIR
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
@ -17,7 +20,7 @@ if [ $? -eq 0 ]; then
go mod edit --replace "github.com/cerc-io/plugeth-statediff=${PLUGETH_STATEDIFF_DIR}" go mod edit --replace "github.com/cerc-io/plugeth-statediff=${PLUGETH_STATEDIFF_DIR}"
fi fi
for r in `go mod edit --json ${PLUGETH_STATEDIFF_DIR}/go.mod | jq -r '.Replace[] | "\(.Old.Path)=\(.New.Path)@\(.New.Version)"'`; do for r in $(go mod edit --json "${PLUGETH_STATEDIFF_DIR}/go.mod" | jq -r '.Replace[] | "\(.Old.Path)=\(.New.Path)@\(.New.Version)"'); do
orig=$(echo $r | cut -d'=' -f1) orig=$(echo $r | cut -d'=' -f1)
rep=$(echo $r | cut -d'=' -f2 | cut -d'@' -f1) rep=$(echo $r | cut -d'=' -f2 | cut -d'@' -f1)
echo "$CURRENT_REPLACEMENTS" | grep "$orig" | grep "$rep" > /dev/null echo "$CURRENT_REPLACEMENTS" | grep "$orig" | grep "$rep" > /dev/null
@ -28,4 +31,4 @@ for r in `go mod edit --json ${PLUGETH_STATEDIFF_DIR}/go.mod | jq -r '.Replace[]
go mod edit --replace "$r" go mod edit --replace "$r"
Review

So that's how you do that!

So that's how you do that!
done done
go mod tidy -e 2>/dev/null exec go mod tidy -e 2>/dev/null