Skip to content

Commit

Permalink
fix: support multiple versions in lockfile
Browse files Browse the repository at this point in the history
� Conflicts:
�	.mise.lock
�	.mise.toml
�	e2e/cli/test_use
  • Loading branch information
jdx committed Nov 6, 2024
1 parent 448e205 commit 217a519
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
18 changes: 18 additions & 0 deletions .mise.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tools]
actionlint = "1.7.4"
cargo-binstall = "1.10.10"
"cargo:cargo-edit" = "0.13.0"
"cargo:cargo-insta" = "1.41.1"
"cargo:cargo-show" = "0.6.0"
"cargo:git-cliff" = "2.6.1"
"cargo:usage-cli" = "1.1.1"
direnv = "latest"
jq = "1.7.1"
"npm:markdownlint-cli" = "0.42.0"
"npm:prettier" = "3.3.3"
"pipx:toml-sort" = "0.23.1"
python = "3.10.15"
ripgrep = "14.1.1"
shellcheck = "0.10.0"
shfmt = "3.10.0"
tiny = "2.1.0"
4 changes: 2 additions & 2 deletions .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ FOO_NUM = 1
THIS_PROJECT = "{{config_root}}-{{cwd}}"

[tools]
#node = 'lts'
python = { version = "latest" }
shellcheck = "0.10"
shfmt = "3"
jq = "latest"
Expand All @@ -26,6 +24,8 @@ actionlint = "latest"
ripgrep = "latest"
"pipx:toml-sort" = "latest"
"cargo:usage-cli" = "1.2"
python = ["3.11", "3.10"]
tiny = ["1", "2"]
#python = { version = "latest", virtualenv = "{{env.HOME}}/.cache/venv" }
#ruby = "3.1"

Expand Down
8 changes: 8 additions & 0 deletions e2e/lockfile/test_lockfile_use
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ assert "cat .mise.lock" '[tools]
tiny = "3.1.0"'
assert "mise ls tiny --json --current | jq -r '.[0].requested_version'" "3"
assert "mise ls tiny --json --current | jq -r '.[0].version'" "3.1.0"

mise use tiny@1 tiny@2
assert "cat .mise.lock" '[tools]
tiny = ["1.0.0", "2.1.0"]'
assert "mise ls tiny --json --current | jq -r '.[0].requested_version'" "1"
assert "mise ls tiny --json --current | jq -r '.[0].version'" "1.0.0"
assert "mise ls tiny --json --current | jq -r '.[1].requested_version'" "2"
assert "mise ls tiny --json --current | jq -r '.[1].version'" "2.1.0"
3 changes: 2 additions & 1 deletion src/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::sync::Mutex;
#[derive(Debug, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Lockfile {
tools: BTreeMap<String, String>,
tools: BTreeMap<String, Vec<String>>,
}

impl Lockfile {
Expand Down Expand Up @@ -94,6 +94,7 @@ pub fn update_lockfiles(new_versions: &[ToolVersion]) -> Result<()> {
.retain(|k, _| all_tool_names.contains(k) || SETTINGS.disable_tools.contains(k));

for (short, tvl) in tools {
dbg!(short, tvl);
for tv in &tvl.versions {
existing_lockfile
.tools
Expand Down

0 comments on commit 217a519

Please sign in to comment.