Skip to content

Commit

Permalink
chore: merge branch 'main' into integrity-check
Browse files Browse the repository at this point in the history
  • Loading branch information
beeb committed Aug 12, 2024
2 parents 7097e25 + 17ca26b commit fa823b8
Show file tree
Hide file tree
Showing 8 changed files with 482 additions and 443 deletions.
530 changes: 254 additions & 276 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,27 @@ pub struct Install {
pub rev: Option<String>,

/// If set, this command will delete the existing remappings and re-create them
#[arg(long, default_value_t = false)]
#[arg(short = 'g', long, default_value_t = false)]
pub regenerate_remappings: bool,

/// If set, this command will install the recursive dependencies (via submodules or via
/// soldeer)
#[arg(short = 'd', long, default_value_t = false)]
pub recursive_deps: bool,
}

/// Update dependencies by reading the config file
#[derive(Debug, Clone, Parser)]
#[clap(after_help = "For more information, read the README.md")]
pub struct Update {
/// If set, this command will delete the existing remappings and re-create them
#[arg(long, default_value_t = false)]
#[arg(short = 'g', long, default_value_t = false)]
pub regenerate_remappings: bool,

/// If set, this command will install the recursive dependencies (via submodules or via
/// soldeer)
#[arg(short = 'd', long, default_value_t = false)]
pub recursive_deps: bool,
}

/// Display the version of Soldeer
Expand Down
14 changes: 14 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ pub struct SoldeerConfig {

#[serde(default)]
pub remappings_location: RemappingsLocation,

#[serde(default)]
pub recursive_deps: bool,
}

impl Default for SoldeerConfig {
Expand All @@ -56,6 +59,7 @@ impl Default for SoldeerConfig {
remappings_version: true,
remappings_prefix: String::new(),
remappings_location: Default::default(),
recursive_deps: false,
}
}
}
Expand Down Expand Up @@ -110,6 +114,7 @@ impl Dependency {
}
}

#[allow(dead_code)]
pub fn url(&self) -> Option<&String> {
match self {
Dependency::Http(dep) => dep.url.as_ref(),
Expand Down Expand Up @@ -184,6 +189,7 @@ impl Dependency {
}
}

#[allow(dead_code)]
pub fn as_http(&self) -> Option<&HttpDependency> {
if let Self::Http(v) = self {
Some(v)
Expand All @@ -192,6 +198,7 @@ impl Dependency {
}
}

#[allow(dead_code)]
pub fn as_git(&self) -> Option<&GitDependency> {
if let Self::Git(v) = self {
Some(v)
Expand Down Expand Up @@ -255,6 +262,10 @@ pub fn get_config_path() -> Result<PathBuf> {
}
}

/// Read the list of dependencies from the config file
///
/// If no config file path is provided, then the path is inferred automatically
/// The returned list is sorted by name and version
pub fn read_config_deps(path: Option<PathBuf>) -> Result<Vec<Dependency>> {
let path: PathBuf = match path {
Some(p) => p,
Expand All @@ -270,6 +281,9 @@ pub fn read_config_deps(path: Option<PathBuf>) -> Result<Vec<Dependency>> {
for (name, v) in data {
dependencies.push(parse_dependency(name, v)?);
}
dependencies
.sort_unstable_by(|a, b| a.name().cmp(b.name()).then_with(|| a.version().cmp(b.version())));

Ok(dependencies)
}

Expand Down
Loading

0 comments on commit fa823b8

Please sign in to comment.