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
3 changes: 3 additions & 0 deletions e2e/assert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# shellcheck source-path=SCRIPTDIR
source "$TEST_ROOT/style.sh"

# shellcheck disable=SC2034,SC2016
LOCKFILE_HEADER='# @generated - this file is auto-generated by `mise lock` https://mise.jdx.dev/dev-tools/mise-lock.html'

fail() {
title="E2E assertion failed" err "$*"
exit 1
Expand Down
24 changes: 14 additions & 10 deletions e2e/cli/test_use_latest
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,30 @@ assert "mise tool tiny --requested" "latest"

touch mise.lock
assert "mise use dummy@1 tiny@1"
assert "cat mise.lock" '[[tools.dummy]]
version = "1.0.0"
backend = "asdf:dummy"
assert "cat mise.lock" "$LOCKFILE_HEADER

[[tools.dummy]]
version = \"1.0.0\"
backend = \"asdf:dummy\"

[[tools.tiny]]
version = "1.0.0"
backend = "asdf:tiny"'
version = \"1.0.0\"
backend = \"asdf:tiny\""
assert "mise tool dummy --requested" "1"
assert "mise tool tiny --requested" "1"
assert "mise tool dummy --active" "1.0.0"
assert "mise tool tiny --active" "1.0.0"

assert "mise use dummy@latest"
assert "cat mise.lock" '[[tools.dummy]]
version = "2.0.0"
backend = "asdf:dummy"
assert "cat mise.lock" "$LOCKFILE_HEADER

[[tools.dummy]]
version = \"2.0.0\"
backend = \"asdf:dummy\"

[[tools.tiny]]
version = "1.0.0"
backend = "asdf:tiny"'
version = \"1.0.0\"
backend = \"asdf:tiny\""
assert "mise tool dummy --requested" "latest"
assert "mise tool tiny --requested" "1"
assert "mise tool dummy --active" "2.0.0"
Expand Down
44 changes: 27 additions & 17 deletions e2e/lockfile/test_lockfile_use
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,36 @@ assert "mise config get -f mise.toml tools.tiny" "1"
assert "mise where tiny" "$MISE_DATA_DIR/installs/tiny/1.0.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 "cat mise.lock" '[[tools.tiny]]
version = "1.0.0"
backend = "asdf:tiny"'
assert "cat mise.lock" "$LOCKFILE_HEADER

[[tools.tiny]]
version = \"1.0.0\"
backend = \"asdf:tiny\""

assert "mise use tiny@1"
assert "cat mise.lock" '[[tools.tiny]]
version = "1.0.0"
backend = "asdf:tiny"'
assert "cat mise.lock" "$LOCKFILE_HEADER

[[tools.tiny]]
version = \"1.0.0\"
backend = \"asdf:tiny\""
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 up tiny"
assert "cat mise.lock" '[[tools.tiny]]
version = "1.1.0"
backend = "asdf:tiny"'
assert "cat mise.lock" "$LOCKFILE_HEADER

[[tools.tiny]]
version = \"1.1.0\"
backend = \"asdf:tiny\""
assert "mise ls tiny --json --current | jq -r '.[0].requested_version'" "1"
assert "mise ls tiny --json --current | jq -r '.[0].version'" "1.1.0"

assert "mise up tiny --bump"
assert "cat mise.lock" '[[tools.tiny]]
version = "3.1.0"
backend = "asdf:tiny"'
assert "cat mise.lock" "$LOCKFILE_HEADER

[[tools.tiny]]
version = \"3.1.0\"
backend = \"asdf:tiny\""
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"

Expand All @@ -41,13 +49,15 @@ version = "1.0.0"
backend = "asdf:tiny"
EOF
assert "mise use tiny@1 tiny@2"
assert "cat mise.lock" '[[tools.tiny]]
version = "1.0.0"
backend = "asdf:tiny"
assert "cat mise.lock" "$LOCKFILE_HEADER

[[tools.tiny]]
version = \"1.0.0\"
backend = \"asdf:tiny\"

[[tools.tiny]]
version = "2.1.0"
backend = "asdf:tiny"'
version = \"2.1.0\"
backend = \"asdf:tiny\""
assert "mise uninstall --all tiny"
assert "mise install tiny"
assert "mise ls tiny --json --current | jq -r '.[0].requested_version'" "1"
Expand Down
2 changes: 2 additions & 0 deletions mise.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ impl Lockfile {

let content = toml::to_string_pretty(&toml::Value::Table(lockfile))?;
let content = format(content.parse()?);
let content = format!(
"# @generated - this file is auto-generated by `mise lock` https://mise.jdx.dev/dev-tools/mise-lock.html\n\
\n\
{content}"
);
Comment on lines +319 to +323

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current formatting of the header string will include leading whitespace from the source code indentation in the output file. This can be avoided by using a const for the header, which also improves readability and makes it easier to keep it in sync with the test files.

Suggested change
let content = format!(
"# This file is auto-generated by mise.\n\
# It is not intended to be edited manually.\n\
# mise docs: https://mise.jdx.dev/dev-tools/mise-lock.html\n\
# mise CLI: `mise lock`\n\
\n\
{content}"
);
const LOCKFILE_HEADER: &str = "# This file is auto-generated by mise.\n# It is not intended to be edited manually.\n# mise docs: https://mise.jdx.dev/dev-tools/mise-lock.html\n# mise CLI: `mise lock`";
let content = format!("{LOCKFILE_HEADER}\n\n{content}");

@ivy ivy Mar 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad robot! I verified locally.

───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: mise.lock
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1 + │ # This file is auto-generated by mise.
   2 + │ # It is not intended to be edited manually.
   3 + │ # mise docs: https://mise.jdx.dev/dev-tools/mise-lock.html
   4 + │ # mise CLI: `mise lock`


// Use atomic write: write to temp file, then rename
// This prevents partial writes from corrupting the lockfile
Expand Down
Loading