-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pin problem-specifications to a specific commit (#1950)
The previous approach used a submodule to keep things somewhat stable. That worked well for the rust-tooling (exercise generator) which made use of the submodule. However, configlet continued to use its own cache. (see exercism/configlet#816) This could lead to problems where the configlet cache and the submodule are out of sync and don't agree. The new approach ditches the submodule and makes everything use the configlet cache. Some helper scripts are responsible to make sure the cache is checked out at the pinned commit and a configlet wrapper sets the `--offile` flag to prevent configlet from updating the cache.
- Loading branch information
Showing
10 changed files
with
88 additions
and
10 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 |
---|---|---|
|
@@ -8,3 +8,4 @@ exercises/*/*/Cargo.lock | |
clippy.log | ||
.vscode | ||
.prob-spec | ||
problem-specifications |
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 |
---|---|---|
@@ -1,3 +0,0 @@ | ||
[submodule "problem-specifications"] | ||
path = problem-specifications | ||
url = [email protected]:exercism/problem-specifications | ||
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,17 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
cd "$(git rev-parse --show-toplevel)" | ||
|
||
PINNED_COMMIT_HASH="685ec55d9388937bbb3cc836b52b3ce27f208f37" | ||
|
||
dir="$(./bin/get_problem_specifications_dir.sh)" | ||
|
||
[ -d "$dir" ] || ./bin/configlet info &> /dev/null # initial population of cache | ||
|
||
if ! git -C "$dir" checkout --quiet --detach "$PINNED_COMMIT_HASH" &> /dev/null | ||
then | ||
# maybe the pinned commit hash was updated and the cache has to be refreshed | ||
./bin/configlet info &> /dev/null | ||
git -C "$dir" checkout --quiet --detach "$PINNED_COMMIT_HASH" | ||
fi |
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,29 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
# This wrapper makes sure the problem-specifications repository is checked out | ||
# at the pinned commit and the --offline flag is set for the relevant commands. | ||
|
||
cd "$(git rev-parse --show-toplevel)" | ||
|
||
[ -f ./bin/configlet ] || ./bin/fetch-configlet | ||
|
||
if [ "$#" == 0 ] | ||
then | ||
./bin/configlet | ||
exit | ||
fi | ||
|
||
cmd="$1" ; shift | ||
|
||
if ! [ "$cmd" == "create" ] && ! [ "$cmd" == "sync" ] && ! [ "$cmd" == "info" ] | ||
then | ||
# problem-specifications independent commands | ||
./bin/configlet "$cmd" "$@" | ||
exit | ||
fi | ||
|
||
./bin/checkout_pinned_problem_specifications_commit.sh | ||
|
||
set -x # show the added --offile flag | ||
./bin/configlet "$cmd" --offline "$@" |
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,13 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | ||
prefix="${XDG_CACHE_HOME:-$HOME/.cache}" | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
prefix="${XDG_CACHE_HOME:-$HOME/Library/Caches}" | ||
else | ||
echo "Unsupported OS: $OSTYPE" >&2 | ||
exit 1 | ||
fi | ||
|
||
echo -n "$prefix/exercism/configlet/problem-specifications" |
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
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,15 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
cd "$(git rev-parse --show-toplevel)" | ||
|
||
./bin/checkout_pinned_problem_specifications_commit.sh | ||
|
||
dir="$(./bin/get_problem_specifications_dir.sh)" | ||
|
||
git -C "$dir" checkout --quiet main | ||
git -C "$dir" pull --quiet | ||
|
||
new_commit_hash="$(git -C "$dir" rev-parse main)" | ||
|
||
sed -i "s/^PINNED_COMMIT_HASH=.*$/PINNED_COMMIT_HASH=\"$new_commit_hash\"/g" ./bin/checkout_pinned_problem_specifications_commit.sh |
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
Submodule problem-specifications
deleted from
6c44c8
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