refactor: disable julia startup file for julia package update (#983)
* refactor(julia): disable julia startup file for julia package update * feat(julia): add configuration option for julia startup file * fix: deny unknown fields on JuliaConfig deserialisation Co-authored-by: SteveLauC <stevelauc@outlook.com> * doc(julia): clarify startup_file option purpose --------- Co-authored-by: SteveLauC <stevelauc@outlook.com>
This commit is contained in:
committed by
GitHub
parent
444689c899
commit
202897ba35
@@ -270,3 +270,11 @@
|
|||||||
# and the update will be installed system-wide, i.e., available to all users.
|
# and the update will be installed system-wide, i.e., available to all users.
|
||||||
# (default: false)
|
# (default: false)
|
||||||
# use_sudo = false
|
# use_sudo = false
|
||||||
|
|
||||||
|
[julia]
|
||||||
|
# If disabled, Topgrade invokes julia with the --startup-file=no CLI option.
|
||||||
|
#
|
||||||
|
# This may be desirable to avoid loading outdated packages with "using" directives
|
||||||
|
# in the startup file, which might cause the update run to fail.
|
||||||
|
# (default: true)
|
||||||
|
# startup_file = true
|
||||||
|
|||||||
@@ -452,6 +452,12 @@ pub struct Lensfun {
|
|||||||
use_sudo: Option<bool>,
|
use_sudo: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Default, Debug, Merge)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct JuliaConfig {
|
||||||
|
startup_file: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default, Debug, Merge)]
|
#[derive(Deserialize, Default, Debug, Merge)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
/// Configuration file
|
/// Configuration file
|
||||||
@@ -518,6 +524,9 @@ pub struct ConfigFile {
|
|||||||
|
|
||||||
#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
|
#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
|
||||||
lensfun: Option<Lensfun>,
|
lensfun: Option<Lensfun>,
|
||||||
|
|
||||||
|
#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
|
||||||
|
julia: Option<JuliaConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn config_directory() -> PathBuf {
|
fn config_directory() -> PathBuf {
|
||||||
@@ -1632,6 +1641,14 @@ impl Config {
|
|||||||
.and_then(|lensfun| lensfun.use_sudo)
|
.and_then(|lensfun| lensfun.use_sudo)
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn julia_use_startup_file(&self) -> bool {
|
||||||
|
self.config_file
|
||||||
|
.julia
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|julia| julia.startup_file)
|
||||||
|
.unwrap_or(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -908,10 +908,15 @@ pub fn update_julia_packages(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
|
|
||||||
print_separator(t!("Julia Packages"));
|
print_separator(t!("Julia Packages"));
|
||||||
|
|
||||||
ctx.run_type()
|
let mut executor = ctx.run_type().execute(julia);
|
||||||
.execute(julia)
|
|
||||||
.args(["-e", "using Pkg; Pkg.update()"])
|
executor.arg(if ctx.config().julia_use_startup_file() {
|
||||||
.status_checked()
|
"--startup-file=yes"
|
||||||
|
} else {
|
||||||
|
"--startup-file=no"
|
||||||
|
});
|
||||||
|
|
||||||
|
executor.args(["-e", "using Pkg; Pkg.update()"]).status_checked()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_helm_repo_update(ctx: &ExecutionContext) -> Result<()> {
|
pub fn run_helm_repo_update(ctx: &ExecutionContext) -> Result<()> {
|
||||||
|
|||||||
Reference in New Issue
Block a user