-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
script to automate aspects of spec URL updating (#3252)
- Loading branch information
Showing
1 changed file
with
21 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,21 @@ | ||
#!/usr/bin/env bash | ||
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 | ||
VALID=".*\\.\\(md\\|py\\)" | ||
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) | ||
|
||
# One can use this to automate the search andreplace with a tool such as | ||
# https://github.com/kcoyner/rpl/ or just a find/sed combination, e.g.,: | ||
URL_BASE=https://github.com/ethereum/consensus-specs/blob/ | ||
FROM=${URL_BASE}${PREV_VERSION}/ | ||
TO=${URL_BASE}${NEXT_VERSION}/ | ||
echo "${UNCHANGED_SPEC_FILES}" | xargs -I{} printf "echo Replacing {}\nrpl --quiet --recursive -x.nim -x.md ${FROM}{} ${TO}{} ${NIMBUS_SOURCE_DIR} 2>/dev/null\n" | ||
|
||
# rpl's --quiet option does seem broken though. |