diff options
| author | onur-ozkan <work@onurozkan.dev> | 2023-10-27 06:51:12 +0300 |
|---|---|---|
| committer | onur-ozkan <work@onurozkan.dev> | 2023-11-08 14:05:56 +0300 |
| commit | ae4d18b2da7a1d044481948bb84f40ba4eec24c5 (patch) | |
| tree | c02a7eb97b435e34b84c00f5f00fedcf9e3b0223 /src | |
| parent | 750c2ecd1503fe7ff39e41603977d12de33417d8 (diff) | |
| download | rust-ae4d18b2da7a1d044481948bb84f40ba4eec24c5.tar.gz rust-ae4d18b2da7a1d044481948bb84f40ba4eec24c5.zip | |
handle the case when the change-id isn't found
When we switch back and forth between the old and recent branches, if there was a breaking change in the bootstrap configuration in between, we have to update the change-id in the build configuration with each checkout, which can be exhausting. This change fixes that. Signed-off-by: onur-ozkan <work@onurozkan.dev>
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/src/bin/main.rs | 20 | ||||
| -rw-r--r-- | src/bootstrap/src/lib.rs | 17 |
2 files changed, 25 insertions, 12 deletions
diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs index d87fb6a9cef..e0caecca5c0 100644 --- a/src/bootstrap/src/bin/main.rs +++ b/src/bootstrap/src/bin/main.rs @@ -109,31 +109,35 @@ fn check_version(config: &Config) -> Option<String> { } let latest_config_id = CONFIG_CHANGE_HISTORY.last().unwrap(); - let suggestion = if let Some(id) = config.change_id { + if let Some(id) = config.change_id { if &id != latest_config_id { - msg.push_str("WARNING: there have been changes to x.py since you last updated.\n"); let change_links: Vec<String> = find_recent_config_change_ids(id) .iter() .map(|id| format!("https://github.com/rust-lang/rust/pull/{id}")) .collect(); if !change_links.is_empty() { + msg.push_str("WARNING: there have been changes to x.py since you last updated.\n"); msg.push_str("To see more detail about these changes, visit the following PRs:\n"); + for link in change_links { msg.push_str(&format!(" - {link}\n")); } + + msg.push_str("WARNING: there have been changes to x.py since you last updated.\n"); + + msg.push_str("note: to silence this warning, "); + msg.push_str(&format!( + "update `config.toml` to use `change-id = {latest_config_id}` instead" + )); } - msg.push_str("WARNING: there have been changes to x.py since you last updated.\n"); - format!("update `config.toml` to use `change-id = {latest_config_id}` instead") } else { return None; } } else { msg.push_str("WARNING: The `change-id` is missing in the `config.toml`. This means that you will not be able to track the major changes made to the bootstrap configurations.\n"); - format!("add `change-id = {latest_config_id}` at the top of `config.toml`") + msg.push_str("note: to silence this warning, "); + msg.push_str(&format!("add `change-id = {latest_config_id}` at the top of `config.toml`")); }; - msg.push_str("note: to silence this warning, "); - msg.push_str(&suggestion); - Some(msg) } diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index fc3413a3c81..d7c05da6864 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -1849,10 +1849,19 @@ fn envify(s: &str) -> String { } pub fn find_recent_config_change_ids(current_id: usize) -> Vec<usize> { - let index = CONFIG_CHANGE_HISTORY - .iter() - .position(|&id| id == current_id) - .expect(&format!("Value `{}` was not found in `CONFIG_CHANGE_HISTORY`.", current_id)); + if !CONFIG_CHANGE_HISTORY.contains(¤t_id) { + // If the current change-id is greater than the most recent one, + // return an empty list; otherwise, return the full list. + if let Some(max_id) = CONFIG_CHANGE_HISTORY.iter().max() { + if ¤t_id > max_id { + return Vec::new(); + } + } + + return CONFIG_CHANGE_HISTORY.to_vec(); + } + + let index = CONFIG_CHANGE_HISTORY.iter().position(|&id| id == current_id).unwrap(); CONFIG_CHANGE_HISTORY .iter() |
