diff options
| author | mo8it <mo8it@proton.me> | 2024-04-17 16:09:25 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-04-17 16:09:25 +0200 |
| commit | 7f433ae28f0e79c62f53b74a14042f916cb13650 (patch) | |
| tree | d2d8c02d7b6b1d57d1f70b9789b5efc54e189a43 /src | |
| parent | a2506f154b929b74e7d5c286cee6eabb008aa1fd (diff) | |
Check the format version in `dev check`
Diffstat (limited to 'src')
| -rw-r--r-- | src/dev/check.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/dev/check.rs b/src/dev/check.rs index bc8e459..daf5bdb 100644 --- a/src/dev/check.rs +++ b/src/dev/check.rs @@ -1,9 +1,9 @@ use anyhow::{bail, Context, Result}; -use std::fs; +use std::{cmp::Ordering, fs}; use crate::{ info_file::{ExerciseInfo, InfoFile}, - DEVELOPING_OFFIFICAL_RUSTLINGS, + CURRENT_FORMAT_VERSION, DEVELOPING_OFFIFICAL_RUSTLINGS, }; pub fn bins_start_end_ind(cargo_toml: &str) -> Result<(usize, usize)> { @@ -62,7 +62,11 @@ fn check_cargo_toml( pub fn check() -> Result<()> { let info_file = InfoFile::parse()?; - // TODO: Add checks + match info_file.format_version.cmp(&CURRENT_FORMAT_VERSION) { + Ordering::Less => bail!("`format_version` < {CURRENT_FORMAT_VERSION} (supported version)\nPlease migrate to the latest format version"), + Ordering::Greater => bail!("`format_version` > {CURRENT_FORMAT_VERSION} (supported version)\nTry updating the Rustlings program"), + Ordering::Equal => (), + } if DEVELOPING_OFFIFICAL_RUSTLINGS { check_cargo_toml( |
