Skip to content

Commit

Permalink
feat: output more info if up to date (#2286)
Browse files Browse the repository at this point in the history
Right now when doing `pixi global install something` on an already
up-to-date environment, it will just print that the env is already
up-to-date.

This PR introduces a more detailed view of up-to-date environment, which
uses the same format as pixi global list


![image](https://github.com/user-attachments/assets/4c7351b6-2518-4193-9f9e-aca624943b0d)


some other niceties 🍪 :

* It also move code from cli/global under separate module
* I've added `test-specific-test` that I think it is handy to have when
you want to test only one test without running all of them. Also running
without `--numprocesses=auto` make debugger hook work.
* I also added output structure for `verify_cli_command`, so it is more
easier to debug what subprocess returned rather than going inside
`verify_cli_command`



upd:

after a discussion with @Hofer-Julian we decided to use `always` tree
output after installing with some information in there
this is how it looks with new colouring and styling:


![image](https://github.com/user-attachments/assets/7f4f9e12-631c-4533-a06f-f87cc569c54b)

---------

Co-authored-by: Julian Hofer <julianhofer@gnome.org>
  • Loading branch information
nichmor and Hofer-Julian authored Oct 18, 2024
1 parent 5914bbe commit 40dff8d
Show file tree
Hide file tree
Showing 9 changed files with 546 additions and 364 deletions.
4 changes: 4 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ test-integration-dev = { cmd = "pytest --numprocesses=auto --durations=10 tests/
test-integration-global = { cmd = "pytest --numprocesses=auto --durations=10 tests/integration/test_global.py", depends-on = [
"build",
] }
# pass the file to run as an argument to the task
# you can also pass a specific test function, like this:
# /path/to/test.py::test_function
test-specific-test = { cmd = "pytest", depends-on = ["build"] }
typecheck-integration = "mypy --strict tests/integration"

[feature.dev.dependencies]
Expand Down
25 changes: 23 additions & 2 deletions src/cli/global/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ use rattler_conda_types::{MatchSpec, NamedChannelOrUrl, PackageName, Platform};

use crate::{
cli::{global::revert_environment_after_error, has_specs::HasSpecs},
global::{self, EnvironmentName, ExposedName, Mapping, Project, StateChange, StateChanges},
global::{
self, common::NotChangedReason, list::list_global_environments, EnvChanges, EnvState,
EnvironmentName, ExposedName, Mapping, Project, StateChange, StateChanges,
},
prefix::Prefix,
};
use pixi_config::{self, Config, ConfigCli};
Expand Down Expand Up @@ -86,6 +89,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
}

let mut state_changes = StateChanges::default();
let mut env_changes = EnvChanges::default();
let mut last_updated_project = project_original;
let specs = args.specs()?;
for env_name in &env_names {
Expand All @@ -104,6 +108,15 @@ pub async fn execute(args: Args) -> miette::Result<()> {
.wrap_err_with(|| format!("Couldn't install {}", env_name.fancy_display()))
{
Ok(sc) => {
match sc.has_changed() {
true => env_changes
.changes
.insert(env_name.clone(), EnvState::Installed),
false => env_changes.changes.insert(
env_name.clone(),
EnvState::NotChanged(NotChangedReason::AlreadyInstalled),
),
};
state_changes |= sc;
}
Err(err) => {
Expand All @@ -116,7 +129,15 @@ pub async fn execute(args: Args) -> miette::Result<()> {
}
last_updated_project = project;
}
state_changes.report();

// After installing, we always want to list the changed environments
list_global_environments(
&last_updated_project,
Some(env_names),
Some(&env_changes),
None,
)
.await?;

Ok(())
}
Expand Down
Loading

0 comments on commit 40dff8d

Please sign in to comment.