Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 11 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 6 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ categories = ["os"]
keywords = ["upgrade", "update"]
license = "GPL-3.0-or-later"
repository = "https://github.com/topgrade-rs/topgrade"
rust-version = "1.84.1"
rust-version = "1.87.0"
version = "16.6.0"
authors = ["Roey Darwish Dror <[email protected]>", "Thomas Schönauer <[email protected]>"]
exclude = ["doc/screenshot.gif", "BREAKINGCHANGES_dev.md"]
edition = "2021"
edition = "2024"

readme = "README.md"

[dependencies]
home = "=0.5.11"
etcetera = "=0.10.0"
etcetera = "~0.11.0"
serde = { version = "~1.0", features = ["derive"] }
toml = { version = "=0.9.8", features = ["preserve_order"] }
toml = { version = "~0.9.8", features = ["preserve_order"] }
which_crate = { version = "~8.0", package = "which" }
shellexpand = "~3.1"
clap = { version = "~4.5", features = ["cargo", "derive"] }
Expand Down Expand Up @@ -47,11 +46,7 @@ sys-locale = "0.3.1"
jetbrains-toolbox-updater = "5.0.0"
indexmap = { version = "2.9.0", features = ["serde"] }
serde_json = "1.0.145"
# Temporary transitive dependency pins
ignore = "=0.4.23"
globset = "=0.4.16"
base64ct = "<1.8.0"
clap-cargo = "0.15.2"
clap-cargo = "0.18.0"

[package.metadata.generate-rpm]
assets = [{ source = "target/release/topgrade", dest = "/usr/bin/topgrade" }]
Expand All @@ -62,7 +57,7 @@ git = "*"
[package.metadata.deb]
name = "topgrade"
maintainer = "Chris Gelatt <[email protected]>"
copyright = "2024, Topgrade Team"
copyright = "2025, Topgrade Team"
license-file = ["LICENSE", "0"]
depends = "$auto"
extended-description = "Keeping your system up to date usually involves invoking multiple package managers. This results in big, non-portable shell one-liners saved in your shell. To remedy this, Topgrade detects which tools you use and runs the appropriate commands to update them."
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.84.1"
channel = "1.87.0"
4 changes: 2 additions & 2 deletions src/breaking_changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
//! 1. The Topgrade being executed is a new major release
//! 2. This is the first launch of that major release

use crate::terminal::print_separator;
#[cfg(windows)]
use crate::WINDOWS_DIRS;
#[cfg(unix)]
use crate::XDG_DIRS;
use crate::terminal::print_separator;
use color_eyre::eyre::Result;
use etcetera::base_strategy::BaseStrategy;
use rust_i18n::t;
use std::{
env::var,
fs::{read_to_string, OpenOptions},
fs::{OpenOptions, read_to_string},
io::Write,
path::PathBuf,
str::FromStr,
Expand Down
2 changes: 1 addition & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::process::Child;
use std::process::{Command, ExitStatus, Output};

use color_eyre::eyre;
use color_eyre::eyre::eyre;
use color_eyre::eyre::Context;
use color_eyre::eyre::eyre;

use crate::error::TopgradeError;

Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(dead_code)]

use std::fs::{write, File};
use std::fs::{File, write};
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::Command;
Expand Down
2 changes: 1 addition & 1 deletion src/ctrlc/unix.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! SIGINT handling in Unix systems.
use crate::ctrlc::interrupted::set_interrupted;
use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal};
use nix::sys::signal::{SaFlags, SigAction, SigHandler, SigSet, Signal, sigaction};

/// Handle SIGINT. Set the interruption flag.
extern "C" fn handle_sigint(_: i32) {
Expand Down
2 changes: 1 addition & 1 deletion src/ctrlc/windows.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! A stub for Ctrl + C handling.
use crate::ctrlc::interrupted::set_interrupted;
use tracing::error;
use windows::Win32::System::Console::{CTRL_C_EVENT, SetConsoleCtrlHandler};
use windows::core::BOOL;
use windows::Win32::System::Console::{SetConsoleCtrlHandler, CTRL_C_EVENT};

extern "system" fn handler(ctrl_type: u32) -> BOOL {
match ctrl_type {
Expand Down
2 changes: 1 addition & 1 deletion src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::process::{Child, Command, ExitStatus, Output};

use color_eyre::eyre::Result;
use rust_i18n::t;
use tracing::{debug, enabled, Level};
use tracing::{Level, debug, enabled};

use crate::command::CommandExt;
use crate::error::DryRun;
Expand Down
13 changes: 5 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#![allow(clippy::cognitive_complexity)]

use std::env;
use std::env::home_dir;
use std::io;
use std::path::PathBuf;
use std::process::exit;
use std::time::Duration;

use crate::breaking_changes::{first_run_of_major_release, print_breaking_changes, should_skip, write_keep_file};
use clap::CommandFactory;
use clap::{crate_version, Parser};
use clap::{Parser, crate_version};
use color_eyre::eyre::Context;
use color_eyre::eyre::Result;
use console::Key;
Expand Down Expand Up @@ -48,7 +49,7 @@ mod sudo;
mod terminal;
mod utils;

pub(crate) static HOME_DIR: LazyLock<PathBuf> = LazyLock::new(|| home::home_dir().expect("No home directory"));
pub(crate) static HOME_DIR: LazyLock<PathBuf> = LazyLock::new(|| home_dir().expect("No home directory"));
#[cfg(unix)]
pub(crate) static XDG_DIRS: LazyLock<Xdg> = LazyLock::new(|| Xdg::new().expect("No home directory"));

Expand Down Expand Up @@ -98,7 +99,7 @@ fn run() -> Result<()> {
let mut parts = env.split('=');
let var = parts.next().unwrap();
let value = parts.next().unwrap();
env::set_var(var, value);
unsafe { env::set_var(var, value) };
}

if opt.edit_config() {
Expand Down Expand Up @@ -321,11 +322,7 @@ fn run() -> Result<()> {
);
}

if failed {
Err(StepFailed.into())
} else {
Ok(())
}
if failed { Err(StepFailed.into()) } else { Ok(()) }
}

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::ctrlc;
use crate::error::{DryRun, MissingSudo, SkipStep};
use crate::execution_context::ExecutionContext;
use crate::step::Step;
use crate::terminal::{print_error, print_warning, should_retry, ShouldRetry};
use crate::terminal::{ShouldRetry, print_error, print_warning, should_retry};

pub enum StepResult {
Success,
Expand Down
4 changes: 2 additions & 2 deletions src/self_update.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::env;
#[cfg(unix)]
use std::os::unix::process::CommandExt as _;
use std::process::Command;
#[cfg(windows)]
use std::process::exit;
use std::process::Command;

use crate::step::Step;
use color_eyre::eyre::Result;
#[cfg(unix)]
use color_eyre::eyre::bail;
use color_eyre::eyre::Result;
use rust_i18n::t;
use self_update_crate::backends::github::Update;
use self_update_crate::update::UpdateStatus;
Expand Down
2 changes: 1 addition & 1 deletion src/steps/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::process::Command;

use color_eyre::eyre::Context;
use color_eyre::eyre::Result;
use color_eyre::eyre::{eyre, OptionExt};
use color_eyre::eyre::{OptionExt, eyre};
use tracing::{debug, error, warn};
use wildmatch::WildMatch;

Expand Down
2 changes: 1 addition & 1 deletion src/steps/emacs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::command::CommandExt;
use crate::execution_context::ExecutionContext;
use crate::step::Step;
use crate::terminal::print_separator;
use crate::utils::{require, require_option, PathExt};
use crate::utils::{PathExt, require, require_option};

const EMACS_UPGRADE: &str = include_str!("emacs.el");
#[cfg(windows)]
Expand Down
32 changes: 17 additions & 15 deletions src/steps/generic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use color_eyre::eyre::Context;
use color_eyre::eyre::Result;
use color_eyre::eyre::{eyre, OptionExt};
use jetbrains_toolbox_updater::{find_jetbrains_toolbox, update_jetbrains_toolbox, FindError};
use color_eyre::eyre::{OptionExt, eyre};
use jetbrains_toolbox_updater::{FindError, find_jetbrains_toolbox, update_jetbrains_toolbox};
use regex::bytes::Regex;
use rust_i18n::t;
use semver::Version;
Expand All @@ -16,15 +16,15 @@ use std::{fs, io::Write};
use tempfile::tempfile_in;
use tracing::{debug, error, warn};

use crate::HOME_DIR;
use crate::command::{CommandExt, Utf8Output};
use crate::execution_context::ExecutionContext;
use crate::executor::ExecutorOutput;
use crate::output_changed_message;
use crate::step::Step;
use crate::sudo::SudoExecuteOpts;
use crate::terminal::{print_separator, shell};
use crate::utils::{check_is_python_2_or_shim, require, require_one, require_option, which, PathExt};
use crate::HOME_DIR;
use crate::utils::{PathExt, check_is_python_2_or_shim, require, require_one, require_option, which};
use crate::{
error::{SkipStep, StepFailed, TopgradeError},
terminal::print_warning,
Expand Down Expand Up @@ -65,7 +65,9 @@ pub fn run_cargo_update(ctx: &ExecutionContext) -> Result<()> {
.or_else(|| cargo_dir.join("bin/cargo-install-update").if_exists());

let Some(cargo_update) = cargo_update else {
let message = String::from("cargo-update isn't installed so Topgrade can't upgrade cargo packages.\nInstall cargo-update by running `cargo install cargo-update`");
let message = String::from(
"cargo-update isn't installed so Topgrade can't upgrade cargo packages.\nInstall cargo-update by running `cargo install cargo-update`",
);
print_warning(&message);
return Err(SkipStep(message).into());
};
Expand All @@ -81,7 +83,9 @@ pub fn run_cargo_update(ctx: &ExecutionContext) -> Result<()> {
if let Some(e) = cargo_cache {
ctx.execute(e).args(["-a"]).status_checked()?;
} else {
let message = String::from("cargo-cache isn't installed so Topgrade can't cleanup cargo packages.\nInstall cargo-cache by running `cargo install cargo-cache`");
let message = String::from(
"cargo-cache isn't installed so Topgrade can't cleanup cargo packages.\nInstall cargo-cache by running `cargo install cargo-cache`",
);
print_warning(message);
}
}
Expand Down Expand Up @@ -542,7 +546,7 @@ fn run_vscode_compatible(variant: VSCodeVariant, ctx: &ExecutionContext) -> Resu
return Err(eyre!(output_changed_message!(
&format!("{bin_name} --version"),
"No first line"
)))
)));
}
};

Expand Down Expand Up @@ -1239,11 +1243,7 @@ pub fn run_helm_repo_update(ctx: &ExecutionContext) -> Result<()> {
};
}

if success {
Ok(())
} else {
Err(eyre!(StepFailed))
}
if success { Ok(()) } else { Err(eyre!(StepFailed)) }
}

pub fn run_stew(ctx: &ExecutionContext) -> Result<()> {
Expand Down Expand Up @@ -1428,8 +1428,7 @@ pub fn run_poetry(ctx: &ExecutionContext) -> Result<()> {
.map_err(|e| SkipStep(format!("Could not find interpreter for {}: {}", poetry.display(), e)))?;
debug!("poetry interpreter: {:?}, args: {:?}", interp, interp_args);

let check_official_install_script =
"import sys; from os import path; print('Y') if path.isfile(path.join(sys.prefix, 'poetry_env')) else print('N')";
let check_official_install_script = "import sys; from os import path; print('Y') if path.isfile(path.join(sys.prefix, 'poetry_env')) else print('N')";
let mut command = Command::new(&interp);
if let Some(args) = interp_args {
command.arg(args);
Expand Down Expand Up @@ -1708,7 +1707,10 @@ fn run_jetbrains_ide_generic<const IS_JETBRAINS: bool>(ctx: &ExecutionContext, b
.code()
.ok_or_eyre("Failed to get status code; was killed with signal")?;
if status_code != 1 {
return Err(eyre!("Expected status code 1 ('Only one instance of <IDE> can be run at a time.'), but found status code {}. Output: {output:?}", status_code));
return Err(eyre!(
"Expected status code 1 ('Only one instance of <IDE> can be run at a time.'), but found status code {}. Output: {output:?}",
status_code
));
}
// Don't crash, but don't be silent either
warn!("{name} is already running, can't update it now.");
Expand Down
Loading
Loading