Skip to content

Commit a5d7753

Browse files
authored
Merge pull request #1176 from pkgxdev/fixes/v0.0
Fixes/v0.0
2 parents cfb5874 + e238cc3 commit a5d7753

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

crates/cli/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2929
}
3030

3131
if flags.version_n_continue {
32-
print_version(flags.json.is_some());
32+
eprintln!("{}", get_version_string(flags.json.is_some()));
3333
}
3434

3535
match mode {
@@ -38,7 +38,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
3838
Ok(())
3939
}
4040
args::Mode::Version => {
41-
print_version(flags.json.is_some());
41+
println!("{}", get_version_string(flags.json.is_some()));
4242
Ok(())
4343
}
4444
args::Mode::Query => {
@@ -101,13 +101,13 @@ async fn setup(
101101
Ok((conn, did_sync, config, spinner))
102102
}
103103

104-
fn print_version(json: bool) {
104+
fn get_version_string(json: bool) -> String {
105105
if !json {
106-
eprintln!("pkgx {}", env!("CARGO_PKG_VERSION"));
106+
format!("pkgx {}", env!("CARGO_PKG_VERSION"))
107107
} else {
108-
eprintln!(
108+
format!(
109109
"{{\"program\": \"pkgx\", \"version\": \"{}\"}}",
110110
env!("CARGO_PKG_VERSION")
111-
);
111+
)
112112
}
113113
}

crates/lib/src/install.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,25 @@ async fn symlink(installation: &Installation, config: &Config) -> Result<(), Box
158158
"{}.{}",
159159
installation.pkg.version.major, installation.pkg.version.minor
160160
);
161-
let minor_range = VersionReq::caret(&v_mm)?;
161+
let minor_range = if installation.pkg.version.major > 0 {
162+
VersionReq::caret(&v_mm)?
163+
} else {
164+
VersionReq::parse(&format!(
165+
">={},<0.{}",
166+
v_mm,
167+
installation.pkg.version.minor + 1
168+
))?
169+
};
162170
let most_minor = versions
163171
.iter()
164172
.filter(|(version, _)| minor_range.satisfies(version))
165173
.next_back()
166-
.ok_or_else(|| anyhow::anyhow!("Could not find most minor version"))?;
174+
.ok_or_else(|| {
175+
anyhow::anyhow!(
176+
"Could not find most minor version for {}",
177+
installation.pkg.project
178+
)
179+
})?;
167180

168181
if most_minor.0 != installation.pkg.version {
169182
return Ok(());

0 commit comments

Comments
 (0)