Skip to content

Commit a4667d1

Browse files
authored
script to automate aspects of spec URL updating (#3252)
1 parent 8242e57 commit a4667d1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
set -Eeuo pipefail
3+
4+
PREV_VERSION=${1}
5+
NEXT_VERSION=${2}
6+
NIMBUS_SOURCE_DIR=${3}
7+
8+
TMPDIR1=$(mktemp -d)
9+
TMPDIR2=$(mktemp -d)
10+
REPO_URL=https://github.com/ethereum/consensus-specs.git
11+
VALID=".*\\.\\(md\\|py\\)"
12+
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)
13+
14+
# One can use this to automate the search andreplace with a tool such as
15+
# https://github.com/kcoyner/rpl/ or just a find/sed combination, e.g.,:
16+
URL_BASE=https://github.com/ethereum/consensus-specs/blob/
17+
FROM=${URL_BASE}${PREV_VERSION}/
18+
TO=${URL_BASE}${NEXT_VERSION}/
19+
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"
20+
21+
# rpl's --quiet option does seem broken though.

0 commit comments

Comments
 (0)