aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/package
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/package')
-rw-r--r--crates/shirabe/src/package/loader/array_loader.rs20
-rw-r--r--crates/shirabe/src/package/loader/json_loader.rs3
-rw-r--r--crates/shirabe/src/package/locker.rs108
-rw-r--r--crates/shirabe/src/package/version/version_bumper.rs3
-rw-r--r--crates/shirabe/src/package/version/version_guesser.rs27
5 files changed, 84 insertions, 77 deletions
diff --git a/crates/shirabe/src/package/loader/array_loader.rs b/crates/shirabe/src/package/loader/array_loader.rs
index 07ad11f..b85fbe6 100644
--- a/crates/shirabe/src/package/loader/array_loader.rs
+++ b/crates/shirabe/src/package/loader/array_loader.rs
@@ -15,7 +15,6 @@ use crate::package::RootPackageHandle;
use crate::package::SUPPORTED_LINK_TYPES;
use crate::package::loader::LoaderInterface;
use crate::package::version::VersionParser;
-use anyhow::Result;
use chrono::Utc;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
@@ -152,7 +151,7 @@ impl LoaderInterface for ArrayLoader {
&self,
mut config: IndexMap<String, PhpMixed>,
class: Option<String>,
- ) -> Result<PackageInterfaceHandle> {
+ ) -> anyhow::Result<PackageInterfaceHandle> {
let class = class.unwrap_or_else(|| "Composer\\Package\\CompletePackage".to_string());
if class != "Composer\\Package\\CompletePackage"
@@ -199,7 +198,7 @@ impl ArrayLoader {
pub fn load_packages(
&self,
versions: Vec<IndexMap<String, PhpMixed>>,
- ) -> Result<Vec<PackageInterfaceHandle>> {
+ ) -> anyhow::Result<Vec<PackageInterfaceHandle>> {
let mut packages: Vec<PackageInterfaceHandle> = vec![];
let mut link_cache: IndexMap<
String,
@@ -222,7 +221,7 @@ impl ArrayLoader {
&self,
config: &IndexMap<String, PhpMixed>,
class: &str,
- ) -> Result<CompleteOrRootPackage> {
+ ) -> anyhow::Result<CompleteOrRootPackage> {
if !config.contains_key("name") {
return Err(UnexpectedValueException {
message: format!(
@@ -312,7 +311,7 @@ impl ArrayLoader {
&self,
mut package: CompleteOrRootPackage,
config: &mut IndexMap<String, PhpMixed>,
- ) -> Result<PackageInterfaceHandle> {
+ ) -> anyhow::Result<PackageInterfaceHandle> {
package
.package_mut()
.set_type(if let Some(t) = config.get("type") {
@@ -704,7 +703,7 @@ impl ArrayLoader {
>,
package: &mut CompleteOrRootPackage,
config: &IndexMap<String, PhpMixed>,
- ) -> Result<()> {
+ ) -> anyhow::Result<()> {
let name = package.get_name().to_string();
let pretty_version = package.get_pretty_version().to_string();
@@ -786,7 +785,7 @@ impl ArrayLoader {
source_version: &str,
description: &str,
links: IndexMap<String, PhpMixed>,
- ) -> Result<IndexMap<String, Link>> {
+ ) -> anyhow::Result<IndexMap<String, Link>> {
let mut res: IndexMap<String, Link> = IndexMap::new();
for (target, constraint) in links {
if !is_string(&constraint) {
@@ -818,7 +817,7 @@ impl ArrayLoader {
description: &str,
target: &str,
pretty_constraint: &str,
- ) -> Result<Link> {
+ ) -> anyhow::Result<Link> {
// PHP: if (!\is_string($prettyConstraint)) — always true in Rust signature, kept for parity
let _ = pretty_constraint;
@@ -856,7 +855,10 @@ impl ArrayLoader {
/// @param mixed[] $config the entire package config
///
/// @return string|null normalized version of the branch alias or null if there is none
- pub fn get_branch_alias(&self, config: &IndexMap<String, PhpMixed>) -> Result<Option<String>> {
+ pub fn get_branch_alias(
+ &self,
+ config: &IndexMap<String, PhpMixed>,
+ ) -> anyhow::Result<Option<String>> {
if !config.contains_key("version") || !is_scalar(config.get("version").unwrap()) {
return Err(UnexpectedValueException {
message: "no/invalid version defined".to_string(),
diff --git a/crates/shirabe/src/package/loader/json_loader.rs b/crates/shirabe/src/package/loader/json_loader.rs
index d48a2fe..205028f 100644
--- a/crates/shirabe/src/package/loader/json_loader.rs
+++ b/crates/shirabe/src/package/loader/json_loader.rs
@@ -3,7 +3,6 @@
use crate::json::JsonFile;
use crate::package::PackageInterfaceHandle;
use crate::package::loader::LoaderInterface;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_php_shim::{PhpMixed, TypeError};
use std::path::Path;
@@ -22,7 +21,7 @@ impl JsonLoader {
Self { loader }
}
- pub fn load(&self, json: JsonLoaderInput) -> Result<PackageInterfaceHandle> {
+ pub fn load(&self, json: JsonLoaderInput) -> anyhow::Result<PackageInterfaceHandle> {
let config = match json {
JsonLoaderInput::File(mut json_file) => json_file.read()?,
JsonLoaderInput::String(ref s) if Path::new(s).exists() => {
diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs
index 09c2def..94f4625 100644
--- a/crates/shirabe/src/package/locker.rs
+++ b/crates/shirabe/src/package/locker.rs
@@ -23,7 +23,6 @@ use crate::repository::RepositoryInterfaceHandle;
use crate::repository::RootPackageRepository;
use crate::util::Git as GitUtil;
use crate::util::ProcessExecutor;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::seld::json_lint::ParsingException;
@@ -84,7 +83,7 @@ impl Locker {
}
/// Returns the md5 hash of the sorted content of the composer file.
- pub fn get_content_hash(composer_file_contents: &str) -> Result<String> {
+ pub fn get_content_hash(composer_file_contents: &str) -> anyhow::Result<String> {
let content = JsonFile::parse_json(Some(composer_file_contents), Some("composer.json"))?;
let content_map: IndexMap<String, PhpMixed> = match &content {
PhpMixed::Array(m) => m.iter().map(|(k, v)| (k.clone(), v.clone())).collect(),
@@ -151,7 +150,7 @@ impl Locker {
}
/// Checks whether the lock file is still up to date with the current hash
- pub fn is_fresh(&mut self) -> Result<bool> {
+ pub fn is_fresh(&mut self) -> anyhow::Result<bool> {
let lock = self.lock_file.read()?;
let lock_map: IndexMap<String, PhpMixed> = match lock {
PhpMixed::Array(m) => m.into_iter().collect(),
@@ -182,7 +181,7 @@ impl Locker {
pub fn get_locked_repository(
&mut self,
with_dev_reqs: bool,
- ) -> Result<LockArrayRepositoryHandle> {
+ ) -> anyhow::Result<LockArrayRepositoryHandle> {
let lock_data = self.get_lock_data()?;
let packages: LockArrayRepositoryHandle =
LockArrayRepositoryHandle::new(LockArrayRepository::new(vec![])?);
@@ -281,7 +280,7 @@ impl Locker {
}
/// @return string[] Names of dependencies installed through require-dev
- pub fn get_dev_package_names(&mut self) -> Result<Vec<String>> {
+ pub fn get_dev_package_names(&mut self) -> anyhow::Result<Vec<String>> {
let mut names: Vec<String> = vec![];
let lock_data = self.get_lock_data()?;
if let Some(PhpMixed::List(list)) = lock_data.get("packages-dev") {
@@ -298,7 +297,7 @@ impl Locker {
}
/// Returns the platform requirements stored in the lock file
- pub fn get_platform_requirements(&mut self, with_dev_reqs: bool) -> Result<Vec<Link>> {
+ pub fn get_platform_requirements(&mut self, with_dev_reqs: bool) -> anyhow::Result<Vec<Link>> {
let lock_data = self.get_lock_data()?;
let mut requirements: IndexMap<String, Link> = IndexMap::new();
@@ -341,7 +340,7 @@ impl Locker {
}
/// @return key-of<BasePackage::STABILITIES>
- pub fn get_minimum_stability(&mut self) -> Result<String> {
+ pub fn get_minimum_stability(&mut self) -> anyhow::Result<String> {
let lock_data = self.get_lock_data()?;
Ok(lock_data
@@ -352,7 +351,7 @@ impl Locker {
}
/// @return array<string, string>
- pub fn get_stability_flags(&mut self) -> Result<IndexMap<String, String>> {
+ pub fn get_stability_flags(&mut self) -> anyhow::Result<IndexMap<String, String>> {
let lock_data = self.get_lock_data()?;
Ok(lock_data
@@ -368,7 +367,7 @@ impl Locker {
.unwrap_or_default())
}
- pub fn get_prefer_stable(&mut self) -> Result<Option<bool>> {
+ pub fn get_prefer_stable(&mut self) -> anyhow::Result<Option<bool>> {
let lock_data = self.get_lock_data()?;
// return null if not set to allow caller logic to choose the
@@ -376,14 +375,14 @@ impl Locker {
Ok(lock_data.get("prefer-stable").and_then(|v| v.as_bool()))
}
- pub fn get_prefer_lowest(&mut self) -> Result<Option<bool>> {
+ pub fn get_prefer_lowest(&mut self) -> anyhow::Result<Option<bool>> {
let lock_data = self.get_lock_data()?;
Ok(lock_data.get("prefer-lowest").and_then(|v| v.as_bool()))
}
/// @return array<string, string>
- pub fn get_platform_overrides(&mut self) -> Result<IndexMap<String, String>> {
+ pub fn get_platform_overrides(&mut self) -> anyhow::Result<IndexMap<String, String>> {
let lock_data = self.get_lock_data()?;
Ok(lock_data
@@ -400,7 +399,7 @@ impl Locker {
}
/// @return string[][]
- pub fn get_aliases(&mut self) -> Result<Vec<IndexMap<String, String>>> {
+ pub fn get_aliases(&mut self) -> anyhow::Result<Vec<IndexMap<String, String>>> {
let lock_data = self.get_lock_data()?;
Ok(lock_data
@@ -425,7 +424,7 @@ impl Locker {
.unwrap_or_default())
}
- pub fn get_plugin_api(&mut self) -> Result<String> {
+ pub fn get_plugin_api(&mut self) -> anyhow::Result<String> {
let lock_data = self.get_lock_data()?;
Ok(lock_data
@@ -436,7 +435,7 @@ impl Locker {
}
/// @return array<string, mixed>
- pub fn get_lock_data(&mut self) -> Result<IndexMap<String, PhpMixed>> {
+ pub fn get_lock_data(&mut self) -> anyhow::Result<IndexMap<String, PhpMixed>> {
if let Some(cache) = self.lock_data_cache.borrow().clone() {
return Ok(cache);
}
@@ -473,7 +472,7 @@ impl Locker {
prefer_lowest: bool,
platform_overrides: IndexMap<String, PhpMixed>,
write: bool,
- ) -> Result<bool> {
+ ) -> anyhow::Result<bool> {
// keep old default branch names normalized to DEFAULT_BRANCH_ALIAS for BC as that is how Composer 1 outputs the lock file
// when loading the lock file the version is anyway ignored in Composer 2, so it has no adverse effect
let aliases: Vec<IndexMap<String, PhpMixed>> = array_map(
@@ -635,7 +634,7 @@ impl Locker {
Ok(false)
}
- fn is_locked_result(&mut self) -> Result<bool> {
+ fn is_locked_result(&mut self) -> anyhow::Result<bool> {
Ok(self.is_locked())
}
@@ -646,7 +645,7 @@ impl Locker {
data_processor: Option<
Box<dyn FnOnce(IndexMap<String, PhpMixed>) -> IndexMap<String, PhpMixed>>,
>,
- ) -> Result<()> {
+ ) -> anyhow::Result<()> {
let contents = file_get_contents(composer_json.get_path());
let contents = match contents {
Some(s) => s,
@@ -719,7 +718,7 @@ impl Locker {
}
/// @param PackageInterface[] $packages
- fn lock_packages(&mut self, packages: &[PackageInterfaceHandle]) -> Result<PhpMixed> {
+ fn lock_packages(&mut self, packages: &[PackageInterfaceHandle]) -> anyhow::Result<PhpMixed> {
let mut locked: Vec<IndexMap<String, PhpMixed>> = vec![];
for package in packages {
@@ -791,7 +790,10 @@ impl Locker {
}
/// Returns the packages's datetime for its source reference.
- fn get_package_time(&mut self, package: PackageInterfaceHandle) -> Result<Option<String>> {
+ fn get_package_time(
+ &mut self,
+ package: PackageInterfaceHandle,
+ ) -> anyhow::Result<Option<String>> {
if !function_exists("proc_open") {
return Ok(None);
}
@@ -895,7 +897,7 @@ impl Locker {
&mut self,
package: RootPackageInterfaceHandle,
include_dev: bool,
- ) -> Result<Vec<String>> {
+ ) -> anyhow::Result<Vec<String>> {
let mut missing_requirement_info: Vec<String> = vec![];
let mut missing_requirements = false;
let mut sets: Vec<SetEntry> = vec![SetEntry {
@@ -1006,18 +1008,21 @@ impl Locker {
pub trait LockerInterface: std::fmt::Debug {
fn get_json_file(&self) -> &JsonFile;
fn is_locked(&mut self) -> bool;
- fn is_fresh(&mut self) -> Result<bool>;
- fn get_locked_repository(&mut self, with_dev_reqs: bool) -> Result<LockArrayRepositoryHandle>;
- fn get_dev_package_names(&mut self) -> Result<Vec<String>>;
- fn get_platform_requirements(&mut self, with_dev_reqs: bool) -> Result<Vec<Link>>;
- fn get_minimum_stability(&mut self) -> Result<String>;
- fn get_stability_flags(&mut self) -> Result<IndexMap<String, String>>;
- fn get_prefer_stable(&mut self) -> Result<Option<bool>>;
- fn get_prefer_lowest(&mut self) -> Result<Option<bool>>;
- fn get_platform_overrides(&mut self) -> Result<IndexMap<String, String>>;
- fn get_aliases(&mut self) -> Result<Vec<IndexMap<String, String>>>;
- fn get_plugin_api(&mut self) -> Result<String>;
- fn get_lock_data(&mut self) -> Result<IndexMap<String, PhpMixed>>;
+ fn is_fresh(&mut self) -> anyhow::Result<bool>;
+ fn get_locked_repository(
+ &mut self,
+ with_dev_reqs: bool,
+ ) -> anyhow::Result<LockArrayRepositoryHandle>;
+ fn get_dev_package_names(&mut self) -> anyhow::Result<Vec<String>>;
+ fn get_platform_requirements(&mut self, with_dev_reqs: bool) -> anyhow::Result<Vec<Link>>;
+ fn get_minimum_stability(&mut self) -> anyhow::Result<String>;
+ fn get_stability_flags(&mut self) -> anyhow::Result<IndexMap<String, String>>;
+ fn get_prefer_stable(&mut self) -> anyhow::Result<Option<bool>>;
+ fn get_prefer_lowest(&mut self) -> anyhow::Result<Option<bool>>;
+ fn get_platform_overrides(&mut self) -> anyhow::Result<IndexMap<String, String>>;
+ fn get_aliases(&mut self) -> anyhow::Result<Vec<IndexMap<String, String>>>;
+ fn get_plugin_api(&mut self) -> anyhow::Result<String>;
+ fn get_lock_data(&mut self) -> anyhow::Result<IndexMap<String, PhpMixed>>;
#[allow(clippy::too_many_arguments, reason = "to keep PHP signature")]
fn set_lock_data(
&mut self,
@@ -1032,19 +1037,19 @@ pub trait LockerInterface: std::fmt::Debug {
prefer_lowest: bool,
platform_overrides: IndexMap<String, PhpMixed>,
write: bool,
- ) -> Result<bool>;
+ ) -> anyhow::Result<bool>;
fn update_hash(
&mut self,
composer_json: &JsonFile,
data_processor: Option<
Box<dyn FnOnce(IndexMap<String, PhpMixed>) -> IndexMap<String, PhpMixed>>,
>,
- ) -> Result<()>;
+ ) -> anyhow::Result<()>;
fn get_missing_requirement_info(
&mut self,
package: RootPackageInterfaceHandle,
include_dev: bool,
- ) -> Result<Vec<String>>;
+ ) -> anyhow::Result<Vec<String>>;
}
impl LockerInterface for Locker {
@@ -1056,51 +1061,54 @@ impl LockerInterface for Locker {
self.is_locked()
}
- fn is_fresh(&mut self) -> Result<bool> {
+ fn is_fresh(&mut self) -> anyhow::Result<bool> {
self.is_fresh()
}
- fn get_locked_repository(&mut self, with_dev_reqs: bool) -> Result<LockArrayRepositoryHandle> {
+ fn get_locked_repository(
+ &mut self,
+ with_dev_reqs: bool,
+ ) -> anyhow::Result<LockArrayRepositoryHandle> {
self.get_locked_repository(with_dev_reqs)
}
- fn get_dev_package_names(&mut self) -> Result<Vec<String>> {
+ fn get_dev_package_names(&mut self) -> anyhow::Result<Vec<String>> {
self.get_dev_package_names()
}
- fn get_platform_requirements(&mut self, with_dev_reqs: bool) -> Result<Vec<Link>> {
+ fn get_platform_requirements(&mut self, with_dev_reqs: bool) -> anyhow::Result<Vec<Link>> {
self.get_platform_requirements(with_dev_reqs)
}
- fn get_minimum_stability(&mut self) -> Result<String> {
+ fn get_minimum_stability(&mut self) -> anyhow::Result<String> {
self.get_minimum_stability()
}
- fn get_stability_flags(&mut self) -> Result<IndexMap<String, String>> {
+ fn get_stability_flags(&mut self) -> anyhow::Result<IndexMap<String, String>> {
self.get_stability_flags()
}
- fn get_prefer_stable(&mut self) -> Result<Option<bool>> {
+ fn get_prefer_stable(&mut self) -> anyhow::Result<Option<bool>> {
self.get_prefer_stable()
}
- fn get_prefer_lowest(&mut self) -> Result<Option<bool>> {
+ fn get_prefer_lowest(&mut self) -> anyhow::Result<Option<bool>> {
self.get_prefer_lowest()
}
- fn get_platform_overrides(&mut self) -> Result<IndexMap<String, String>> {
+ fn get_platform_overrides(&mut self) -> anyhow::Result<IndexMap<String, String>> {
self.get_platform_overrides()
}
- fn get_aliases(&mut self) -> Result<Vec<IndexMap<String, String>>> {
+ fn get_aliases(&mut self) -> anyhow::Result<Vec<IndexMap<String, String>>> {
self.get_aliases()
}
- fn get_plugin_api(&mut self) -> Result<String> {
+ fn get_plugin_api(&mut self) -> anyhow::Result<String> {
self.get_plugin_api()
}
- fn get_lock_data(&mut self) -> Result<IndexMap<String, PhpMixed>> {
+ fn get_lock_data(&mut self) -> anyhow::Result<IndexMap<String, PhpMixed>> {
self.get_lock_data()
}
@@ -1118,7 +1126,7 @@ impl LockerInterface for Locker {
prefer_lowest: bool,
platform_overrides: IndexMap<String, PhpMixed>,
write: bool,
- ) -> Result<bool> {
+ ) -> anyhow::Result<bool> {
self.set_lock_data(
packages,
dev_packages,
@@ -1140,7 +1148,7 @@ impl LockerInterface for Locker {
data_processor: Option<
Box<dyn FnOnce(IndexMap<String, PhpMixed>) -> IndexMap<String, PhpMixed>>,
>,
- ) -> Result<()> {
+ ) -> anyhow::Result<()> {
self.update_hash(composer_json, data_processor)
}
@@ -1148,7 +1156,7 @@ impl LockerInterface for Locker {
&mut self,
package: RootPackageInterfaceHandle,
include_dev: bool,
- ) -> Result<Vec<String>> {
+ ) -> anyhow::Result<Vec<String>> {
self.get_missing_requirement_info(package, include_dev)
}
}
diff --git a/crates/shirabe/src/package/version/version_bumper.rs b/crates/shirabe/src/package/version/version_bumper.rs
index 4deb450..4f2d324 100644
--- a/crates/shirabe/src/package/version/version_bumper.rs
+++ b/crates/shirabe/src/package/version/version_bumper.rs
@@ -5,7 +5,6 @@ use crate::package::dumper::ArrayDumper;
use crate::package::loader::ArrayLoader;
use crate::package::version::VersionParser;
use crate::util::Platform;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_semver::Intervals;
@@ -19,7 +18,7 @@ impl VersionBumper {
&self,
constraint: &AnyConstraint,
package: PackageInterfaceHandle,
- ) -> Result<String> {
+ ) -> anyhow::Result<String> {
let parser = VersionParser::new();
let pretty_constraint = constraint.get_pretty_string();
if pretty_constraint.starts_with("dev-") {
diff --git a/crates/shirabe/src/package/version/version_guesser.rs b/crates/shirabe/src/package/version/version_guesser.rs
index 6fba7c4..249646c 100644
--- a/crates/shirabe/src/package/version/version_guesser.rs
+++ b/crates/shirabe/src/package/version/version_guesser.rs
@@ -11,7 +11,6 @@ use crate::util::Platform;
use crate::util::ProcessExecutor;
use crate::util::Svn as SvnUtil;
use crate::util::sync_executor;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
@@ -28,9 +27,9 @@ pub trait VersionGuesserInterface: std::fmt::Debug {
&mut self,
package_config: &IndexMap<String, PhpMixed>,
path: &str,
- ) -> Result<Option<VersionData>>;
+ ) -> anyhow::Result<Option<VersionData>>;
- fn get_root_version_from_env(&self) -> Result<String>;
+ fn get_root_version_from_env(&self) -> anyhow::Result<String>;
}
/// Try to guess the current version number based on different VCS configuration.
@@ -103,7 +102,7 @@ impl VersionGuesser {
&mut self,
package_config: &IndexMap<String, PhpMixed>,
path: &str,
- ) -> Result<Option<VersionData>> {
+ ) -> anyhow::Result<Option<VersionData>> {
// For testing only (ref VersionGuesserMock::guessVersion returns null).
if self.mock {
return Ok(None);
@@ -207,7 +206,7 @@ impl VersionGuesser {
&mut self,
package_config: &IndexMap<String, PhpMixed>,
path: &str,
- ) -> Result<VersionData> {
+ ) -> anyhow::Result<VersionData> {
GitUtil::clean_env(&self.process);
let mut commit: Option<String> = None;
let mut version: Option<String> = None;
@@ -365,7 +364,7 @@ impl VersionGuesser {
}
/// @return array{version: string, pretty_version: string}|null
- fn version_from_git_tags(&mut self, path: &str) -> Result<Option<(String, String)>> {
+ fn version_from_git_tags(&mut self, path: &str) -> anyhow::Result<Option<(String, String)>> {
// try to fetch current version from git tags
let mut output = String::new();
if 0 == self.process.borrow_mut().execute_args(
@@ -394,7 +393,7 @@ impl VersionGuesser {
&mut self,
package_config: &IndexMap<String, PhpMixed>,
path: &str,
- ) -> Result<Option<VersionData>> {
+ ) -> anyhow::Result<Option<VersionData>> {
// try to fetch current version from hg branch
let mut output = String::new();
if 0 == self.process.borrow_mut().execute_args(
@@ -492,7 +491,7 @@ impl VersionGuesser {
mut branches: Vec<String>,
scm_cmdline: Vec<String>,
path: &str,
- ) -> Result<FeatureVersionResult> {
+ ) -> anyhow::Result<FeatureVersionResult> {
let mut pretty_version: Option<String> = version.clone();
let mut version = version;
@@ -546,7 +545,7 @@ impl VersionGuesser {
// PHP runs every candidate diff in parallel and cancels the siblings once a zero-length
// diff is found; the single-threaded sync bridge block_on's each diff serially and stops
// at the first zero-length match.
- let result: Result<()> = (|| -> Result<()> {
+ let result: anyhow::Result<()> = (|| -> anyhow::Result<()> {
let mut last_index: i64 = -1;
for (index, candidate) in branches.iter().enumerate() {
let index = index as i64;
@@ -635,7 +634,7 @@ impl VersionGuesser {
}
/// @return array{version: string|null, commit: '', pretty_version: string|null}
- fn guess_fossil_version(&mut self, path: &str) -> Result<VersionData> {
+ fn guess_fossil_version(&mut self, path: &str) -> anyhow::Result<VersionData> {
let mut version: Option<String> = None;
let mut pretty_version: Option<String> = None;
@@ -687,7 +686,7 @@ impl VersionGuesser {
&mut self,
package_config: &IndexMap<String, PhpMixed>,
path: &str,
- ) -> Result<Option<VersionData>> {
+ ) -> anyhow::Result<Option<VersionData>> {
SvnUtil::clean_env();
// try to fetch current version from svn
@@ -760,7 +759,7 @@ impl VersionGuesser {
Ok(None)
}
- pub fn get_root_version_from_env(&self) -> Result<String> {
+ pub fn get_root_version_from_env(&self) -> anyhow::Result<String> {
let version = Platform::get_env("COMPOSER_ROOT_VERSION");
let version = match version {
Some(v) if !v.is_empty() => v,
@@ -789,11 +788,11 @@ impl VersionGuesserInterface for VersionGuesser {
&mut self,
package_config: &IndexMap<String, PhpMixed>,
path: &str,
- ) -> Result<Option<VersionData>> {
+ ) -> anyhow::Result<Option<VersionData>> {
VersionGuesser::guess_version(self, package_config, path)
}
- fn get_root_version_from_env(&self) -> Result<String> {
+ fn get_root_version_from_env(&self) -> anyhow::Result<String> {
VersionGuesser::get_root_version_from_env(self)
}
}