Nightly sync mode - #58
Conversation
chrono is used to get the current date in order to update the nightly version, in case josh-sync is configured to use nightly versions. toml_edit is used to read and modify the rust-toolchain.toml file.
In the `Latest` sync mode, this will be `rust-version`, but in the `Nightly` mode this either has to be `rust-toolchain` (legacy) or `rust-toolchain.toml`.
This lets repos choose if they want to sync from the latest rustc commit or if they want to pin a nightly in rust-toolchain.toml.
Gets the current rust version depending on the BaseCommit mode selected.
Extracts the rust-version write logic out of the `rustc_pull` function in its own `bump_version_latest` helper. Then it adds a new nightly sync helper called `bump_version_nightly`. In the new mode, it uses toml_edit to modify the `rust-toolchain.toml` file with the latest nightly version, which it constructs through the current date. Small behaviorial change: The `new upstream base: <sha>` message is now printed after the `original local HEAD: <sha>` message.
|
Hi, thanks for the PR. Fiddling with the TOML adds some complexity, but it makes sense. I wonder, instead of using dates manually, maybe we can download https://static.rust-lang.org/manifests.txt and read the latest entry? |
|
manifests.txt in the past on occasion not been getting updated for several days in a row. |
|
I think that only happens if we forget to update the CI job which needs to be poked once every 6 months I think 😆 But I realized that adding a dependency on a network client is perhaps a bit of a heavy hammer for this functionality. Using the local nightly rustc to figure out its commit hash actually seems quite elegant. It could even work on CI, if we do something like This PR already reads the hash from the nightly rustc, so maybe it could also read its date from it? Or you could pass the nightly verison explicitly. It seems better to me than guessing the date, because the nightly dates are always offset-by-one and it gets confusing. |
These only really make sense in combination, right? IMO they should be controlled by a single flag. |
That would mean you did have to download rustc twice, right? Once for the nightly toolchain and once for
The date reported by rustc is off by one, but the date in the toolchain name matches the current day. |
|
Ok, fair enough. Since we would anyway be dealing with parsing TOML files, downloading from the manifest seems reasonable, as it is the source of truth for Rustup too, and contains both the date and the commit. |
Clippy wants to pin its version in the repo to a nightly, so that contributors don't need any special tooling in order to compile it and
rustupwill automatically take care of toolchain management.This requires some extra logic for syncing:
rust-toolchain.tomlfile ->toml_editchrono-> date ->nightly-{date}rustc +nightly-{date} -vVThis PR moves a bunch of code around to add the new nightly sync-mode as just a new helper function. More details of the separate steps in the commit messages.
WIP, as I'm still testing it with this config: