2022-01-06 12:59:36 +00:00
|
|
|
#!/usr/bin/env bash
|
2023-07-29 10:23:25 +00:00
|
|
|
# beacon_chain
|
|
|
|
# Copyright (c) 2022-2023 Status Research & Development GmbH
|
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2022-01-06 12:59:36 +00:00
|
|
|
set -Eeuo pipefail
|
|
|
|
|
|
|
|
PREV_VERSION=${1}
|
|
|
|
NEXT_VERSION=${2}
|
|
|
|
NIMBUS_SOURCE_DIR=${3}
|
|
|
|
|
|
|
|
TMPDIR1=$(mktemp -d)
|
|
|
|
TMPDIR2=$(mktemp -d)
|
|
|
|
REPO_URL=https://github.com/ethereum/consensus-specs.git
|
2023-12-05 02:34:45 +00:00
|
|
|
VALID=".*\\.\\(md\\|py\\|yaml\\|sol\\)"
|
2022-01-06 12:59:36 +00:00
|
|
|
UNCHANGED_SPEC_FILES=$(comm -12 --check-order <(git clone --branch "${PREV_VERSION}" --config advice.detachedHead=false --depth 1 --quiet "${REPO_URL}" "${TMPDIR1}" && cd "${TMPDIR1}" && find . -type f -regex "${VALID}" -print0 | xargs -0 sha256sum | sort) <(git clone --branch "${NEXT_VERSION}" --config advice.detachedHead=false --depth 1 --quiet "${REPO_URL}" "${TMPDIR2}" && cd "${TMPDIR2}" && find . -type f -regex "${VALID}" -print0 | xargs -0 sha256sum | sort) | awk '{print $2}' | sed -e"s/^\.\///" | shuf)
|
|
|
|
|
2022-03-11 15:03:47 +00:00
|
|
|
# One can use this to automate the search and replace with a tool such as
|
|
|
|
# https://github.com/kcoyner/rpl/, or just a find/sed combination, e.g.,:
|
2022-01-06 12:59:36 +00:00
|
|
|
URL_BASE=https://github.com/ethereum/consensus-specs/blob/
|
|
|
|
FROM=${URL_BASE}${PREV_VERSION}/
|
|
|
|
TO=${URL_BASE}${NEXT_VERSION}/
|
2023-12-05 02:34:45 +00:00
|
|
|
echo "${UNCHANGED_SPEC_FILES}" | xargs -I{} printf "echo Replacing {}\nrpl --quiet --recursive -x.nim -x.md -x.c -x.h ${FROM}{} ${TO}{} ${NIMBUS_SOURCE_DIR} 2>/dev/null\n"
|
2022-01-06 12:59:36 +00:00
|
|
|
|
|
|
|
# rpl's --quiet option does seem broken though.
|