Skip to content

Commit

Permalink
chore: Tidy up suspicious entries output in doctor command
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Nov 1, 2021
1 parent 10f1c1a commit 2307917
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 3 additions & 8 deletions internal/cmd/doctorcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"io/fs"
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"sort"
Expand Down Expand Up @@ -467,11 +466,7 @@ func (c *suspiciousEntriesCheck) Run(system chezmoi.System, homeDirAbsPath chezm
return err
}
if chezmoi.SuspiciousSourceDirEntry(absPath.Base(), info) {
relPath, err := filepath.Rel(c.dirname.String(), absPath.String()) // FIXME add Rel to chezmoi.AbsPath
if err != nil {
return err
}
suspiciousEntries = append(suspiciousEntries, relPath)
suspiciousEntries = append(suspiciousEntries, absPath.String())
}
return nil
}); {
Expand All @@ -481,9 +476,9 @@ func (c *suspiciousEntriesCheck) Run(system chezmoi.System, homeDirAbsPath chezm
return checkResultError, err.Error()
}
if len(suspiciousEntries) > 0 {
return checkResultWarning, fmt.Sprintf("%s: %s", c.dirname, englishList(suspiciousEntries))
return checkResultWarning, englishList(suspiciousEntries)
}
return checkResultOK, fmt.Sprintf("%s: no suspicious entries", c.dirname)
return checkResultOK, "no suspicious entries"
}

func (c *umaskCheck) Name() string {
Expand Down
7 changes: 7 additions & 0 deletions internal/cmd/testdata/scripts/doctor_unix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ stdout '^ok\s+config-file\s+'
stdout '^error\s+source-dir\s+'
stdout '^ok\s+suspicious-entries\s+'

chhome home3/user

# test that chezmoi doctor warns about suspicious entries
chezmoi doctor
stdout '^warning\s+suspicious-entries\s+'

-- bin/age --
#!/bin/sh

Expand Down Expand Up @@ -120,3 +126,4 @@ echo "Vault v1.5.5 ('f5d1ddb3750e7c28e25036e1ef26a4c02379fc01+CHANGES')"
[keepassxc]
command = "keepassxc"
-- home/user/.config/chezmoi/chezmoi.yaml --
-- home3/user/.local/share/chezmoi/.chezmoisuspicious --

0 comments on commit 2307917

Please sign in to comment.