Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/pet-poetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mod pyproject_toml;
mod telemetry;

lazy_static! {
static ref POETRY_ENV_NAME_PATTERN: Regex = Regex::new(r"^.+-[A-Za-z0-9_-]{8}-py.*$")
static ref POETRY_ENV_NAME_PATTERN: Regex = Regex::new(r"^.+-[A-Za-z0-9_-]{8}-py\d+\.\d+$")
.expect("Error generating RegEx for poetry environment name pattern");
}

Expand Down
8 changes: 5 additions & 3 deletions crates/pet-poetry/tests/path_identification_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mod tests {

if path_str.contains("pypoetry") && path_str.contains("virtualenvs") {
if let Some(dir_name) = path.file_name().and_then(|n| n.to_str()) {
let re = Regex::new(r"^.+-[A-Za-z0-9_-]{8}-py.*$").unwrap();
let re = Regex::new(r"^.+-[A-Za-z0-9_-]{8}-py\d+\.\d+$").unwrap();
return re.is_match(dir_name);
}
}
Expand Down Expand Up @@ -97,8 +97,10 @@ mod tests {
}

#[test]
fn test_poetry_path_pattern_no_version() {
assert!(test_poetry_cache_path_pattern(
fn test_poetry_path_pattern_no_version_rejected() {
// Poetry always includes the Python version (major.minor) in the environment name
// A name ending in just "py" without version should not match
assert!(!test_poetry_cache_path_pattern(
"/home/user/.cache/pypoetry/virtualenvs/testproject-XyZ12345-py"
));
}
Expand Down
Loading