Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5475 +/- ##
==========================================
+ Coverage 79.58% 79.64% +0.07%
==========================================
Files 359 359
Lines 19625 19619 -6
==========================================
+ Hits 15616 15623 +7
+ Misses 4009 3996 -13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| sub(/\r$/, "", $6) | ||
| if ($6 == "active") print $1 | ||
| else if (command == "unalias") print $5 "." $1 |
|
This probably doesn't link in a comment, but for future reference: MULTI-2692 |
ricab
left a comment
There was a problem hiding this comment.
It took me a while to get into context and understand it all, but I think this is solid overall and doing what it means to.
However, I believe a few choices make this more complex that it should have to be, leaving more disperse code to remove in the second step (e.g. active_context field and setter). I also spotted some inconsistencies with respect to other deprecated commands.
One thing that would have helped me review this would be some more information in the description. I don't need anything very long and I don't mind if you skip non-applicable fields in the template, but a reference for what sort of interaction this aimed for, choices, and manual testing steps would have helped.
Finally, there is one commit here changing 30+ files. Splitting it by concern would ease review and future reference. In this case, I think that justifies the commit rewrite and force-push.
I haven't reviewed the docs yet — waiting for I/O to settle before that.
9be3f24 to
dbdaa8c
Compare
Done, split into 8 commits based on concern. |
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open issues
The expected help text forpreferhere does not match the implementation/test expectations… · New Treat multiple empty contexts as an empty alias dictionary Read alias status and context from trailing CSV fields Usingemplace(\"context-status\", ...)will silently do nothing ifcontext-statusis already… · New
Review effort: Lite
| std::make_pair(std::string{"prefer"}, | ||
| "Switch the current alias context. If it does not exist, create it " | ||
| "before switching."))); | ||
| std::make_pair(std::string{"prefer"}, "Alias contexts can no longer be switched."))); |
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
8 open issues
This can block legitimate built-in commands if a legacy inactive context contains an alias with the… · New The positional-argument validation runs even whencommandParse()returns a non-OK status (notably… · New With legacy data, the same alias name can exist in multiple contexts. In--allmode this will… · New Usingemplace("context-status", ...)will silently do nothing if that key is ever added upstream… · New The expected help text forpreferhere does not match the implementation/test expectations… Treat multiple empty contexts as an empty alias dictionary Read alias status and context from trailing CSV fields Usingemplace(\"context-status\", ...)will silently do nothing ifcontext-statusis already…
Review effort: Lite
| { | ||
| execute_alias = aliases->get_alias(requested_command.toStdString()); | ||
| if (execute_alias) | ||
| return prepare_alias_execution(requested_command); | ||
|
|
||
| if (aliases->is_inactive_alias(requested_command.toStdString())) | ||
| { | ||
| cerr << make_inactive_alias_warning(requested_command.toStdString()); | ||
| return ParseCode::CommandLineError; | ||
| } | ||
| } |
| cerr << mp::make_deprecation_warning( | ||
| "`multipass prefer`", | ||
| "Alias contexts can no longer be switched; only the default context is active. " | ||
| "Use unique alias names instead."); | ||
|
|
||
| return status; | ||
| } |
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
11 open issues
Removing the unqualified alias script (com.mand) when unaliasing an inactive-context alias can… · New The positional-argument validation runs even whencommandParse()returns a non-OK status (notably… This can block legitimate built-in commands if a legacy inactive context contains an alias with the… This warning triggers solely based on the storedactive-contextvalue, even if that legacy… · New Usingemplace("context-status", ...)will silently do nothing if that key is ever added upstream… With legacy data, the same alias name can exist in multiple contexts. In--allmode this will… The expected help text forpreferhere does not match the implementation/test expectations… Treat multiple empty contexts as an empty alias dictionary Read alias status and context from trailing CSV fields Usingemplace(\"context-status\", ...)will silently do nothing ifcontext-statusis ever… · New Usingemplace(\"context-status\", ...)will silently do nothing ifcontext-statusis already…
Review effort: Lite
| EXPECT_CALL(*mock_platform, remove_alias_script("secondary.com.mand")).Times(1); | ||
| EXPECT_CALL(*mock_platform, remove_alias_script("com.mand")).Times(1); | ||
|
|
||
| EXPECT_EQ(send_command({"unalias", "secondary.com.mand"}), mp::ReturnCode::Ok); |
| if (previous_context && previous_context->is_string() && | ||
| previous_context->as_string() != mp::default_context_name) | ||
| cerr << mp::make_inactive_alias_context_warning(previous_context->as_string().c_str()); |
There was a problem hiding this comment.
🔵 Needs a closer look
Comma-containing alias commands shift the CSV fields, causing the fixed-column parsing to omit active aliases from command completion and generate invalid unalias candidates.
11 open issues
Removing the unqualified alias script (com.mand) when unaliasing an inactive-context alias can… The positional-argument validation runs even whencommandParse()returns a non-OK status (notably… This can block legitimate built-in commands if a legacy inactive context contains an alias with the… This warning triggers solely based on the storedactive-contextvalue, even if that legacy… Usingemplace("context-status", ...)will silently do nothing if that key is ever added upstream… With legacy data, the same alias name can exist in multiple contexts. In--allmode this will… The expected help text forpreferhere does not match the implementation/test expectations… Treat multiple empty contexts as an empty alias dictionary Read alias status and context from trailing CSV fields Usingemplace(\"context-status\", ...)will silently do nothing ifcontext-statusis ever… Usingemplace(\"context-status\", ...)will silently do nothing ifcontext-statusis already…
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Fixed CSV field positions mishandle valid alias commands containing commas, dropping active aliases from command completion and suggesting nonexistent aliases for unalias.
11 open issues
Removing the unqualified alias script (com.mand) when unaliasing an inactive-context alias can… The positional-argument validation runs even whencommandParse()returns a non-OK status (notably… This can block legitimate built-in commands if a legacy inactive context contains an alias with the… This warning triggers solely based on the storedactive-contextvalue, even if that legacy… Usingemplace("context-status", ...)will silently do nothing if that key is ever added upstream… With legacy data, the same alias name can exist in multiple contexts. In--allmode this will… The expected help text forpreferhere does not match the implementation/test expectations… Treat multiple empty contexts as an empty alias dictionary Read alias status and context from trailing CSV fields Usingemplace(\"context-status\", ...)will silently do nothing ifcontext-statusis ever… Usingemplace(\"context-status\", ...)will silently do nothing ifcontext-statusis already…
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Fixed-column CSV parsing breaks completion for alias commands containing commas, omitting active aliases and suggesting nonexistent names for unalias.
7 open issues
Removing the unqualified alias script (com.mand) when unaliasing an inactive-context alias can… The positional-argument validation runs even whencommandParse()returns a non-OK status (notably… This can block legitimate built-in commands if a legacy inactive context contains an alias with the… This warning triggers solely based on the storedactive-contextvalue, even if that legacy… With legacy data, the same alias name can exist in multiple contexts. In--allmode this will… The expected help text forpreferhere does not match the implementation/test expectations… Read alias status and context from trailing CSV fields
3 resolved since last review
Review effort: Balanced
Launch warned about aliases that were created successfully and stayed silent about the ones that failed. Warn only when alias creation fails.
Alias contexts can no longer be switched. Keep the prefer command so existing scripts get a clear deprecation warning instead of an unknown command error, but make it fail without changing the active context.
Alias contexts can no longer be switched, so AliasDict now enforces "default" as the only active context instead of tracking it in state. Drop the active_context member, set_active_context and active_context_name. The default context always exists, even after it is removed or the dictionary is cleared. Legacy files that select another context still load. Their aliases are kept but inactive, a warning explains how to recreate them, and the file is only rewritten when the dictionary is modified. The active-context field is still written as "default" so that older releases can read the file.
Add a context status column (CSV and table) and a context status map (JSON and YAML) so users can tell usable aliases in the default context apart from definitions retained in inactive contexts.
Running an alias that only exists in an inactive context now fails with a message explaining how to view its definition and recreate it in the default context, instead of reporting an unknown command.
Since contexts can no longer be switched, aliases in inactive contexts could not be removed in bulk. Make --all remove aliases from every context.
Only offer aliases from the default context as commands. Qualified names from inactive contexts are still offered to unalias, so they can be removed.
Document that default is the only active context, how to recreate aliases from inactive contexts, the new context status output, and the deprecation of prefer.
f4719dd to
304307e
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Fixed-column CSV parsing breaks completion for valid aliases whose command paths contain commas, omitting them from command suggestions and generating incorrect names for unalias.
6 open issues
Removing the unqualified alias script (com.mand) when unaliasing an inactive-context alias can… The positional-argument validation runs even whencommandParse()returns a non-OK status (notably… This can block legitimate built-in commands if a legacy inactive context contains an alias with the… This warning triggers solely based on the storedactive-contextvalue, even if that legacy… The expected help text forpreferhere does not match the implementation/test expectations… Read alias status and context from trailing CSV fields
1 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Fixed CSV field positions mishandle valid alias commands containing commas, dropping active aliases from command completion and producing invalid names for unalias completion.
6 open issues
Removing the unqualified alias script (com.mand) when unaliasing an inactive-context alias can… The positional-argument validation runs even whencommandParse()returns a non-OK status (notably… This can block legitimate built-in commands if a legacy inactive context contains an alias with the… This warning triggers solely based on the storedactive-contextvalue, even if that legacy… The expected help text forpreferhere does not match the implementation/test expectations… Read alias status and context from trailing CSV fields
Review effort: Balanced



This PR deprecates the prefer command and also blocks context switching between the user's available alias contexts. The user can still list and migrate aliases to the default context manually if they want to.
User-facing changes:
multipass prefer <ctx>multipass alias ...defaultmultipass <alias>defaultonly; aliases from other contexts fail with a message on how to recreate themmultipass aliases*Context statuscolumn (active/inactive); JSON/YAML gaincontext-status/context_statusmultipass unalias --allExisting aliases in non-default contexts are kept, not deleted or merged. They show as
inactiveinmultipass aliases, and users can recreate them indefaultor remove them withunalias <context>.<name>.Drive-by fixes:
launchshowed "unable to create alias" for aliases that were actually created fine, and said nothing when one really failed. It now only warns about real failures.multipass aliasescould print an empty table with just the headers when there were no aliases left. It now says "No aliases defined." like it should.defaultwiped every alias indefault. Now it only removes the deleted instance's own aliases, and cleans up their scripts.Updated tests and documentation as well.
MULTI-2692