mirror of
https://github.com/storytold/gridcraft.git
synced 2026-12-01 18:26:05 -06:00
nightly: read the built commit only from a lower-case version
gate / gate (ubuntu-24.04) failed channel::tests::the_commit_is_read_back_only_from_a_nightly_version: `commit_for` used `is_ascii_hexdigit`, which also accepts A-F, so `...gABCDEF012345` read back as a commit although the producer's version pattern is lower-case. The check now takes digits and a-f only, as the nightly version pattern already requires.
This commit is contained in:
@@ -92,10 +92,13 @@ pub fn version() -> &'static str {
|
||||
}
|
||||
|
||||
/// The commit a nightly was built from, read back from its version (`…g<sha12>`), if any.
|
||||
///
|
||||
/// The producer writes the sha in lower case (the version pattern every nightly job enforces), so an
|
||||
/// upper-case one is a malformed version rather than a commit: nothing is read back for it.
|
||||
pub fn commit_for(version: &str) -> Option<&str> {
|
||||
let (_, suffix) = version.split_once("-nightly.")?;
|
||||
let (_, sha) = suffix.rsplit_once(".g")?;
|
||||
(sha.len() == 12 && sha.bytes().all(|b| b.is_ascii_hexdigit())).then_some(sha)
|
||||
(sha.len() == 12 && sha.bytes().all(|b| matches!(b, b'0'..=b'9' | b'a'..=b'f'))).then_some(sha)
|
||||
}
|
||||
|
||||
pub fn commit() -> Option<&'static str> {
|
||||
|
||||
Reference in New Issue
Block a user