-
Notifications
You must be signed in to change notification settings - Fork 104
Add alias command - Review fixes #1235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
26a5afc
Add `alias` command
christiangnrd ad208f4
"Fix" `api` command
christiangnrd 2853856
Add test
christiangnrd 91a4b1f
Remove debug text
christiangnrd 5306353
Test
christiangnrd d32b20e
Merge branch 'main' into pr/1115
IanButterworth 4fecee6
add tests for identified issues
IanButterworth b08988b
bugfix
IanButterworth faee75f
show aliases in `list`
IanButterworth fa1288b
add circular alias detection
IanButterworth fd4b25a
rustfmt
IanButterworth 517adfc
Update command_alias.rs
IanButterworth ed63238
Update operations.rs
IanButterworth 60093bc
Apply suggestions from code review
IanButterworth 09604ca
reverts
IanButterworth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| use crate::config_file::JuliaupConfigChannel; | ||
| use crate::config_file::{load_mut_config_db, save_config_db}; | ||
| use crate::global_paths::GlobalPaths; | ||
| #[cfg(not(windows))] | ||
| use crate::operations::create_symlink; | ||
| use crate::operations::is_valid_channel; | ||
| use crate::versions_file::load_versions_db; | ||
| use anyhow::{bail, Context, Result}; | ||
|
|
||
| pub fn run_command_alias(alias: &str, channel: &str, paths: &GlobalPaths) -> Result<()> { | ||
| let mut config_file = load_mut_config_db(paths) | ||
| .with_context(|| "`alias` command failed to load configuration data.")?; | ||
|
|
||
| let versiondb_data = | ||
| load_versions_db(paths).with_context(|| "`alias` command failed to load versions db.")?; | ||
|
|
||
| if config_file.data.installed_channels.contains_key(alias) { | ||
| bail!("Channel name `{}` is already used.", alias) | ||
| } | ||
|
|
||
| if !config_file.data.installed_channels.contains_key(channel) { | ||
| eprintln!("WARNING: The channel `{}` does not currently exist. If this was a mistake, run `juliaup remove {}` and try again.", channel, alias); | ||
| } | ||
|
|
||
| if is_valid_channel(&versiondb_data, &alias.to_string())? { | ||
IanButterworth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| eprintln!("WARNING: The channel name `{}` is also a system channel. By creating an alias to this channel you are hiding this system channel.", alias); | ||
| } | ||
|
|
||
| config_file.data.installed_channels.insert( | ||
| alias.to_string(), | ||
| JuliaupConfigChannel::AliasedChannel { | ||
| channel: channel.to_string(), | ||
| }, | ||
| ); | ||
|
|
||
| save_config_db(&mut config_file) | ||
| .with_context(|| "`alias` command failed to save configuration db.")?; | ||
|
|
||
| #[cfg(not(windows))] | ||
| { | ||
| if config_file.data.settings.create_channel_symlinks { | ||
| create_symlink( | ||
| &JuliaupConfigChannel::AliasedChannel { | ||
| channel: channel.to_string(), | ||
| }, | ||
| &format!("julia-{}", alias), | ||
| paths, | ||
| )?; | ||
| } | ||
| } | ||
|
|
||
| Ok(()) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.