Skip to content

Commit

Permalink
Merge branch 'main' into update-pep508
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Mar 29, 2024
2 parents fc91d87 + b3695f6 commit 675258f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ _Unreleased_

- Fix adding relative path dependencies outside the project root #928

- Fix error on using -v or -q with `rye fmt` or `rye lint`. #959

- Fix rye fetch detection of registered toolchain. #931

<!-- released start -->

## 0.31.0
Expand Down
12 changes: 11 additions & 1 deletion rye/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,16 @@ pub fn fetch(
version: &PythonVersionRequest,
options: FetchOptions,
) -> Result<PythonVersion, Error> {
// Check if there is registered toolchain that matches the request
if options.target_path.is_none() {
if let Ok(version) = PythonVersion::try_from(version.clone()) {
let py_bin = get_toolchain_python_bin(&version)?;
if !options.force && py_bin.is_file() {
echo!(if verbose options.output, "Python version already downloaded. Skipping.");
return Ok(version);
}
}
}
let (version, url, sha256) = match get_download_url(version) {
Some(result) => result,
None => bail!("unknown version {}", version),
Expand All @@ -400,7 +410,7 @@ pub fn fetch(
None => {
let target_dir = get_canonical_py_path(&version)?;
let target_py_bin = get_toolchain_python_bin(&version)?;
if target_dir.is_dir() && target_py_bin.is_file() {
if target_py_bin.is_file() {
if !options.force {
echo!(if verbose options.output, "Python version already downloaded. Skipping.");
return Ok(version);
Expand Down
6 changes: 4 additions & 2 deletions rye/src/utils/ruff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,18 @@ pub fn execute_ruff(args: RuffArgs, extra_args: &[&str]) -> Result<(), Error> {
project.workspace_path().join(".ruff_cache"),
);
}
ruff_cmd.args(extra_args);

match output {
CommandOutput::Normal => {}
CommandOutput::Verbose => {
ruff_cmd.arg("--verbose");
}
CommandOutput::Quiet => {
ruff_cmd.arg("-q");
ruff_cmd.arg("--quiet");
}
}
ruff_cmd.args(extra_args);

ruff_cmd.args(args.extra_args);

ruff_cmd.arg("--");
Expand Down
49 changes: 49 additions & 0 deletions rye/tests/test_version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use crate::common::{rye_cmd_snapshot, Space};

mod common;

#[test]
fn test_version_show() {
let space = Space::new();
space.init("my-project");
rye_cmd_snapshot!(space.rye_cmd().arg("version"), @r###"
success: true
exit_code: 0
----- stdout -----
0.1.0
----- stderr -----
"###);
}

#[test]
fn test_version_bump() {
let space = Space::new();
space.init("my-project");
rye_cmd_snapshot!(space.rye_cmd().arg("version").arg("--bump").arg("patch"), @r###"
success: true
exit_code: 0
----- stdout -----
version bumped to 0.1.1
----- stderr -----
"###);

rye_cmd_snapshot!(space.rye_cmd().arg("version").arg("--bump").arg("minor"), @r###"
success: true
exit_code: 0
----- stdout -----
version bumped to 0.2.0
----- stderr -----
"###);

rye_cmd_snapshot!(space.rye_cmd().arg("version").arg("--bump").arg("major"), @r###"
success: true
exit_code: 0
----- stdout -----
version bumped to 1.0.0
----- stderr -----
"###);
}

0 comments on commit 675258f

Please sign in to comment.