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
12 changes: 8 additions & 4 deletions cmd/config_slim.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,19 @@ func slimToOverlay(src string) ([]byte, error) {
}

// pinAbsentMiseChecks returns a copy of a legacy source's mise block with
// every check block the source leaves out written as `{enabled: false}`.
// In a full config an absent check block does not run, but the overlay is
// deep-merged onto the base on resolve, so an absent key would inherit the
// base's enabled block and turn the check on.
// every check block the source leaves out written as `{enabled: false}`,
// and `enabled: true` when it leaves out `enabled` and the base is off.
// In a full config an absent check block does not run and a present mise
// block is enabled, but the overlay is deep-merged onto the base on
// resolve, so an absent key would inherit the base's value.
func pinAbsentMiseChecks(m map[interface{}]interface{}, base *configuration.MiseConfig) map[interface{}]interface{} {
out := make(map[interface{}]interface{})
for k, v := range m {
out[k] = v
}
if _, ok := out["enabled"]; !ok && !base.IsEnabled() {
out["enabled"] = true
}
if _, ok := out["lockfile"]; !ok && base.LockfileCheckEnabled() {
out["lockfile"] = map[interface{}]interface{}{"enabled": false}
}
Expand Down
9 changes: 7 additions & 2 deletions cmd/config_slim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,13 @@ func TestSlimToOverlay_MiseSurvivesResolve(t *testing.T) {
wantEnabled: false,
},
{
name: "an overlay source without mise inherits the base",
src: "extends: plumber:default\nversion: \"2.0\"\n",
name: "an overlay source without mise inherits the disabled base",
src: "extends: plumber:default\nversion: \"2.0\"\n",
wantEnabled: false,
},
{
name: "an overlay source with enabled: true runs the shipped checks",
src: "extends: plumber:default\nversion: \"2.0\"\nmise:\n enabled: true\n",
wantEnabled: true,
wantLockfile: true,
wantVersions: true,
Expand Down
6 changes: 5 additions & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -1553,8 +1553,12 @@ func (st *initWizardState) toPlumberConfig() *configuration.PlumberConfig {

// Provider-independent: mise is a top-level block. It is the
// shipped default's, so the wizard and the default cannot drift.
// The default ships it disabled; picking package managers turns it
// on, and a present block with no `enabled` key is enabled.
if compSelected(st, compPackageManagers) {
cfg.Mise = embeddedDefault().Mise
m := *embeddedDefault().Mise
m.Enabled = nil
cfg.Mise = &m
}

// GitHub-only composition checks.
Expand Down
11 changes: 6 additions & 5 deletions defaultConfig/.plumber.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1414,18 +1414,19 @@ github:
# ============================================================================
# Top level, like gitlab and github: mise does not depend on the provider,
# the same block applies to a GitHub or a GitLab repository. It drives the
# mise-en-place control. Remove the block, or set
# `enabled: false`, and nothing is scanned or reported. A check whose
# block (lockfile, versions, sources, tasks) is absent does not run.
# mise-en-place control. Ships disabled: set `enabled: true` to run the
# lockfile and versions checks below. While it is disabled, nothing is
# scanned or reported. A check whose block (lockfile, versions, sources,
# tasks) is absent does not run.
#
# The files are read from the local checkout. A run without one (a remote
# --project run) reports the control as not evaluated.
#
# Best practice: commit mise.lock with a checksum for every download, and
# install with `mise install --locked` in CI.
mise:
# Set to false to disable every mise check
enabled: true
# Set to true to enable the mise checks
enabled: false
# Set to true to report a repository that commits no mise config
# (ISSUE-1010). A .tool-versions file alone does not count.
required: false
Expand Down
8 changes: 6 additions & 2 deletions policies/mise_versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ import (

// shippedForbiddenVersions returns the forbiddenVersions list of
// plumber:default, so the cases below pin the shipped list: dropping a
// pattern from defaultConfig/.plumber.yaml fails them.
// pattern from defaultConfig/.plumber.yaml fails them. mise ships
// disabled, with the versions block ready for `enabled: true`.
func shippedForbiddenVersions(t *testing.T) []string {
t.Helper()
pc, _, _, err := configuration.LoadPlumberConfigFromBytes([]byte("extends: plumber:default\nversion: \"2.0\"\n"), "test")
if err != nil {
t.Fatalf("load plumber:default: %v", err)
}
if pc.Mise.IsEnabled() {
t.Fatal("plumber:default turns mise on, want it shipped disabled")
}
if !pc.Mise.VersionsCheckEnabled() {
t.Fatal("plumber:default does not turn the mise versions check on")
t.Fatal("plumber:default does not ship the mise versions check block")
}
return pc.Mise.Versions.ForbiddenVersions
}
Expand Down