Delete dead code and stale fixtures, fix config set reindent (closes #70)
check / check (pull_request) Failing after 1s

Remove the unused internal/models package (and its coverage-only test),
internal/cli/vaultik_snapshot_types.go (a second, dead SnapshotInfo that
shadowed the live type in internal/vaultik), and two fixtures
(test-config.yml, test/integration-config.yml) that use source_dirs and
other keys config.Config no longer has. All confirmed by grep against
origin/next; none has a production consumer.

config set now writes via yaml.NewEncoder with 2-space indent, matching
defaultConfigTemplate, so the first set no longer reindents the file it
promises to preserve. A test covers the round-trip.

Single commit rather than one commit per deletion, per task instruction.
test/integration-config.yml removed per the manager note on the issue.

Model: opus-4-8
This commit is contained in:
2026-09-21 13:05:22 +00:00
parent d2a0510cb4
commit 1071058f4e
7 changed files with 71 additions and 189 deletions
+30 -1
View File
@@ -1,6 +1,7 @@
package cli
import (
"bytes"
"errors"
"fmt"
"os"
@@ -24,6 +25,11 @@ const configSetArgs = 2
// parent config dirs (e.g. ~/.config) are conventionally traversable.
const configDirMode = 0o755
// configYAMLIndent matches the 2-space indentation of defaultConfigTemplate,
// so `config set` writes the file back with the same indentation rather than
// yaml.Marshal's 4-space default.
const configYAMLIndent = 2
var (
errConfigExists = errors.New("config file already exists")
errEmptyConfig = errors.New("empty config file")
@@ -381,7 +387,7 @@ Examples:
return err
}
out, err := yaml.Marshal(root)
out, err := marshalConfigYAML(root)
if err != nil {
return fmt.Errorf("marshaling config: %w", err)
}
@@ -405,6 +411,29 @@ Examples:
}
}
// marshalConfigYAML renders a config document tree with 2-space indentation,
// matching defaultConfigTemplate. yaml.Marshal defaults to 4 spaces, which
// would reindent the whole file on the first `config set` despite the promise
// to preserve formatting.
func marshalConfigYAML(root *yaml.Node) ([]byte, error) {
var buf bytes.Buffer
enc := yaml.NewEncoder(&buf)
enc.SetIndent(configYAMLIndent)
err := enc.Encode(root)
if err != nil {
return nil, err
}
err = enc.Close()
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}
// loadYAMLFile parses a YAML file into a yaml.Node document tree,
// which preserves comments and ordering for round-tripping.
func loadYAMLFile(path string) (*yaml.Node, error) {