Skip to content

Commit 84d3854

Browse files
committed
dist: Ensure we treat two-part versions as tracking
Without this, `rustup update` will not update two-part version channels such as `1.48`. Signed-off-by: Daniel Silverstone (WSL2) <dsilvers@digital-scurf.org>
1 parent 7af951a commit 84d3854

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/dist/dist.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,16 @@ impl ToolchainDesc {
464464
}
465465
}
466466

467+
/// Toolchain channels are considered 'tracking' if it is one of the named channels
468+
/// such as `stable`, or is an incomplete version such as `1.48`, and the
469+
/// date field is empty.
467470
pub fn is_tracking(&self) -> bool {
468471
let channels = ["nightly", "beta", "stable"];
469-
channels.iter().any(|x| *x == self.channel) && self.date.is_none()
472+
lazy_static! {
473+
static ref TRACKING_VERSION: Regex = Regex::new(r"^\d{1}\.\d{1,3}$").unwrap();
474+
}
475+
(channels.iter().any(|x| *x == self.channel) || TRACKING_VERSION.is_match(&self.channel))
476+
&& self.date.is_none()
470477
}
471478
}
472479

@@ -1079,4 +1086,22 @@ mod tests {
10791086
);
10801087
}
10811088
}
1089+
1090+
#[test]
1091+
fn test_tracking_channels() {
1092+
static CASES: &[(&str, bool)] = &[
1093+
("stable", true),
1094+
("beta", true),
1095+
("nightly", true),
1096+
("nightly-2020-10-04", false),
1097+
("1.48", true),
1098+
("1.47.0", false),
1099+
];
1100+
for case in CASES {
1101+
let full_tcn = format!("{}-x86_64-unknown-linux-gnu", case.0);
1102+
let tcd = ToolchainDesc::from_str(&full_tcn).unwrap();
1103+
eprintln!("Considering {}", case.0);
1104+
assert_eq!(tcd.is_tracking(), case.1);
1105+
}
1106+
}
10821107
}

0 commit comments

Comments
 (0)