diff --git a/ADMIN_TASKS.md b/ADMIN_TASKS.md index b91b2ef96c..d4c650d104 100644 --- a/ADMIN_TASKS.md +++ b/ADMIN_TASKS.md @@ -21,7 +21,9 @@ occasional maintenance tasks. ## Update the `edition` in all listings To update the `edition = "[year]"` metadata in all the listings' `Cargo.toml`s, -run the `./tools/update-editions.sh` script and commit the changes. +run the `./tools/update-editions.sh` script. Check the diff to make sure it +looks reasonable, and in particular check whether the updates necessitate any +changes to the text. Then commit the changes. ## Update the `edition` in mdBook config diff --git a/Cargo.lock b/Cargo.lock index 2c4a7ecb3a..c1fd7d4b54 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,10 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "adder" -version = "0.1.0" - [[package]] name = "adler" version = "1.0.2" @@ -92,10 +88,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "guessing_game" -version = "0.1.0" - [[package]] name = "lazy_static" version = "1.4.0" diff --git a/Cargo.toml b/Cargo.toml index b2ef132160..73c7ba471a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = [ "listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new", "listings/ch11-writing-automated-tests/listing-11-01","packages/tools"] +members = ["packages/tools"] default-members = ["packages/tools"] resolver = "2" exclude = [ diff --git a/tools/update-editions.sh b/tools/update-editions.sh index 3f1fa15cb8..c356beb9c3 100755 --- a/tools/update-editions.sh +++ b/tools/update-editions.sh @@ -2,7 +2,18 @@ set -eu +# So that we can do this in a single pass, check *here* if there are any “dirty” +# files from Git, and bail if so. +git diff --quiet || { echo "Git working directory is not clean"; exit 1; } + OLD_EDITION=2021 NEW_EDITION=2024 -find listings/** -name "Cargo.toml" -exec sed -i '' "s/edition = \"$OLD_EDITION\"/edition = \"$NEW_EDITION\"/g" '{}' \; +# Start by preparing all listings for the edition. +find listings -name "Cargo.toml" -exec cargo fix --allow-dirty --edition --manifest-path '{}' \; + +# Update the edition itself +find listings -name "Cargo.toml" -exec sed -i '' "s/edition = \"$OLD_EDITION\"/edition = \"$NEW_EDITION\"/g" '{}' \; + +# Update all id +find listings -name "Cargo.toml" -exec cargo fix --allow-dirty --edition-idioms --manifest-path {} \;