hash
stringlengths
40
40
date
stringdate
2019-01-29 11:49:07
2025-03-22 03:23:55
author
stringclasses
79 values
commit_message
stringlengths
14
85
is_merge
bool
1 class
git_diff
stringlengths
210
1.63M
type
stringclasses
8 values
masked_commit_message
stringlengths
8
79
3ae5f5124be2159e2757ca3a5e43b61c516f2294
2023-06-17 04:54:29
Tom Payne
chore: Fix typo
false
diff --git a/pkg/chezmoi/realsystem.go b/pkg/chezmoi/realsystem.go index 2ab94789979..047e874865e 100644 --- a/pkg/chezmoi/realsystem.go +++ b/pkg/chezmoi/realsystem.go @@ -159,7 +159,7 @@ func (s *RealSystem) UnderlyingSystem() System { // getScriptWorkingDir returns the script's working directory. // // If this is a before_ script then the requested working directory may not -// actually exist yet, so search through the parent directory hierarchy till +// actually exist yet, so search through the parent directory hierarchy until // we find a suitable working directory. func (s *RealSystem) getScriptWorkingDir(dir AbsPath) (string, error) { // This should always terminate because dir will eventually become ".", i.e.
chore
Fix typo
a8ab8536853116f7b3b27f80572c4d3a5561a8a9
2024-02-25 01:58:09
Tom Payne
chore: Update GitHub Actions
false
diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml index d8ccbae6c49..436cd3265a8 100644 --- a/.github/workflows/installer.yml +++ b/.github/workflows/installer.yml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: filter - uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd + uses: dorny/paths-filter@ebc4d7e9ebcb0b1eb21480bb8f43113e996ac77a with: filters: | shared: &shared diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index efc1b517c69..0d25b8bb4b7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: filter - uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd + uses: dorny/paths-filter@ebc4d7e9ebcb0b1eb21480bb8f43113e996ac77a with: filters: | code:
chore
Update GitHub Actions
217cdaa6ace86efd47b63dda4e95119a2f2c3f08
2024-06-26 22:03:02
Tom Payne
feat: Add --no-network flag to doctor command
false
diff --git a/assets/chezmoi.io/docs/reference/commands/doctor.md b/assets/chezmoi.io/docs/reference/commands/doctor.md index caafbae7305..6b29f04f0ba 100644 --- a/assets/chezmoi.io/docs/reference/commands/doctor.md +++ b/assets/chezmoi.io/docs/reference/commands/doctor.md @@ -2,6 +2,10 @@ Check for potential problems. +## `--no-network` + +Do not use any network connections. + !!! example ```console diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 88d92c73250..f39a6a03cbb 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -193,6 +193,7 @@ type Config struct { archive archiveCmdConfig chattr chattrCmdConfig destroy destroyCmdConfig + doctor doctorCmdConfig dump dumpCmdConfig executeTemplate executeTemplateCmdConfig ignored ignoredCmdConfig diff --git a/internal/cmd/doctorcmd.go b/internal/cmd/doctorcmd.go index cbce95a106b..4578b5f20d3 100644 --- a/internal/cmd/doctorcmd.go +++ b/internal/cmd/doctorcmd.go @@ -35,6 +35,7 @@ import ( type checkResult int const ( + checkResultOmitted checkResult = -3 // The check was omitted. checkResultFailed checkResult = -2 // The check could not be completed. checkResultSkipped checkResult = -1 // The check was skipped. checkResultOK checkResult = 0 // The check completed and did not find any problems. @@ -60,6 +61,7 @@ type check interface { } var checkResultStr = map[checkResult]string{ + checkResultOmitted: "omitted", checkResultFailed: "failed", checkResultSkipped: "skipped", checkResultOK: "ok", @@ -117,6 +119,7 @@ type goVersionCheck struct{} // A latestVersionCheck checks the latest version. type latestVersionCheck struct { + network bool httpClient *http.Client httpClientErr error version semver.Version @@ -125,8 +128,8 @@ type latestVersionCheck struct { // An osArchCheck checks that runtime.GOOS and runtime.GOARCH are supported. type osArchCheck struct{} -// A skippedCheck is a check that is skipped. -type skippedCheck struct{} +// A omittedCheck is a check that is omitted. +type omittedCheck struct{} // A suspiciousEntriesCheck checks that a source directory does not contain any // suspicious files. @@ -143,6 +146,10 @@ type versionCheck struct { versionStr string } +type doctorCmdConfig struct { + noNetwork bool +} + func (c *Config) newDoctorCmd() *cobra.Command { doctorCmd := &cobra.Command{ Args: cobra.NoArgs, @@ -157,6 +164,8 @@ func (c *Config) newDoctorCmd() *cobra.Command { ), } + doctorCmd.PersistentFlags().BoolVar(&c.doctor.noNetwork, "no-network", c.doctor.noNetwork, "do not use network connection") + return doctorCmd } @@ -176,6 +185,7 @@ func (c *Config) runDoctorCmd(cmd *cobra.Command, args []string) error { versionStr: c.versionStr, }, &latestVersionCheck{ + network: !c.doctor.noNetwork, httpClient: httpClient, httpClientErr: httpClientErr, version: c.version, @@ -422,7 +432,7 @@ func (c *Config) runDoctorCmd(cmd *cobra.Command, args []string) error { fmt.Fprint(resultWriter, "RESULT\tCHECK\tMESSAGE\n") for _, check := range checks { checkResult, message := check.Run(c.baseSystem, homeDirAbsPath) - if checkResult == checkResultSkipped { + if checkResult == checkResultOmitted { continue } // Conceal the user's actual home directory in the message as the @@ -653,7 +663,10 @@ func (c *latestVersionCheck) Name() string { } func (c *latestVersionCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) { - if c.httpClientErr != nil { + switch { + case !c.network: + return checkResultSkipped, "no network" + case c.httpClientErr != nil: return checkResultFailed, c.httpClientErr.Error() } @@ -704,12 +717,12 @@ func (osArchCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (c return checkResultOK, strings.Join(fields, " ") } -func (skippedCheck) Name() string { - return "skipped" +func (omittedCheck) Name() string { + return "omitted" } -func (skippedCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) { - return checkResultSkipped, "" +func (omittedCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) { + return checkResultOmitted, "" } func (c *suspiciousEntriesCheck) Name() string { @@ -759,7 +772,7 @@ func (upgradeMethodCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsP return checkResultFailed, err.Error() } if method == "" { - return checkResultSkipped, "" + return checkResultOmitted, "" } return checkResultOK, method } diff --git a/internal/cmd/doctorcmd_unix.go b/internal/cmd/doctorcmd_unix.go index 79765bcc2bc..e3d7e28d7a1 100644 --- a/internal/cmd/doctorcmd_unix.go +++ b/internal/cmd/doctorcmd_unix.go @@ -17,7 +17,7 @@ import ( ) type ( - systeminfoCheck struct{ skippedCheck } + systeminfoCheck struct{ omittedCheck } umaskCheck struct{} unameCheck struct{} ) @@ -42,7 +42,7 @@ func (unameCheck) Name() string { func (unameCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) { if runtime.GOOS == "windows" { - return checkResultSkipped, "" + return checkResultOmitted, "" } cmd := exec.Command("uname", "-a") cmd.Stderr = os.Stderr diff --git a/internal/cmd/doctorcmd_windows.go b/internal/cmd/doctorcmd_windows.go index 92dcc4b16df..cffba14c199 100644 --- a/internal/cmd/doctorcmd_windows.go +++ b/internal/cmd/doctorcmd_windows.go @@ -14,8 +14,8 @@ import ( type ( systeminfoCheck struct{} - umaskCheck struct{ skippedCheck } - unameCheck struct{ skippedCheck } + umaskCheck struct{ omittedCheck } + unameCheck struct{ omittedCheck } ) func (systeminfoCheck) Name() string {
feat
Add --no-network flag to doctor command
ce8782f390b7b7427ae584cd690ac9d5b17a8208
2021-10-20 03:09:51
Tom Payne
chore: Fix comments regarding encoding.Text{M,UnM}arshaler
false
diff --git a/internal/chezmoi/abspath.go b/internal/chezmoi/abspath.go index 43007d0bfe6..6461a05f899 100644 --- a/internal/chezmoi/abspath.go +++ b/internal/chezmoi/abspath.go @@ -69,7 +69,7 @@ func (p AbsPath) Len() int { return len(p.absPath) } -// MarshalText implements encoding.TextMarshaler. +// MarshalText implements encoding.TextMarshaler.MarshalText. func (p AbsPath) MarshalText() ([]byte, error) { return []byte(p.absPath), nil } @@ -139,7 +139,7 @@ func (p AbsPath) Type() string { return "path" } -// UnmarshalText implements encoding.UnmarshalText. +// UnmarshalText implements encoding.TextUnmarshaler.UnmarshalText. func (p *AbsPath) UnmarshalText(text []byte) error { return p.Set(string(text)) } diff --git a/internal/chezmoi/hexbytes.go b/internal/chezmoi/hexbytes.go index 0986f00441a..084556dc23d 100644 --- a/internal/chezmoi/hexbytes.go +++ b/internal/chezmoi/hexbytes.go @@ -22,7 +22,7 @@ func (h HexBytes) MarshalText() ([]byte, error) { return result, nil } -// UnmarshalText implements encoding.TextMarshaler.UnmarshalText. +// UnmarshalText implements encoding.TextUnmarshaler.UnmarshalText. func (h *HexBytes) UnmarshalText(text []byte) error { if len(text) == 0 { *h = nil
chore
Fix comments regarding encoding.Text{M,UnM}arshaler
65e216c501cd4afe806b8bf50c0ef406d91ac6da
2024-01-01 17:14:24
dependabot[bot]
chore(deps): bump github/codeql-action from 2.22.8 to 3.22.12
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e943182262a..82812da17a3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,10 +52,10 @@ jobs: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 with: fetch-depth: 1 - - uses: github/codeql-action/init@407ffafae6a767df3e0230c3df91b6443ae8df75 + - uses: github/codeql-action/init@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 with: languages: go - - uses: github/codeql-action/analyze@407ffafae6a767df3e0230c3df91b6443ae8df75 + - uses: github/codeql-action/analyze@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 misspell: runs-on: ubuntu-22.04 steps:
chore
bump github/codeql-action from 2.22.8 to 3.22.12
8d9a89b0c131e69fc97ecbb2279558e2930ae9e1
2021-10-04 01:04:58
Tom Payne
feat: Re-enable building with Go 1.16
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2ca9d2826e8..9030314a4e3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -91,6 +91,23 @@ jobs: sudo install -m 755 age/age-keygen /usr/local/bin - name: Test run: go test -race ./... + test-openbsd: + runs-on: macos-latest + env: + VAGRANT_BOX: openbsd6 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Cache Vagrant Boxes + uses: actions/cache@v2 + with: + path: ~/.vagrant.d + key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/*.Vagrantfile') }} + restore-keys: | + ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}- + - name: Test + run: | + ( cd assets/vagrant && ./test.sh openbsd6 ) test-ubuntu: runs-on: ubuntu-18.04 steps: @@ -167,6 +184,36 @@ jobs: with: name: chezmoi-windows-amd64.exe path: dist/chezmoi-nocgo_windows_amd64/chezmoi.exe + test-ubuntu-go1-16: + runs-on: ubuntu-18.04 + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16.x + - name: Checkout + uses: actions/checkout@v2 + - name: Cache Go modules + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-ubuntu-go-1-16-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-ubuntu-go-1-16- + - name: Build + run: | + go build ./... + - name: Run + run: | + go run . --version + - name: Install age + run: | + cd $(mktemp -d) + curl -fsSL https://dl.filippo.io/age/v${AGE_VERSION}?for=linux/amd64 | tar xzf - + sudo install -m 755 age/age /usr/local/bin + sudo install -m 755 age/age-keygen /usr/local/bin + - name: Test + run: go test ./... test-windows: runs-on: windows-latest steps: @@ -275,6 +322,7 @@ jobs: - test-fedora - test-freebsd - test-macos + - test-openbsd - test-ubuntu - test-windows runs-on: ubuntu-18.04 diff --git a/Makefile b/Makefile index e7b793e78d1..3bc8dd0e854 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ test-docker: .PHONY: test-vagrant test-vagrant: - ( cd assets/vagrant && ./test.sh debian11-i386 freebsd13 ) + ( cd assets/vagrant && ./test.sh debian11-i386 freebsd13 openbsd6 ) .PHONY: coverage-html coverage-html: coverage diff --git a/assets/docker/fedora.entrypoint.sh b/assets/docker/fedora.entrypoint.sh index 1a822697670..a27de7948e0 100755 --- a/assets/docker/fedora.entrypoint.sh +++ b/assets/docker/fedora.entrypoint.sh @@ -2,10 +2,4 @@ set -eufo pipefail -GO_VERSION=$(grep GO_VERSION: /chezmoi/.github/workflows/main.yml | awk '{ print $2 }' ) - -go get "golang.org/dl/go${GO_VERSION}" -"${HOME}/go/bin/go${GO_VERSION}" download -export PATH="${HOME}/sdk/go${GO_VERSION}/bin:${PATH}" - ( cd /chezmoi && go test ./... ) diff --git a/assets/vagrant/openbsd6.Vagrantfile b/assets/vagrant/openbsd6.Vagrantfile index 7f8cdc9d9ea..46e777778cc 100644 --- a/assets/vagrant/openbsd6.Vagrantfile +++ b/assets/vagrant/openbsd6.Vagrantfile @@ -1,5 +1,3 @@ -# OpenBSD currently includes Go version 1.16.2, but chezmoi requires version -# 1.17 or later. Vagrant.configure("2") do |config| config.vm.box = "generic/openbsd6" config.vm.define :openbsd6 diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index c24487f2f46..9e0393507f5 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -24,7 +24,7 @@ chezmoi's source code. ## Developing locally -chezmoi requires Go 1.17 or later. +chezmoi requires Go 1.16 or later. chezmoi is a standard Go project, using standard Go tooling, with a few extra tools. Ensure that these extra tools are installed with: diff --git a/docs/FAQ.md b/docs/FAQ.md index d3e9f725663..97bf9bf3b4f 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -446,7 +446,7 @@ lock include `diff`, `status`, and `verify`. ## I'm getting errors trying to build chezmoi from source -chezmoi requires Go version 1.17 or later. You can check the version of Go with: +chezmoi requires Go version 1.16 or later. You can check the version of Go with: ```console $ go version @@ -458,8 +458,8 @@ If you try to build chezmoi with an earlier version of Go you will get the error package github.com/twpayne/chezmoi/v2: build constraints exclude all Go files in /home/twp/src/github.com/twpayne/chezmoi ``` -This is because chezmoi includes the build tag `go1.17` in `main.go`, which is -only set on Go 1.17 or later. +This is because chezmoi includes the build tag `go1.16` in `main.go`, which is +only set on Go 1.16 or later. For more details on building chezmoi, see the [Contributing Guide]([CONTRIBUTING.md](https://github.com/twpayne/chezmoi/blob/master/docs/CONTRIBUTING.md)). diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 6f5b3e2da46..0832c1c360f 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -116,6 +116,6 @@ $ cd chezmoi $ make install ``` -Building chezmoi requires Go 1.17 or later. +Building chezmoi requires Go 1.16 or later. --- diff --git a/go.mod b/go.mod index a3c40a7664a..22b37aacaf2 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/twpayne/chezmoi/v2 -go 1.17 +go 1.16 require ( filippo.io/age v1.0.0 @@ -16,7 +16,6 @@ require ( github.com/danieljoos/wincred v1.1.2 // indirect github.com/go-git/go-git/v5 v5.4.2 github.com/google/go-github/v39 v39.1.0 - github.com/google/go-querystring v1.1.0 // indirect github.com/google/gops v0.3.20 github.com/google/renameio/v2 v2.0.0 github.com/google/uuid v1.3.0 // indirect @@ -33,7 +32,6 @@ require ( github.com/rs/zerolog v1.25.0 github.com/sergi/go-diff v1.1.0 github.com/spf13/afero v1.6.0 - github.com/spf13/cast v1.4.1 // indirect github.com/spf13/cobra v1.2.1 github.com/spf13/viper v1.9.0 github.com/stretchr/testify v1.7.0 @@ -50,56 +48,17 @@ require ( golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f golang.org/x/sys v0.0.0-20211001092434-39dca1131b70 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 - google.golang.org/protobuf v1.27.1 // indirect gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b howett.net/plist v0.0.0-20201203080718-1454fab16a06 ) require ( - github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.1.1 // indirect - github.com/Microsoft/go-winio v0.5.0 // indirect - github.com/acomagu/bufpipe v1.0.3 // indirect - github.com/aymerick/douceur v0.2.0 // indirect - github.com/bradenhilton/cityhash v1.0.0 // indirect - github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dlclark/regexp2 v1.4.0 // indirect - github.com/emirpasic/gods v1.12.0 // indirect - github.com/fsnotify/fsnotify v1.5.1 // indirect - github.com/go-git/gcfg v1.5.0 // indirect - github.com/go-git/go-billy/v5 v5.3.1 // indirect github.com/godbus/dbus/v5 v5.0.5 // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/gorilla/css v1.0.0 // indirect - github.com/hashicorp/hcl v1.0.0 // indirect - github.com/imdario/mergo v0.3.12 // indirect - github.com/inconshreveable/mousetrap v1.0.0 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/lucasb-eyer/go-colorful v1.2.0 // indirect - github.com/magiconair/properties v1.8.5 // indirect github.com/mattn/go-isatty v0.0.14 // indirect - github.com/mattn/go-runewidth v0.0.13 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rivo/uniseg v0.2.0 // indirect - github.com/shopspring/decimal v1.2.0 // indirect - github.com/spf13/jwalterweatherman v1.1.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.3.0 // indirect - github.com/subosito/gotenv v1.2.0 // indirect - github.com/yuin/goldmark-emoji v1.0.1 // indirect golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect golang.org/x/text v0.3.7 // indirect - google.golang.org/appengine v1.6.7 // indirect - gopkg.in/errgo.v2 v2.1.0 // indirect - gopkg.in/ini.v1 v1.63.2 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect ) exclude github.com/sergi/go-diff v1.2.0 // Produces incorrect diffs diff --git a/internal/cmd/config_test.go b/internal/cmd/config_test.go index f67c98c41e5..d52702e9f28 100644 --- a/internal/cmd/config_test.go +++ b/internal/cmd/config_test.go @@ -239,7 +239,7 @@ func withTestUser(t *testing.T, username string) configOption { c.homeDir = filepath.Join("/", "home", username) env = "HOME" } - t.Setenv(env, c.homeDir) + testSetenv(t, env, c.homeDir) var err error c.homeDirAbsPath, err = chezmoi.NormalizePath(c.homeDir) if err != nil { diff --git a/internal/cmd/util_go1.16_test.go b/internal/cmd/util_go1.16_test.go new file mode 100644 index 00000000000..8a437e99960 --- /dev/null +++ b/internal/cmd/util_go1.16_test.go @@ -0,0 +1,18 @@ +//go:build !go1.17 +// +build !go1.17 + +package cmd + +import ( + "os" + "testing" +) + +func testSetenv(t *testing.T, key, value string) { + t.Helper() + prevValue := os.Getenv(key) + t.Cleanup(func() { + os.Setenv(key, prevValue) + }) + os.Setenv(key, value) +} diff --git a/internal/cmd/util_go1.17_test.go b/internal/cmd/util_go1.17_test.go new file mode 100644 index 00000000000..e7f4edb89ca --- /dev/null +++ b/internal/cmd/util_go1.17_test.go @@ -0,0 +1,11 @@ +//go:build go1.17 +// +build go1.17 + +package cmd + +import "testing" + +func testSetenv(t *testing.T, key, value string) { + t.Helper() + t.Setenv(key, value) +} diff --git a/main.go b/main.go index 212fc7b0ed3..12460eb82b4 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,5 @@ -//go:build go1.17 -// +build go1.17 +//go:build go1.16 +// +build go1.16 //go:generate go run . completion bash -o completions/chezmoi-completion.bash //go:generate go run . completion fish -o completions/chezmoi.fish
feat
Re-enable building with Go 1.16
fd5e0f1f65f9b9d952cd8599d7e03552316ce0b9
2021-10-07 23:50:44
Tom Payne
chore: Factor out common encryption testing code
false
diff --git a/internal/chezmoi/ageencryption_test.go b/internal/chezmoi/ageencryption_test.go index 458533d89ec..2da6f5db05e 100644 --- a/internal/chezmoi/ageencryption_test.go +++ b/internal/chezmoi/ageencryption_test.go @@ -1,10 +1,7 @@ package chezmoi import ( - "errors" - "fmt" "os" - "os/exec" "path/filepath" "testing" @@ -17,11 +14,7 @@ import ( ) func TestAgeEncryption(t *testing.T) { - command, err := exec.LookPath("age") - if errors.Is(err, exec.ErrNotFound) { - t.Skip("age not found in $PATH") - } - require.NoError(t, err) + command := lookPathOrSkip(t, "age") publicKey, privateKeyFile, err := chezmoitest.AgeGenerateKey("") require.NoError(t, err) @@ -29,33 +22,26 @@ func TestAgeEncryption(t *testing.T) { assert.NoError(t, os.RemoveAll(filepath.Dir(privateKeyFile))) }() - ageEncryption := &AgeEncryption{ + testEncryption(t, &AgeEncryption{ Command: command, Identity: NewAbsPath(privateKeyFile), Recipient: publicKey, - } - - testEncryptionDecryptToFile(t, ageEncryption) - testEncryptionEncryptDecrypt(t, ageEncryption) - testEncryptionEncryptFile(t, ageEncryption) + }) } func TestBuiltinAgeEncryption(t *testing.T) { recipientStringer, identityAbsPath := builtinAgeGenerateKey(t) - ageEncryption := &AgeEncryption{ + testEncryption(t, &AgeEncryption{ UseBuiltin: true, BaseSystem: NewRealSystem(vfs.OSFS), Identity: identityAbsPath, Recipient: recipientStringer.String(), - } - - testEncryptionDecryptToFile(t, ageEncryption) - testEncryptionEncryptDecrypt(t, ageEncryption) - testEncryptionEncryptFile(t, ageEncryption) + }) } func builtinAgeGenerateKey(t *testing.T) (fmt.Stringer, AbsPath) { + t.Helper() identity, err := age.GenerateX25519Identity() require.NoError(t, err) privateKeyFile := filepath.Join(t.TempDir(), "chezmoi-builtin-age-key.txt") diff --git a/internal/chezmoi/encryption_test.go b/internal/chezmoi/encryption_test.go index b9c39c188a1..66af2b3f2e2 100644 --- a/internal/chezmoi/encryption_test.go +++ b/internal/chezmoi/encryption_test.go @@ -1,8 +1,10 @@ package chezmoi import ( + "errors" "math/rand" "os" + "os/exec" "testing" "github.com/stretchr/testify/assert" @@ -47,6 +49,16 @@ func (e *xorEncryption) xorWithKey(input []byte) []byte { return output } +func lookPathOrSkip(t *testing.T, file string) string { + t.Helper() + command, err := exec.LookPath(file) + if errors.Is(err, exec.ErrNotFound) { + t.Skipf("%s not found in $PATH", file) + } + require.NoError(t, err) + return command +} + func testEncryptionDecryptToFile(t *testing.T, encryption Encryption) { t.Helper() t.Run("DecryptToFile", func(t *testing.T) { @@ -106,10 +118,14 @@ func testEncryptionEncryptFile(t *testing.T, encryption Encryption) { } func TestXOREncryption(t *testing.T) { - xorEncryption := &xorEncryption{ + testEncryption(t, &xorEncryption{ key: byte(rand.Int() + 1), - } - testEncryptionDecryptToFile(t, xorEncryption) - testEncryptionEncryptDecrypt(t, xorEncryption) - testEncryptionEncryptFile(t, xorEncryption) + }) +} + +func testEncryption(t *testing.T, encryption Encryption) { + t.Helper() + testEncryptionDecryptToFile(t, encryption) + testEncryptionEncryptDecrypt(t, encryption) + testEncryptionEncryptFile(t, encryption) } diff --git a/internal/chezmoi/gpgencryption_test.go b/internal/chezmoi/gpgencryption_test.go index 264c9b4bc00..6d1fd9a16e7 100644 --- a/internal/chezmoi/gpgencryption_test.go +++ b/internal/chezmoi/gpgencryption_test.go @@ -1,8 +1,6 @@ package chezmoi import ( - "errors" - "os/exec" "testing" "github.com/stretchr/testify/require" @@ -11,11 +9,7 @@ import ( ) func TestGPGEncryption(t *testing.T) { - command, err := chezmoitest.GPGCommand() - if errors.Is(err, exec.ErrNotFound) { - t.Skip("gpg not found in $PATH") - } - require.NoError(t, err) + command := lookPathOrSkip(t, "gpg") tempDir := t.TempDir() key, passphrase, err := chezmoitest.GPGGenerateKey(command, tempDir) @@ -35,7 +29,7 @@ func TestGPGEncryption(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - gpgEncryption := &GPGEncryption{ + testEncryption(t, &GPGEncryption{ Command: command, Args: []string{ "--homedir", tempDir, @@ -45,11 +39,7 @@ func TestGPGEncryption(t *testing.T) { }, Recipient: key, Symmetric: tc.symmetric, - } - - testEncryptionDecryptToFile(t, gpgEncryption) - testEncryptionEncryptDecrypt(t, gpgEncryption) - testEncryptionEncryptFile(t, gpgEncryption) + }) }) } } diff --git a/internal/chezmoitest/chezmoitest.go b/internal/chezmoitest/chezmoitest.go index 9d0c2cbbd34..35f33eb5ea4 100644 --- a/internal/chezmoitest/chezmoitest.go +++ b/internal/chezmoitest/chezmoitest.go @@ -65,11 +65,6 @@ func AgeGenerateKey(filename string) (publicKey, privateKeyFile string, err erro return } -// GPGCommand returns the path to gpg, if it can be found. -func GPGCommand() (string, error) { - return exec.LookPath("gpg") -} - // GPGGenerateKey generates GPG key in homeDir and returns the key and the // passphrase. func GPGGenerateKey(command, homeDir string) (key, passphrase string, err error) { diff --git a/internal/cmd/main_test.go b/internal/cmd/main_test.go index 1da50ac985a..ee21aa65b9d 100644 --- a/internal/cmd/main_test.go +++ b/internal/cmd/main_test.go @@ -9,6 +9,7 @@ import ( "net/http" "net/http/httptest" "os" + "os/exec" "path" "path/filepath" "regexp" @@ -307,7 +308,7 @@ func cmdMkGPGConfig(ts *testscript.TestScript, neg bool, args []string) { ts.Check(os.Chmod(gpgHomeDir, 0o700)) } - command, err := chezmoitest.GPGCommand() + command, err := exec.LookPath("gpg") ts.Check(err) key, passphrase, err := chezmoitest.GPGGenerateKey(command, gpgHomeDir)
chore
Factor out common encryption testing code
031b2676b2027364fd9b4d4a53af422725030027
2024-01-22 06:09:41
Tom Payne
fix: Handle more keepassxc-cli errors
false
diff --git a/internal/cmd/keepassxctemplatefuncs.go b/internal/cmd/keepassxctemplatefuncs.go index 7654dd90ba7..290b9ee7974 100644 --- a/internal/cmd/keepassxctemplatefuncs.go +++ b/internal/cmd/keepassxctemplatefuncs.go @@ -51,6 +51,7 @@ var ( keepassxcMinVersion = semver.Version{Major: 2, Minor: 7, Patch: 0} keepassxcEnterPasswordToUnlockDatabaseRx = regexp.MustCompile(`^Enter password to unlock .*: `) + keepassxcAnyResponseRx = regexp.MustCompile(`(?m)\A.*\r\n`) keepassxcPairRx = regexp.MustCompile(`^([A-Z]\w*):\s*(.*)$`) keepassxcPromptRx = regexp.MustCompile(`^.*> `) ) @@ -216,10 +217,16 @@ func (c *Config) keepassxcOutputOpen(command string, args ...string) ([]byte, er if c.Keepassxc.Prompt { // Expect the password prompt, e.g. "Enter password to unlock $HOME/Passwords.kdbx: ". - enterPasswordToUnlockPrompt, err := console.Expect(expect.Regexp(keepassxcEnterPasswordToUnlockDatabaseRx)) + enterPasswordToUnlockPrompt, err := console.Expect( + expect.Regexp(keepassxcEnterPasswordToUnlockDatabaseRx), + expect.Regexp(keepassxcAnyResponseRx), + ) if err != nil { return nil, err } + if !keepassxcEnterPasswordToUnlockDatabaseRx.MatchString(enterPasswordToUnlockPrompt) { + return nil, errors.New(strings.TrimSpace(enterPasswordToUnlockPrompt)) + } // Read the password from the user, if necessary. var password string @@ -244,10 +251,16 @@ func (c *Config) keepassxcOutputOpen(command string, args ...string) ([]byte, er } // Read the prompt, e.g "Passwords> ", so we can expect it later. - output, err := console.Expect(expect.Regexp(keepassxcPromptRx)) + output, err := console.Expect( + expect.Regexp(keepassxcPromptRx), + expect.Regexp(keepassxcAnyResponseRx), + ) if err != nil { return nil, err } + if !keepassxcPromptRx.MatchString(output) { + return nil, errors.New(strings.TrimSpace(output)) + } c.Keepassxc.cmd = cmd c.Keepassxc.console = console diff --git a/internal/cmd/keepassxctemplatefuncs_test.go b/internal/cmd/keepassxctemplatefuncs_test.go index fefe722eda8..974757f5d12 100644 --- a/internal/cmd/keepassxctemplatefuncs_test.go +++ b/internal/cmd/keepassxctemplatefuncs_test.go @@ -119,15 +119,53 @@ func TestKeepassxcTemplateFuncs(t *testing.T) { keepassxcModeOpen, } { t.Run(string(mode), func(t *testing.T) { - config := newTestConfig(t, vfs.OSFS) - config.Keepassxc.Database = chezmoi.NewAbsPath(database) - config.Keepassxc.Mode = mode - config.Keepassxc.Prompt = true - config.Keepassxc.password = databasePassword + t.Run("correct_password", func(t *testing.T) { + config := newTestConfig(t, vfs.OSFS) + defer config.keepassxcClose() + config.Keepassxc.Database = chezmoi.NewAbsPath(database) + config.Keepassxc.Mode = mode + config.Keepassxc.Prompt = true + config.Keepassxc.password = databasePassword + assert.Equal(t, entryPassword, config.keepassxcTemplateFunc(entryName)["Password"]) + assert.Equal(t, entryUsername, config.keepassxcAttributeTemplateFunc(entryName, "UserName")) + assert.Equal(t, attachmentData, config.keepassxcAttachmentTemplateFunc(entryName, attachmentName)) + }) - assert.Equal(t, entryPassword, config.keepassxcTemplateFunc(entryName)["Password"]) - assert.Equal(t, entryUsername, config.keepassxcAttributeTemplateFunc(entryName, "UserName")) - assert.Equal(t, attachmentData, config.keepassxcAttachmentTemplateFunc(entryName, attachmentName)) + t.Run("incorrect_password", func(t *testing.T) { + config := newTestConfig(t, vfs.OSFS) + defer config.keepassxcClose() + config.Keepassxc.Database = chezmoi.NewAbsPath(database) + config.Keepassxc.Mode = mode + config.Keepassxc.Prompt = true + config.Keepassxc.password = "incorrect-" + databasePassword + assert.Panics(t, func() { + config.keepassxcTemplateFunc(entryName) + }) + assert.Panics(t, func() { + config.keepassxcAttributeTemplateFunc(entryName, "UserName") + }) + assert.Panics(t, func() { + config.keepassxcAttachmentTemplateFunc(entryName, attachmentName) + }) + }) + + t.Run("incorrect_database", func(t *testing.T) { + config := newTestConfig(t, vfs.OSFS) + defer config.keepassxcClose() + config.Keepassxc.Database = chezmoi.NewAbsPath(filepath.Join(tempDir, "Non-existent database.kdbx")) + config.Keepassxc.Mode = mode + config.Keepassxc.Prompt = true + config.Keepassxc.password = databasePassword + assert.Panics(t, func() { + config.keepassxcTemplateFunc(entryName) + }) + assert.Panics(t, func() { + config.keepassxcAttributeTemplateFunc(entryName, "UserName") + }) + assert.Panics(t, func() { + config.keepassxcAttachmentTemplateFunc(entryName, attachmentName) + }) + }) }) } }
fix
Handle more keepassxc-cli errors
1126ff3a8b5e48b63b19d5953626dd1ec125780f
2022-04-02 03:33:45
Tom Payne
chore: Remove support for Go 1.16
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 210296973d5..797841e27b4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -162,23 +162,6 @@ jobs: run: | sh assets/scripts/install.sh bin/chezmoi --version - test-openbsd: - needs: changes - if: github.event_name == 'push' || needs.changes.outputs.code == 'true' - runs-on: macos-10.15 - env: - VAGRANT_BOX: openbsd6 - steps: - - uses: actions/checkout@v3 - - uses: actions/[email protected] - with: - path: ~/.vagrant.d - key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/openbsd6.Vagrantfile') }} - restore-keys: | - ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}- - - name: test - run: | - ( cd assets/vagrant && ./test.sh openbsd6 ) test-openindiana: needs: changes if: github.event_name == 'push' || needs.changes.outputs.code == 'true' @@ -292,38 +275,6 @@ jobs: with: name: chezmoi-windows-amd64.exe path: dist/chezmoi-nocgo_windows_amd64/chezmoi.exe - test-ubuntu-go1-16: - needs: changes - if: github.event_name == 'push' || needs.changes.outputs.code == 'true' - runs-on: ubuntu-18.04 - steps: - - uses: actions/setup-go@v2 - with: - go-version: 1.16.x - - uses: actions/checkout@v3 - - uses: actions/[email protected] - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-ubuntu-go-1-16-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-ubuntu-go-1-16- - - name: build - run: | - go build ./... - - name: run - run: | - go run . --version - - name: install-age - run: | - cd $(mktemp -d) - curl -fsSL https://github.com/FiloSottile/age/releases/download/v${AGE_VERSION}/age-v${AGE_VERSION}-linux-amd64.tar.gz | tar xzf - - sudo install -m 755 age/age /usr/local/bin - sudo install -m 755 age/age-keygen /usr/local/bin - - name: test - env: - CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} - run: | - go test ./... test-ubuntu-go1-17: needs: changes if: github.event_name == 'push' || needs.changes.outputs.code == 'true' @@ -451,10 +402,8 @@ jobs: - test-fedora - test-freebsd - test-macos - - test-openbsd - test-openindiana - test-ubuntu - - test-ubuntu-go1-16 - test-ubuntu-go1-17 - test-voidlinux - test-windows diff --git a/.golangci.yml b/.golangci.yml index 8d275daf0d5..a560fd1899e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -98,7 +98,7 @@ linters-settings: - prefix(github.com/twpayne/chezmoi) gofumpt: extra-rules: true - lang-version: "1.16" + lang-version: "1.17" module-path: github.com/twpayne/chezmoi goimports: local-prefixes: github.com/twpayne/chezmoi diff --git a/Makefile b/Makefile index 424d8031706..506805964fb 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ test-docker: .PHONY: test-vagrant test-vagrant: - ( cd assets/vagrant && ./test.sh debian11-i386 freebsd13 openbsd6 openindiana ) + ( cd assets/vagrant && ./test.sh debian11-i386 freebsd13 openindiana ) .PHONY: coverage-html coverage-html: coverage diff --git a/assets/chezmoi.io/docs/developer/developing-locally.md b/assets/chezmoi.io/docs/developer/developing-locally.md index 7e270daa007..3950c2da6f6 100644 --- a/assets/chezmoi.io/docs/developer/developing-locally.md +++ b/assets/chezmoi.io/docs/developer/developing-locally.md @@ -2,7 +2,7 @@ chezmoi is written in [Go](https://golang.org) and development happens on [GitHub](https://github.com). chezmoi is a standard Go project, using standard -Go tooling. chezmoi requires Go 1.16 or later. +Go tooling. chezmoi requires Go 1.17 or later. Checkout chezmoi: diff --git a/assets/chezmoi.io/docs/install.md.tmpl b/assets/chezmoi.io/docs/install.md.tmpl index aafdbd2b05f..fd1674ac3aa 100644 --- a/assets/chezmoi.io/docs/install.md.tmpl +++ b/assets/chezmoi.io/docs/install.md.tmpl @@ -211,7 +211,7 @@ pre-built binary and shell completions. ## Install from source -Download, build, and install chezmoi for your system with Go 1.16 or later: +Download, build, and install chezmoi for your system with Go 1.17 or later: ```console $ git clone https://github.com/twpayne/chezmoi.git diff --git a/assets/chezmoi.io/docs/reference/templates/functions/exit.md b/assets/chezmoi.io/docs/reference/templates/functions/exit.md index 4ebfd500094..6519f97f773 100644 --- a/assets/chezmoi.io/docs/reference/templates/functions/exit.md +++ b/assets/chezmoi.io/docs/reference/templates/functions/exit.md @@ -2,7 +2,3 @@ `exit` stops template execution and causes chezmoi to exit with *code*. `exit` is only available when generating the initial config file - -!!! warning - - `exit` is not available when chezmoi is built with Go 1.16 or earlier. diff --git a/assets/docker/entrypoint.sh b/assets/docker/entrypoint.sh index 94d3e02ca18..2f54b07fb67 100755 --- a/assets/docker/entrypoint.sh +++ b/assets/docker/entrypoint.sh @@ -2,9 +2,11 @@ set -euf +GO=${GO:-go} + cd /chezmoi -go run . doctor || true -go test ./... +${GO} run . doctor || true +${GO} test ./... sh assets/scripts/install.sh bin/chezmoi --version diff --git a/assets/docker/fedora.Dockerfile b/assets/docker/fedora.Dockerfile index faa07b2c524..6baf55e6ba2 100644 --- a/assets/docker/fedora.Dockerfile +++ b/assets/docker/fedora.Dockerfile @@ -3,5 +3,9 @@ FROM fedora:latest RUN dnf update -y && \ dnf install -y bzip2 git gnupg golang +RUN go get golang.org/dl/go1.18 && \ + ${HOME}/go/bin/go1.18 download +ENV GO=/root/go/bin/go1.18 + COPY assets/docker/entrypoint.sh /entrypoint.sh ENTRYPOINT /entrypoint.sh diff --git a/assets/docker/test.sh b/assets/docker/test.sh index f998172f6ef..d44d047db1a 100755 --- a/assets/docker/test.sh +++ b/assets/docker/test.sh @@ -4,6 +4,7 @@ set -eufo pipefail cd ../.. for distribution in "$@"; do + echo ${distribution} dockerfile="assets/docker/${distribution}.Dockerfile" if [ ! -f "${dockerfile}" ]; then echo "${dockerfile} not found" diff --git a/assets/vagrant/openbsd6.Vagrantfile b/assets/vagrant/openbsd6.Vagrantfile deleted file mode 100644 index 9500da7c0c6..00000000000 --- a/assets/vagrant/openbsd6.Vagrantfile +++ /dev/null @@ -1,18 +0,0 @@ - -Vagrant.configure("2") do |config| - config.vm.box = "generic/openbsd6" - config.vm.define :openbsd6 - config.vm.hostname = "openbsd6" - config.vm.synced_folder ".", "/chezmoi", type: "rsync" - config.vm.provision "shell", inline: <<-SHELL - pkg_add -x bzip2 git gnupg go zip - SHELL - config.vm.provision "shell", inline: <<-SHELL - echo CHEZMOI_GITHUB_ACCESS_TOKEN=#{ENV['CHEZMOI_GITHUB_ACCESS_TOKEN']} >> /home/vagrant/.bash_profile - echo CHEZMOI_GITHUB_TOKEN=#{ENV['CHEZMOI_GITHUB_TOKEN']} >> /home/vagrant/.bash_profile - echo GITHUB_ACCESS_TOKEN=#{ENV['GITHUB_ACCESS_TOKEN']} >> /home/vagrant/.bash_profile - echo GITHUB_TOKEN=#{ENV['GITHUB_TOKEN']} >> /home/vagrant/.bash_profile - echo export CHEZMOI_GITHUB_ACCESS_TOKEN CHEZMOI_GITHUB_TOKEN GITHUB_ACCESS_TOKEN GITHUB_TOKEN >> /home/vagrant/.bash_profile - SHELL - config.vm.provision "file", source: "assets/vagrant/openbsd6.test-chezmoi.sh", destination: "test-chezmoi.sh" -end diff --git a/assets/vagrant/openbsd6.test-chezmoi.sh b/assets/vagrant/openbsd6.test-chezmoi.sh deleted file mode 100755 index c8eb950ae89..00000000000 --- a/assets/vagrant/openbsd6.test-chezmoi.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -set -eufo pipefail - -cd /chezmoi - -go test ./... - -sh assets/scripts/install.sh -bin/chezmoi --version diff --git a/assets/vagrant/test.sh b/assets/vagrant/test.sh index d5a995960ac..456c64ef157 100755 --- a/assets/vagrant/test.sh +++ b/assets/vagrant/test.sh @@ -3,6 +3,7 @@ set -eufo pipefail for os in "$@"; do + echo ${os} if [ ! -f "${os}.Vagrantfile" ]; then echo "${os}.Vagrantfile not found" exit 1 diff --git a/go.mod b/go.mod index c15e5dfb2c9..e90a26d62c0 100644 --- a/go.mod +++ b/go.mod @@ -1,65 +1,109 @@ module github.com/twpayne/chezmoi/v2 -go 1.16 +go 1.17 require ( filippo.io/age v1.0.0 github.com/Masterminds/sprig/v3 v3.2.2 - github.com/Microsoft/go-winio v0.5.2 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20220113124808-70ae35bab23f // indirect github.com/bmatcuk/doublestar/v4 v4.0.2 github.com/bradenhilton/mozillainstallhash v1.0.0 github.com/charmbracelet/glamour v0.5.0 github.com/coreos/go-semver v0.3.0 - github.com/danieljoos/wincred v1.1.2 // indirect github.com/go-git/go-git/v5 v5.4.2 - github.com/godbus/dbus/v5 v5.1.0 // indirect - github.com/google/btree v1.0.1 // indirect github.com/google/go-github/v43 v43.0.0 github.com/google/gops v0.3.22 github.com/google/renameio/v2 v2.0.0 - github.com/google/uuid v1.3.0 // indirect github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 - github.com/huandu/xstrings v1.3.2 // indirect - github.com/kevinburke/ssh_config v1.1.0 // indirect - github.com/magiconair/properties v1.8.6 // indirect - github.com/microcosm-cc/bluemonday v1.0.18 // indirect - github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.4.3 github.com/muesli/combinator v0.3.0 - github.com/muesli/termenv v0.11.0 // indirect github.com/pelletier/go-toml v1.9.4 - github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/rogpeppe/go-internal v1.8.1 github.com/rs/zerolog v1.26.1 github.com/sergi/go-diff v1.1.0 - github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/afero v1.8.2 github.com/spf13/cobra v1.4.0 github.com/spf13/viper v1.10.1 - github.com/stretchr/objx v0.3.0 // indirect github.com/stretchr/testify v1.7.1 github.com/twpayne/go-pinentry v0.2.0 github.com/twpayne/go-shell v0.3.1 github.com/twpayne/go-vfs/v4 v4.1.0 github.com/twpayne/go-xdg/v6 v6.0.0 github.com/ulikunitz/xz v0.5.10 - github.com/xanzy/ssh-agent v0.3.1 // indirect - github.com/yuin/goldmark v1.4.10 // indirect github.com/zalando/go-keyring v0.2.0 go.etcd.io/bbolt v1.3.6 - go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 - golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect - golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 - gopkg.in/ini.v1 v1.66.4 // indirect gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b howett.net/plist v1.0.0 ) +require ( + github.com/Masterminds/goutils v1.1.1 // indirect + github.com/Masterminds/semver/v3 v3.1.1 // indirect + github.com/Microsoft/go-winio v0.5.2 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20220113124808-70ae35bab23f // indirect + github.com/acomagu/bufpipe v1.0.3 // indirect + github.com/alecthomas/chroma v0.10.0 // indirect + github.com/alessio/shellescape v1.4.1 // indirect + github.com/aymerick/douceur v0.2.0 // indirect + github.com/bradenhilton/cityhash v1.0.0 // indirect + github.com/danieljoos/wincred v1.1.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dlclark/regexp2 v1.4.0 // indirect + github.com/emirpasic/gods v1.12.0 // indirect + github.com/fsnotify/fsnotify v1.5.1 // indirect + github.com/go-git/gcfg v1.5.0 // indirect + github.com/go-git/go-billy/v5 v5.3.1 // indirect + github.com/godbus/dbus/v5 v5.1.0 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/btree v1.0.1 // indirect + github.com/google/go-querystring v1.1.0 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/gorilla/css v1.0.0 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/huandu/xstrings v1.3.2 // indirect + github.com/imdario/mergo v0.3.12 // indirect + github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + github.com/kevinburke/ssh_config v1.1.0 // indirect + github.com/lucasb-eyer/go-colorful v1.2.0 // indirect + github.com/magiconair/properties v1.8.6 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-runewidth v0.0.13 // indirect + github.com/microcosm-cc/bluemonday v1.0.18 // indirect + github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/muesli/reflow v0.3.0 // indirect + github.com/muesli/termenv v0.11.0 // indirect + github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/peterbourgon/diskv v2.0.1+incompatible // indirect + github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rivo/uniseg v0.2.0 // indirect + github.com/shopspring/decimal v1.3.1 // indirect + github.com/spf13/cast v1.4.1 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/stretchr/objx v0.3.0 // indirect + github.com/subosito/gotenv v1.2.0 // indirect + github.com/xanzy/ssh-agent v0.3.1 // indirect + github.com/yuin/goldmark v1.4.10 // indirect + github.com/yuin/goldmark-emoji v1.0.1 // indirect + go.uber.org/atomic v1.9.0 // indirect + golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect + golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect + golang.org/x/text v0.3.7 // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/protobuf v1.27.1 // indirect + gopkg.in/errgo.v2 v2.1.0 // indirect + gopkg.in/ini.v1 v1.66.4 // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect +) + exclude github.com/sergi/go-diff v1.2.0 // Produces incorrect diffs diff --git a/go.sum b/go.sum index fdf2f2aea0b..682a275db1a 100644 --- a/go.sum +++ b/go.sum @@ -63,7 +63,6 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= @@ -76,7 +75,6 @@ github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugX github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= github.com/ProtonMail/go-crypto v0.0.0-20220113124808-70ae35bab23f h1:J2FzIrXN82q5uyUraeJpLIm7U6PffRwje2ORho5yIik= @@ -88,24 +86,19 @@ github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek= github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 h1:Hs82Z41s6SdL1CELW+XaDYmOH4hkBN4/N9og/AsOv7E= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0= github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= -github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1RINW/+RMTVmiwxETico2l3gxJA= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.3.10 h1:FR+drcQStOe+32sYyJYyZ7FIdgoGGBnwLl+flodp8Uo= github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= @@ -113,9 +106,7 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bmatcuk/doublestar/v4 v4.0.2 h1:X0krlUVAVmtr2cRoTqR8aDMrDqnB36ht8wpWTiQ3jsA= github.com/bmatcuk/doublestar/v4 v4.0.2/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= @@ -128,7 +119,6 @@ github.com/bradleyfalzon/ghinstallation/v2 v2.0.4/go.mod h1:B40qPqJxWE0jDZgOR1Jm github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0 h1:t/LhUZLVitR1Ow2YOnduCsavhwFUklBMoGVYUCqmCqk= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= @@ -141,9 +131,7 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5O github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible h1:C29Ae4G5GtYyYMm1aztcyj/J5ckgJm2zwdDajFbx1NY= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= -github.com/circonus-labs/circonusllhist v0.1.3 h1:TJH+oke8D16535+jHExHj4nQvzlZrj7ug5D7I/orNUA= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -198,7 +186,6 @@ github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjr github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= @@ -217,22 +204,18 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0 h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0 h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.2.6-0.20210915003542-8b1f7f90f6b1 h1:4dntyT+x6QTOSCIrgczbQ+ockAEha0cfxD5Wi0iCzjY= github.com/go-ole/go-ole v1.2.6-0.20210915003542-8b1f7f90f6b1/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= -github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v4 v4.0.0 h1:RAqyYixv1p7uEnocuy8P1nru5wprCh/MH2BIlW5z5/o= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= @@ -271,7 +254,6 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -297,15 +279,14 @@ github.com/google/go-github/v43 v43.0.0 h1:y+GL7LIsAIF2NZlJ46ZoC/D1W1ivZasT0lnWH github.com/google/go-github/v43 v43.0.0/go.mod h1:ZkTvvmCXBvsfPpTHXnH/d2hP9Y0cTbvN9kr5xqyXOIc= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= -github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gops v0.3.22 h1:lyvhDxfPLHAOR2xIYwjPhN387qHxyU21Sk9sz/GhmhQ= github.com/google/gops v0.3.22/go.mod h1:7diIdLsqpCihPSX3fQagksT/Ku/y4RL9LHTlKyEUDl8= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0 h1:wCKgOCHuUEVfsaQLpPSJb7VdYCdTVZQAuOdYm1yc/60= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.2.1 h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -316,12 +297,12 @@ github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2 h1:LR89qFljJ48s990kEKGsk213yIJDPI4205OKOzbURK8= github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= @@ -342,13 +323,10 @@ github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/consul/api v1.12.0 h1:k3y1FYv6nuKyNTqj6w9gXOx5r5CfLj/k/euUeBXj1OY= github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= -github.com/hashicorp/consul/sdk v0.8.0 h1:OJtKBtEjboEZvG6AOUdh4Z1Zbyu0WcxQ0qatRrZHTVU= github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= -github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -360,21 +338,15 @@ github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39E github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI= github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= -github.com/hashicorp/go-retryablehttp v0.5.3 h1:QlWt0KvWT0lq8MFppF9tsJGF+ynG7ztc2KIPhzRGk7s= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-sockaddr v1.0.0 h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sLo0ICXs= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-syslog v1.0.0 h1:KaodqZuhUoZereWVIYmpUgZysurB1kBLX2j0MwMrUAE= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -382,18 +354,14 @@ github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+l github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.4 h1:sY0CMhFmjIPDMlTB+HfymFHCaYLhgifZ0QhjaYKD/UQ= github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= -github.com/hashicorp/memberlist v0.3.0 h1:8+567mCcFDnS5ADl7lrpxPMWiFCElyUEeW0gtj34fMA= github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= github.com/hashicorp/serf v0.9.6 h1:uuEX1kLR6aoda1TBttmJQKDLZE1Ob7KN0NPdE7EtCDc= github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639 h1:mV02weKRL81bEnm8A0HT1/CAelMQDBuQIfLw8n+d6xI= @@ -416,14 +384,12 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kevinburke/ssh_config v1.1.0 h1:pH/t1WS9NzT8go394IqZeJTMHVm6Cr6ZJ6AQ+mdNo/o= github.com/kevinburke/ssh_config v1.1.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19 h1:WjT3fLi9n8YWh/Ih8Q1LHAPsTqGddPcHqscN+PJ3i68= github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19/go.mod h1:hY+WOq6m2FpbvyrI93sMaypsttvaIL5nhVR92dTMUcQ= -github.com/kisielk/errcheck v1.5.0 h1:e8esj/e4R+SAOwFwN+n3zr0nYeCyeweozKfO23MvHzY= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -431,7 +397,6 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGi github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -444,7 +409,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= -github.com/lyft/protoc-gen-star v0.5.3 h1:zSGLzsUew8RT+ZKPHc3jnf8XLaVyHzTcAFBzHtCNR20= github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= @@ -469,22 +433,18 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.17/go.mod h1:Z0r70sCuXHig8YpBzCc5eGHAap2K7e/u082ZUpDRRqM= github.com/microcosm-cc/bluemonday v1.0.18 h1:6HcxvXDAi3ARt3slx6nTesbvorIc3QeTzBNRvWktHBo= github.com/microcosm-cc/bluemonday v1.0.18/go.mod h1:Z0r70sCuXHig8YpBzCc5eGHAap2K7e/u082ZUpDRRqM= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= -github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/mitchellh/cli v1.1.0 h1:tEElEatulEHDeedTxwckzyYMA5c86fbmNIUL1hBIiTg= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= @@ -507,14 +467,12 @@ github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKt github.com/muesli/termenv v0.9.0/go.mod h1:R/LzAKf+suGs4IsO95y7+7DpFHO0KABgnZqtlyx2mBw= github.com/muesli/termenv v0.11.0 h1:fwNUbu2mfWlgicwG7qYzs06aOI8Z/zKPAv8J4uKbT+o= github.com/muesli/termenv v0.11.0/go.mod h1:Bd5NYQ7pd+SrtBSrSNoBBmXlcY8+Xj4BMJgh8qcZrvs= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223 h1:F9x/1yl3T2AeKLr2AMdilSD8+f9bvMnNN8VS5iDtovc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= @@ -532,28 +490,23 @@ github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qR github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.4.0 h1:YVIb/fVcOTMSqtqZWSKnHpSLBxu8DKgxq8z6RuBZwqI= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= @@ -565,11 +518,9 @@ github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc= github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f h1:UFr9zpz4xgTnIE5yIMtWAMngCdZ9p/+q6lTbgelo80M= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/crypt v0.4.0 h1:Rqcx6Sf/bWQUmmfGQhcFx3wQQEfb2UZWhAKvGRairm0= github.com/sagikazarmark/crypt v0.4.0/go.mod h1:ALv2SRj7GxYV4HO9elxH9nS6M9gW+xDNxqmyJ6RfDFM= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= @@ -583,7 +534,6 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= @@ -618,7 +568,6 @@ github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ= github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= -github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 h1:G3dpKMzFDjgEh2q1Z7zUUtKa8ViPtH+ocF0bE0g00O8= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/twpayne/go-pinentry v0.2.0 h1:hS5NEJiilop9xP9pBX/1NYduzDlGGMdg1KamTBTrOWw= github.com/twpayne/go-pinentry v0.2.0/go.mod h1:r6buhMwARxnnL0VRBqfd1tE6Fadk1kfP00GRMutEspY= @@ -666,7 +615,6 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/proto/otlp v0.7.0 h1:rwOQPCuKAKmwGKq2aVNnYIibI6wnV7EvzgfTCzcdGg8= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= @@ -675,7 +623,6 @@ go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9i go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= -go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -719,8 +666,8 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG6DXeebvUHFpre8QvbyI= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028 h1:4+4C/Iv2U4fMZBiMCc98MG1In4gJY5YRhtpDNeDeHWs= @@ -733,8 +680,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.0 h1:UG21uOlmZabA4fW5i7ZX6bjw1xELEGg/ZLgZq9auk/Q= golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1107,7 +1054,6 @@ google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9K google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.43.0 h1:Eeu7bZtDZ2DpRCsLhUlcrLnvYaMK1Gz86a+hMVvELmM= google.golang.org/grpc v1.43.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1123,7 +1069,6 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/main.go b/main.go index 5220872df02..8e35d3d02bd 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.17 +// +build go1.17 //go:generate go run . completion bash -o completions/chezmoi-completion.bash //go:generate go run . completion fish -o completions/chezmoi.fish diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index e6ec65795c7..d6d1211ecdc 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -7,7 +7,6 @@ import ( "encoding/json" "errors" "fmt" - "go/build" "io" "io/fs" "net/http" @@ -734,18 +733,13 @@ func (c *Config) createConfigFile(filename chezmoi.RelPath, data []byte) ([]byte funcMap := make(template.FuncMap) chezmoi.RecursiveMerge(funcMap, c.templateFuncs) initTemplateFuncs := map[string]interface{}{ + "exit": c.exitInitTemplateFunc, "promptBool": c.promptBoolInitTemplateFunc, "promptInt": c.promptIntInitTemplateFunc, "promptString": c.promptStringInitTemplateFunc, "stdinIsATTY": c.stdinIsATTYInitTemplateFunc, "writeToStdout": c.writeToStdout, } - for _, releaseTag := range build.Default.ReleaseTags { - if releaseTag == "go1.17" { - initTemplateFuncs["exit"] = c.exitInitTemplateFunc - break - } - } chezmoi.RecursiveMerge(funcMap, initTemplateFuncs) t, err := template.New(filename.String()).Funcs(funcMap).Parse(string(data)) diff --git a/pkg/cmd/config_test.go b/pkg/cmd/config_test.go index 2156bb87b74..fc495134dde 100644 --- a/pkg/cmd/config_test.go +++ b/pkg/cmd/config_test.go @@ -239,7 +239,7 @@ func withTestUser(t *testing.T, username string) configOption { config.homeDir = filepath.Join("/", "home", username) env = "HOME" } - testSetenv(t, env, config.homeDir) + t.Setenv(env, config.homeDir) var err error config.homeDirAbsPath, err = chezmoi.NormalizePath(config.homeDir) if err != nil { diff --git a/pkg/cmd/executetemplatecmd.go b/pkg/cmd/executetemplatecmd.go index 30868ca8dbf..faa455fd7a7 100644 --- a/pkg/cmd/executetemplatecmd.go +++ b/pkg/cmd/executetemplatecmd.go @@ -2,7 +2,6 @@ package cmd import ( "fmt" - "go/build" "io" "strconv" "strings" @@ -61,6 +60,7 @@ func (c *Config) runExecuteTemplateCmd(cmd *cobra.Command, args []string) error } if c.executeTemplate.init { initTemplateFuncs := map[string]interface{}{ + "exit": c.exitInitTemplateFunc, "promptBool": func(prompt string, args ...bool) bool { switch len(args) { case 0: @@ -111,12 +111,6 @@ func (c *Config) runExecuteTemplateCmd(cmd *cobra.Command, args []string) error }, "writeToStdout": c.writeToStdout, } - for _, releaseTag := range build.Default.ReleaseTags { - if releaseTag == "go1.17" { - initTemplateFuncs["exit"] = c.exitInitTemplateFunc - break - } - } chezmoi.RecursiveMerge(c.templateFuncs, initTemplateFuncs) } diff --git a/pkg/cmd/testdata/scripts/templatefuncs.txt b/pkg/cmd/testdata/scripts/templatefuncs.txt index 46329f85f52..ba4ea3efb4b 100644 --- a/pkg/cmd/testdata/scripts/templatefuncs.txt +++ b/pkg/cmd/testdata/scripts/templatefuncs.txt @@ -45,8 +45,8 @@ chezmoi execute-template '{{ (stat ".").isDir }}' stdout true # test exit template function -[build:go1.17] chezmoi execute-template --init '{{ exit 0 }}' -[build:go1.17] ! chezmoi execute-template --init '{{ exit 1 }}' +chezmoi execute-template --init '{{ exit 0 }}' +! chezmoi execute-template --init '{{ exit 1 }}' # test that the output template function returns a command's output chezmoi execute-template '{{ output "chezmoi-output-test" "arg" | trim }}' diff --git a/pkg/cmd/util_go1.16_test.go b/pkg/cmd/util_go1.16_test.go deleted file mode 100644 index 8a437e99960..00000000000 --- a/pkg/cmd/util_go1.16_test.go +++ /dev/null @@ -1,18 +0,0 @@ -//go:build !go1.17 -// +build !go1.17 - -package cmd - -import ( - "os" - "testing" -) - -func testSetenv(t *testing.T, key, value string) { - t.Helper() - prevValue := os.Getenv(key) - t.Cleanup(func() { - os.Setenv(key, prevValue) - }) - os.Setenv(key, value) -} diff --git a/pkg/cmd/util_go1.17_test.go b/pkg/cmd/util_go1.17_test.go deleted file mode 100644 index e7f4edb89ca..00000000000 --- a/pkg/cmd/util_go1.17_test.go +++ /dev/null @@ -1,11 +0,0 @@ -//go:build go1.17 -// +build go1.17 - -package cmd - -import "testing" - -func testSetenv(t *testing.T, key, value string) { - t.Helper() - t.Setenv(key, value) -}
chore
Remove support for Go 1.16
0f48bc77c28a34aa928b5717f60b986acb416a0b
2023-07-18 22:37:03
Tom Payne
docs: Clarify use of exclude patterns in .chezmoiignore
false
diff --git a/assets/chezmoi.io/docs/user-guide/manage-machine-to-machine-differences.md b/assets/chezmoi.io/docs/user-guide/manage-machine-to-machine-differences.md index c9b5aaaac3a..a2022a6ca17 100644 --- a/assets/chezmoi.io/docs/user-guide/manage-machine-to-machine-differences.md +++ b/assets/chezmoi.io/docs/user-guide/manage-machine-to-machine-differences.md @@ -132,14 +132,14 @@ install `.work` if hostname is `work-laptop`" but chezmoi installs everything by default, so we have to turn the logic around and instead write "ignore `.work` unless the hostname is `work-laptop`". -Patterns can be excluded by prefixing them with a `!`, for example: +Patterns can be excluded by starting the line with a `!`, for example: ``` title="~/.local/share/chezmoi/.chezmoiignore" -f* -!foo +dir/f* +!dir/foo ``` -will ignore all files beginning with an `f` except `foo`. +will ignore all files beginning with an `f` in `dir` except for `dir/foo`. You can see what files chezmoi ignores with the command
docs
Clarify use of exclude patterns in .chezmoiignore
4504bc3b4fd221d4a20e29a2b95ee9cffebadb10
2024-02-27 21:03:36
Tom Payne
chore: Run daily checks four hours earlier
false
diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index 325f14f4439..f2b3aa78727 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -9,7 +9,7 @@ on: tags: - v* schedule: - - cron: 22 2 * * * + - cron: 2 2 * * * jobs: govulncheck: runs-on: ubuntu-22.04 diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 62f9d0f2272..ebf8540ea07 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -2,7 +2,7 @@ name: lock-threads on: schedule: - - cron: 0 0 * * * + - cron: 2 2 * * * workflow_dispatch: {} permissions: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3316255177f..7bbf9a88787 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ on: tags: - v* schedule: - - cron: 22 2 * * * + - cron: 2 2 * * * env: ACTIONLINT_VERSION: 1.6.26 AGE_VERSION: 1.1.1
chore
Run daily checks four hours earlier
9844fb3221783ee327a32e52818a4815fa9c3561
2024-11-12 22:09:09
Ruslan Sayfutdinov
chore: Shard testscript tests
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 03f98ff0593..9f7fc3f070f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -126,6 +126,11 @@ jobs: export DOCKER_GOCACHE="$HOME/.go-archlinux" ./assets/docker/test.sh archlinux test-macos: + name: test-macos-${{ matrix.test-index }} + strategy: + fail-fast: false + matrix: + test-index: [0, 1, 2] needs: changes if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: macos-15 @@ -159,7 +164,14 @@ jobs: env: CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} run: | - go test -race ./... + if [ "${{ matrix.test-index }}" = "0" ]; then + go test ./... -short -race + go test ./internal/cmd -run=TestScript -filter='^[0-9a-dA-D]' -race + elif [ "${{ matrix.test-index }}" = "1" ]; then + go test ./internal/cmd -run=TestScript -filter='^[e-iE-I]' -race + else + go test ./internal/cmd -run=TestScript -filter='^[j-zJ-Z]' -race + fi test-oldstable-go: needs: changes if: github.event_name == 'push' || needs.changes.outputs.code == 'true' @@ -257,13 +269,14 @@ jobs: name: chezmoi-windows-amd64 path: dist/chezmoi-nocgo_windows_amd64_v1/chezmoi.exe test-ubuntu: - name: test-ubuntu-umask${{ matrix.umask }} + name: test-ubuntu-umask${{ matrix.umask }}-${{ matrix.test-index }} strategy: fail-fast: false matrix: umask: - "022" - "002" + test-index: [0, 1] needs: changes runs-on: ubuntu-22.04 permissions: @@ -298,8 +311,14 @@ jobs: if: github.event_name == 'push' || needs.changes.outputs.code == 'true' env: CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} - run: | - go test -ldflags="-X github.com/twpayne/chezmoi/v2/internal/chezmoitest.umaskStr=0o${{ matrix.umask }}" -race -timeout=1h ./... + TEST_FLAGS: '-ldflags="-X github.com/twpayne/chezmoi/v2/internal/chezmoitest.umaskStr=0o${{ matrix.umask }}" -race -timeout=1h' + run: | + if [ "${{ matrix.test-index }}" = "0" ]; then + go test ./... -short ${{ env.TEST_FLAGS }} + go test ./internal/cmd -run=TestScript -filter='^[0-9a-hA-h]' ${{ env.TEST_FLAGS }} + else + go test ./internal/cmd -run=TestScript -filter='^[i-zI-Z]' ${{ env.TEST_FLAGS }} + fi test-website: runs-on: ubuntu-22.04 permissions: @@ -323,6 +342,11 @@ jobs: env: CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} test-windows: + name: test-windows-${{ matrix.test-index }} + strategy: + fail-fast: false + matrix: + test-index: [0, 1] needs: changes if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: windows-2022 @@ -343,7 +367,12 @@ jobs: env: CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} run: | - go test -race ./... + if (${{ matrix.test-index }} -eq 0) { + go test ./... -short -race + go test ./internal/cmd -run=TestScript -filter='^[0-9a-hA-h]' -race + } else { + go test ./internal/cmd -run=TestScript -filter='^[i-zI-Z]' -race + } check: runs-on: ubuntu-22.04 permissions:
chore
Shard testscript tests
2a7845f4ffe2fd427c140711c0d7d46424747363
2024-07-16 01:06:30
Tom Payne
feat: Add 1Password SDK template funcs
false
diff --git a/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml b/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml index 5c051fca792..1367817f63b 100644 --- a/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml +++ b/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml @@ -335,6 +335,11 @@ sections: mode: default: '`account`' description: See [1Password Secrets Automation](../../user-guide/password-managers/1password.md#secrets-automation) + onepasswordSDK: + token: + description: See [1Password SDK functions](../templates/1password-sdk-functions/index.md) + tokenEnvVar: + description: See [1Password SDK functions](../templates/1password-sdk-functions/index.md) pass: command: default: '`pass`' diff --git a/assets/chezmoi.io/docs/reference/templates/1password-sdk-functions/index.md b/assets/chezmoi.io/docs/reference/templates/1password-sdk-functions/index.md new file mode 100644 index 00000000000..41f54f76af8 --- /dev/null +++ b/assets/chezmoi.io/docs/reference/templates/1password-sdk-functions/index.md @@ -0,0 +1,15 @@ +# 1Password SDK functions + +!!! warning + + 1Password SDK template functions are experimental and may change. + +The `onepasswordSDK*` template functions return structured data from +[1Password](https://1password.com/) using the [1Password +SDK](https://developer.1password.com/docs/sdks/). + +By default, the 1Password service account token is taken from the +`$OP_SERVICE_ACCOUNT_TOKEN` environment variable. The name of the environment +variable can be set with `onepasswordSDK.tokenEnvVar` configuration variable, or +the token can be set explicitly by setting the `onepasswordSDK.token` +configuration variable. diff --git a/assets/chezmoi.io/docs/reference/templates/1password-sdk-functions/onepasswordSDKItemsGet.md b/assets/chezmoi.io/docs/reference/templates/1password-sdk-functions/onepasswordSDKItemsGet.md new file mode 100644 index 00000000000..baef1a744ad --- /dev/null +++ b/assets/chezmoi.io/docs/reference/templates/1password-sdk-functions/onepasswordSDKItemsGet.md @@ -0,0 +1,17 @@ +# `onepasswordSDKItemsGet` *vault-id* *item-id* + +!!! warning + + `onepasswordSDKItemsGet` is an experimental function and may change. + +`onepasswordSDKItemsGet` returns an item from [1Password](https://1password.com) +using the [1Password SDK](https://developer.1password.com/docs/sdks/). + +The output of `onepasswordSDKItemsGet` is cached so multiple calls to +`onepasswordSDKItemsGet` with the same *vault-id* and *item-id* will return the same value. + +!!! example + + ``` + {{- onepasswordSDKItemsGet "vault" "item" | toJson -}} + ``` diff --git a/assets/chezmoi.io/docs/reference/templates/1password-sdk-functions/onepasswordSDKSecretsResolve.md b/assets/chezmoi.io/docs/reference/templates/1password-sdk-functions/onepasswordSDKSecretsResolve.md new file mode 100644 index 00000000000..a6971357aa4 --- /dev/null +++ b/assets/chezmoi.io/docs/reference/templates/1password-sdk-functions/onepasswordSDKSecretsResolve.md @@ -0,0 +1,17 @@ +# `onepasswordSDKSecretsResolve` *url* + +!!! warning + + `onepasswordSDKSecretsResolve` is an experimental function and may change. + +`onepasswordSDKSecretsResolve` returns a secret from [1Password](https://1password.com) +using the [1Password SDK](https://developer.1password.com/docs/sdks/). + +The output of `onepasswordSDKSecretsResolve` is cached so multiple calls to +`onepasswordSDKSecretsResolve` with the same *url* will return the same value. + +!!! example + + ``` + {{- onepasswordSDKSecretsResolve "op://vault/item/field" -}} + ``` diff --git a/assets/chezmoi.io/mkdocs.yml b/assets/chezmoi.io/mkdocs.yml index 098df462b8d..31a9df256d9 100644 --- a/assets/chezmoi.io/mkdocs.yml +++ b/assets/chezmoi.io/mkdocs.yml @@ -249,6 +249,10 @@ nav: - onepasswordDetailsFields: reference/templates/1password-functions/onepasswordDetailsFields.md - onepasswordItemFields: reference/templates/1password-functions/onepasswordItemFields.md - onepasswordRead: reference/templates/1password-functions/onepasswordRead.md + - 1Password SDK functions: + - reference/templates/1password-sdk-functions/index.md + - onepasswordSDKItemsGet: reference/templates/1password-sdk-functions/onepasswordSDKItemsGet.md + - onepasswordSDKSecretsResolve: reference/templates/1password-sdk-functions/onepasswordSDKSecretsResolve.md - AWS Secrets Manager functions: - reference/templates/aws-secrets-manager-functions/index.md - awsSecretsManager: reference/templates/aws-secrets-manager-functions/awsSecretsManager.md diff --git a/go.mod b/go.mod index 85e6271e35f..b9f7a448a01 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ toolchain go1.22.0 require ( filippo.io/age v1.2.0 + github.com/1password/onepassword-sdk-go v0.1.0-beta.10 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.1.0 github.com/Masterminds/sprig/v3 v3.2.3 @@ -101,10 +102,12 @@ require ( github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect + github.com/extism/go-sdk v1.3.0 // indirect github.com/fatih/semgroup v1.2.0 // indirect github.com/gitleaks/go-gitdiff v0.9.0 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect + github.com/gobwas/glob v0.2.3 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect @@ -148,6 +151,7 @@ require ( github.com/spf13/cast v1.6.0 // indirect github.com/spf13/viper v1.19.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect + github.com/tetratelabs/wazero v1.7.3 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/yuin/goldmark v1.7.4 // indirect diff --git a/go.sum b/go.sum index e3255bb044c..f26e10db143 100644 --- a/go.sum +++ b/go.sum @@ -20,6 +20,8 @@ filippo.io/age v1.2.0 h1:vRDp7pUMaAJzXNIWJVAZnEf/Dyi4Vu4wI8S1LBzufhE= filippo.io/age v1.2.0/go.mod h1:JL9ew2lTN+Pyft4RiNGguFfOpewKwSHm5ayKD/A4004= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +github.com/1password/onepassword-sdk-go v0.1.0-beta.10 h1:vYm15kP/HMWdJaScgWFUu0zxl5QeRgUAwg322VabV54= +github.com/1password/onepassword-sdk-go v0.1.0-beta.10/go.mod h1:FnJzZHo0kfR7U4M3f9xRbKIAn+sR9pn1Ssu3zGDcMpM= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0 h1:1nGuui+4POelzDwI7RG56yfQJHCnKvwfMoU7VsEp+Zg= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0/go.mod h1:99EvauvlcJ1U06amZiksfYz/3aFGyIhWGHVyiZXtBAI= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= @@ -161,6 +163,8 @@ github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= +github.com/extism/go-sdk v1.3.0 h1:DBd4FzDBUAL3P01MNqUD2+x8G7qyYdJ7pV96NIrfWXA= +github.com/extism/go-sdk v1.3.0/go.mod h1:tPMWfCSOThie3LSTSZKbrQjRm2oAXxUUjSE4HJWjYQM= github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w= github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg= github.com/fatih/semgroup v1.2.0 h1:h/OLXwEM+3NNyAdZEpMiH1OzfplU09i2qXPVThGZvyg= @@ -187,6 +191,8 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= +github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -434,6 +440,8 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a h1:SJy1Pu0eH1C29XwJucQo73FrleVK6t4kYz4NVhp34Yw= github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a/go.mod h1:DFSS3NAGHthKo1gTlmEcSBiZrRJXi28rLNd/1udP1c8= +github.com/tetratelabs/wazero v1.7.3 h1:PBH5KVahrt3S2AHgEjKu4u+LlDbbk+nsGE3KLucy6Rw= +github.com/tetratelabs/wazero v1.7.3/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= github.com/twpayne/go-expect v0.0.1 h1:cRJ552FIdQzs4z98Q2OLQsGLSbkB7Xpm/IU6cyQ6mUM= github.com/twpayne/go-expect v0.0.1/go.mod h1:+ffr+YtUt8ifebyvRQ3NhVTiLch/HnfxsAQqO5LeXss= github.com/twpayne/go-pinentry/v4 v4.0.0 h1:8WcNa+UDVRzz7y9OEEU/nRMX+UGFPCAvl5XsqWRxTY4= diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 5cc7cbb0def..b1a512a9493 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -139,6 +139,7 @@ type ConfigFile struct { Keeper keeperConfig `json:"keeper" mapstructure:"keeper" yaml:"keeper"` Lastpass lastpassConfig `json:"lastpass" mapstructure:"lastpass" yaml:"lastpass"` Onepassword onepasswordConfig `json:"onepassword" mapstructure:"onepassword" yaml:"onepassword"` + OnepasswordSDK onepasswordSDKConfig `json:"onepasswordSDK" mapstructure:"onepasswordSDK" yaml:"onepasswordSDK"` //nolint:tagliatelle Pass passConfig `json:"pass" mapstructure:"pass" yaml:"pass"` Passhole passholeConfig `json:"passhole" mapstructure:"passhole" yaml:"passhole"` RBW rbwConfig `json:"rbw" mapstructure:"rbw" yaml:"rbw"` @@ -407,88 +408,90 @@ func newConfig(options ...configOption) (*Config, error) { // The completion template function is added in persistentPreRunRootE as // it needs a *cobra.Command, which we don't yet have. for key, value := range map[string]any{ - "awsSecretsManager": c.awsSecretsManagerTemplateFunc, - "awsSecretsManagerRaw": c.awsSecretsManagerRawTemplateFunc, - "azureKeyVault": c.azureKeyVaultTemplateFunc, - "bitwarden": c.bitwardenTemplateFunc, - "bitwardenAttachment": c.bitwardenAttachmentTemplateFunc, - "bitwardenAttachmentByRef": c.bitwardenAttachmentByRefTemplateFunc, - "bitwardenFields": c.bitwardenFieldsTemplateFunc, - "bitwardenSecrets": c.bitwardenSecretsTemplateFunc, - "comment": c.commentTemplateFunc, - "dashlaneNote": c.dashlaneNoteTemplateFunc, - "dashlanePassword": c.dashlanePasswordTemplateFunc, - "decrypt": c.decryptTemplateFunc, - "deleteValueAtPath": c.deleteValueAtPathTemplateFunc, - "doppler": c.dopplerTemplateFunc, - "dopplerProjectJson": c.dopplerProjectJSONTemplateFunc, - "ejsonDecrypt": c.ejsonDecryptTemplateFunc, - "ejsonDecryptWithKey": c.ejsonDecryptWithKeyTemplateFunc, - "encrypt": c.encryptTemplateFunc, - "eqFold": c.eqFoldTemplateFunc, - "findExecutable": c.findExecutableTemplateFunc, - "findOneExecutable": c.findOneExecutableTemplateFunc, - "fromIni": c.fromIniTemplateFunc, - "fromJson": c.fromJsonTemplateFunc, - "fromJsonc": c.fromJsoncTemplateFunc, - "fromToml": c.fromTomlTemplateFunc, - "fromYaml": c.fromYamlTemplateFunc, - "gitHubKeys": c.gitHubKeysTemplateFunc, - "gitHubLatestRelease": c.gitHubLatestReleaseTemplateFunc, - "gitHubLatestReleaseAssetURL": c.gitHubLatestReleaseAssetURLTemplateFunc, - "gitHubLatestTag": c.gitHubLatestTagTemplateFunc, - "gitHubReleases": c.gitHubReleasesTemplateFunc, - "gitHubTags": c.gitHubTagsTemplateFunc, - "glob": c.globTemplateFunc, - "gopass": c.gopassTemplateFunc, - "gopassRaw": c.gopassRawTemplateFunc, - "hcpVaultSecret": c.hcpVaultSecretTemplateFunc, - "hcpVaultSecretJson": c.hcpVaultSecretJSONTemplateFunc, - "hexDecode": c.hexDecodeTemplateFunc, - "hexEncode": c.hexEncodeTemplateFunc, - "include": c.includeTemplateFunc, - "includeTemplate": c.includeTemplateTemplateFunc, - "ioreg": c.ioregTemplateFunc, - "isExecutable": c.isExecutableTemplateFunc, - "joinPath": c.joinPathTemplateFunc, - "jq": c.jqTemplateFunc, - "keepassxc": c.keepassxcTemplateFunc, - "keepassxcAttachment": c.keepassxcAttachmentTemplateFunc, - "keepassxcAttribute": c.keepassxcAttributeTemplateFunc, - "keeper": c.keeperTemplateFunc, - "keeperDataFields": c.keeperDataFieldsTemplateFunc, - "keeperFindPassword": c.keeperFindPasswordTemplateFunc, - "keyring": c.keyringTemplateFunc, - "lastpass": c.lastpassTemplateFunc, - "lastpassRaw": c.lastpassRawTemplateFunc, - "lookPath": c.lookPathTemplateFunc, - "lstat": c.lstatTemplateFunc, - "mozillaInstallHash": c.mozillaInstallHashTemplateFunc, - "onepassword": c.onepasswordTemplateFunc, - "onepasswordDetailsFields": c.onepasswordDetailsFieldsTemplateFunc, - "onepasswordDocument": c.onepasswordDocumentTemplateFunc, - "onepasswordItemFields": c.onepasswordItemFieldsTemplateFunc, - "onepasswordRead": c.onepasswordReadTemplateFunc, - "output": c.outputTemplateFunc, - "pass": c.passTemplateFunc, - "passFields": c.passFieldsTemplateFunc, - "passhole": c.passholeTemplateFunc, - "passRaw": c.passRawTemplateFunc, - "pruneEmptyDicts": c.pruneEmptyDictsTemplateFunc, - "quoteList": c.quoteListTemplateFunc, - "rbw": c.rbwTemplateFunc, - "rbwFields": c.rbwFieldsTemplateFunc, - "replaceAllRegex": c.replaceAllRegexTemplateFunc, - "secret": c.secretTemplateFunc, - "secretJSON": c.secretJSONTemplateFunc, - "setValueAtPath": c.setValueAtPathTemplateFunc, - "splitList": c.splitListTemplateFunc, - "stat": c.statTemplateFunc, - "toIni": c.toIniTemplateFunc, - "toPrettyJson": c.toPrettyJsonTemplateFunc, - "toToml": c.toTomlTemplateFunc, - "toYaml": c.toYamlTemplateFunc, - "vault": c.vaultTemplateFunc, + "awsSecretsManager": c.awsSecretsManagerTemplateFunc, + "awsSecretsManagerRaw": c.awsSecretsManagerRawTemplateFunc, + "azureKeyVault": c.azureKeyVaultTemplateFunc, + "bitwarden": c.bitwardenTemplateFunc, + "bitwardenAttachment": c.bitwardenAttachmentTemplateFunc, + "bitwardenAttachmentByRef": c.bitwardenAttachmentByRefTemplateFunc, + "bitwardenFields": c.bitwardenFieldsTemplateFunc, + "bitwardenSecrets": c.bitwardenSecretsTemplateFunc, + "comment": c.commentTemplateFunc, + "dashlaneNote": c.dashlaneNoteTemplateFunc, + "dashlanePassword": c.dashlanePasswordTemplateFunc, + "decrypt": c.decryptTemplateFunc, + "deleteValueAtPath": c.deleteValueAtPathTemplateFunc, + "doppler": c.dopplerTemplateFunc, + "dopplerProjectJson": c.dopplerProjectJSONTemplateFunc, + "ejsonDecrypt": c.ejsonDecryptTemplateFunc, + "ejsonDecryptWithKey": c.ejsonDecryptWithKeyTemplateFunc, + "encrypt": c.encryptTemplateFunc, + "eqFold": c.eqFoldTemplateFunc, + "findExecutable": c.findExecutableTemplateFunc, + "findOneExecutable": c.findOneExecutableTemplateFunc, + "fromIni": c.fromIniTemplateFunc, + "fromJson": c.fromJsonTemplateFunc, + "fromJsonc": c.fromJsoncTemplateFunc, + "fromToml": c.fromTomlTemplateFunc, + "fromYaml": c.fromYamlTemplateFunc, + "gitHubKeys": c.gitHubKeysTemplateFunc, + "gitHubLatestRelease": c.gitHubLatestReleaseTemplateFunc, + "gitHubLatestReleaseAssetURL": c.gitHubLatestReleaseAssetURLTemplateFunc, + "gitHubLatestTag": c.gitHubLatestTagTemplateFunc, + "gitHubReleases": c.gitHubReleasesTemplateFunc, + "gitHubTags": c.gitHubTagsTemplateFunc, + "glob": c.globTemplateFunc, + "gopass": c.gopassTemplateFunc, + "gopassRaw": c.gopassRawTemplateFunc, + "hcpVaultSecret": c.hcpVaultSecretTemplateFunc, + "hcpVaultSecretJson": c.hcpVaultSecretJSONTemplateFunc, + "hexDecode": c.hexDecodeTemplateFunc, + "hexEncode": c.hexEncodeTemplateFunc, + "include": c.includeTemplateFunc, + "includeTemplate": c.includeTemplateTemplateFunc, + "ioreg": c.ioregTemplateFunc, + "isExecutable": c.isExecutableTemplateFunc, + "joinPath": c.joinPathTemplateFunc, + "jq": c.jqTemplateFunc, + "keepassxc": c.keepassxcTemplateFunc, + "keepassxcAttachment": c.keepassxcAttachmentTemplateFunc, + "keepassxcAttribute": c.keepassxcAttributeTemplateFunc, + "keeper": c.keeperTemplateFunc, + "keeperDataFields": c.keeperDataFieldsTemplateFunc, + "keeperFindPassword": c.keeperFindPasswordTemplateFunc, + "keyring": c.keyringTemplateFunc, + "lastpass": c.lastpassTemplateFunc, + "lastpassRaw": c.lastpassRawTemplateFunc, + "lookPath": c.lookPathTemplateFunc, + "lstat": c.lstatTemplateFunc, + "mozillaInstallHash": c.mozillaInstallHashTemplateFunc, + "onepassword": c.onepasswordTemplateFunc, + "onepasswordDetailsFields": c.onepasswordDetailsFieldsTemplateFunc, + "onepasswordDocument": c.onepasswordDocumentTemplateFunc, + "onepasswordItemFields": c.onepasswordItemFieldsTemplateFunc, + "onepasswordRead": c.onepasswordReadTemplateFunc, + "onepasswordSDKItemsGet": c.onepasswordSDKItemsGet, + "onepasswordSDKSecretsResolve": c.onepasswordSDKSecretsResolve, + "output": c.outputTemplateFunc, + "pass": c.passTemplateFunc, + "passFields": c.passFieldsTemplateFunc, + "passhole": c.passholeTemplateFunc, + "passRaw": c.passRawTemplateFunc, + "pruneEmptyDicts": c.pruneEmptyDictsTemplateFunc, + "quoteList": c.quoteListTemplateFunc, + "rbw": c.rbwTemplateFunc, + "rbwFields": c.rbwFieldsTemplateFunc, + "replaceAllRegex": c.replaceAllRegexTemplateFunc, + "secret": c.secretTemplateFunc, + "secretJSON": c.secretJSONTemplateFunc, + "setValueAtPath": c.setValueAtPathTemplateFunc, + "splitList": c.splitListTemplateFunc, + "stat": c.statTemplateFunc, + "toIni": c.toIniTemplateFunc, + "toPrettyJson": c.toPrettyJsonTemplateFunc, + "toToml": c.toTomlTemplateFunc, + "toYaml": c.toYamlTemplateFunc, + "vault": c.vaultTemplateFunc, } { c.addTemplateFunc(key, value) } @@ -2772,6 +2775,9 @@ func newConfigFile(bds *xdg.BaseDirectorySpecification) ConfigFile { Prompt: true, Mode: onepasswordModeAccount, }, + OnepasswordSDK: onepasswordSDKConfig{ + TokenEnvVar: "OP_SERVICE_ACCOUNT_TOKEN", + }, Pass: passConfig{ Command: "pass", }, diff --git a/internal/cmd/onepasswordsdktemplatefuncs.go b/internal/cmd/onepasswordsdktemplatefuncs.go new file mode 100644 index 00000000000..26abdbb0e8a --- /dev/null +++ b/internal/cmd/onepasswordsdktemplatefuncs.go @@ -0,0 +1,125 @@ +package cmd + +import ( + "context" + "os" + "strings" + + "github.com/1password/onepassword-sdk-go" +) + +type onepasswordSDKConfig struct { + Token string `json:"token" mapstructure:"token" yaml:"token"` + TokenEnvVar string `json:"tokenEnvVar" mapstructure:"tokenEnvVar" yaml:"tokenEnvVar"` + itemsGetCache map[string]onepasswordSDKItem + secretsResolveCache map[string]string + client *onepassword.Client + clientErr error +} + +type onepasswordSDKItem struct { + ID string + Title string + Category onepassword.ItemCategory + VaultID string + Fields map[string]onepassword.ItemField + Sections map[string]onepassword.ItemSection +} + +func (c *Config) onepasswordSDKItemsGet(vaultID, itemID string) onepasswordSDKItem { + key := strings.Join([]string{vaultID, itemID}, "\x00") + if result, ok := c.OnepasswordSDK.itemsGetCache[key]; ok { + return result + } + + ctx := context.TODO() + + client, err := c.onepasswordSDKClient(ctx) + if err != nil { + panic(err) + } + + item, err := client.Items.Get(ctx, vaultID, itemID) + if err != nil { + panic(err) + } + + if c.OnepasswordSDK.itemsGetCache == nil { + c.OnepasswordSDK.itemsGetCache = make(map[string]onepasswordSDKItem) + } + + fields := make(map[string]onepassword.ItemField) + for _, field := range item.Fields { + fields[field.ID] = field + } + + sections := make(map[string]onepassword.ItemSection) + for _, section := range item.Sections { + sections[section.ID] = section + } + + onepasswordSDKItem := onepasswordSDKItem{ + ID: item.ID, + Title: item.Title, + Category: item.Category, + VaultID: item.VaultID, + Fields: fields, + Sections: sections, + } + + c.OnepasswordSDK.itemsGetCache[key] = onepasswordSDKItem + + return onepasswordSDKItem +} + +func (c *Config) onepasswordSDKSecretsResolve(secretReference string) string { + if result, ok := c.OnepasswordSDK.secretsResolveCache[secretReference]; ok { + return result + } + + ctx := context.TODO() + + client, err := c.onepasswordSDKClient(ctx) + if err != nil { + panic(err) + } + + secret, err := client.Secrets.Resolve(ctx, secretReference) + if err != nil { + panic(err) + } + + if c.OnepasswordSDK.secretsResolveCache == nil { + c.OnepasswordSDK.secretsResolveCache = make(map[string]string) + } + c.OnepasswordSDK.secretsResolveCache[secretReference] = secret + + return secret +} + +func (c *Config) onepasswordSDKClient(ctx context.Context) (*onepassword.Client, error) { + if c.OnepasswordSDK.client != nil || c.OnepasswordSDK.clientErr != nil { + return c.OnepasswordSDK.client, c.OnepasswordSDK.clientErr + } + + token := c.OnepasswordSDK.Token + if token == "" { + token = os.Getenv(c.OnepasswordSDK.TokenEnvVar) + } + + version := c.versionInfo.Version + if version == "" { + version = c.versionInfo.Commit + } + if version == "" { + version = onepassword.DefaultIntegrationVersion + } + + c.OnepasswordSDK.client, c.OnepasswordSDK.clientErr = onepassword.NewClient( + ctx, + onepassword.WithIntegrationInfo("chezmoi", version), + onepassword.WithServiceAccountToken(token), + ) + + return c.OnepasswordSDK.client, c.OnepasswordSDK.clientErr +}
feat
Add 1Password SDK template funcs
6b82c372019395d9a338a01c7dd9c95380857465
2022-10-26 18:17:23
Lawrence Chou
docs(bitwarden): Correct bitwardenFields example
false
diff --git a/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/bitwardenFields.md b/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/bitwardenFields.md index 17ed8252180..f9c320e0d76 100644 --- a/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/bitwardenFields.md +++ b/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/bitwardenFields.md @@ -30,15 +30,15 @@ the same arguments will only invoke `bw get` once. "notes": null, "favorite": false, "fields": [ - { - "name": "text", - "value": "text-value", - "type": 0 - }, { "name": "hidden", "value": "hidden-value", "type": 1 + }, + { + "name": "token", + "value": "token-value", + "type": 0 } ], "login": {
docs
Correct bitwardenFields example
6123962398190728a7f3ae4eb8862bde9087f06e
2021-01-24 23:16:35
Justin Grote
fix: Musl and Glibc Linux Binaries
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1d2cf2e101a..bf62cc9bec2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -95,23 +95,36 @@ jobs: uses: actions/upload-artifact@v2 with: name: chezmoi2-linux-amd64 - path: dist/chezmoi2-nocgo_linux_amd64/chezmoi + path: dist/chezmoi2-cgo-glibc_linux_amd64/chezmoi - name: Artifact chezmoi-linux-amd64 uses: actions/upload-artifact@v2 with: name: chezmoi-linux-amd64 - path: dist/chezmoi-nocgo_linux_amd64/chezmoi + path: dist/chezmoi-cgo-glibc_linux_amd64/chezmoi + + - name: Artifact chezmoi2-linux-musl-amd64 + uses: actions/upload-artifact@v2 + with: + name: chezmoi2-linux-musl-amd64 + path: dist/chezmoi2-cgo-musl_linux_amd64/chezmoi + + - name: Artifact chezmoi-linux-musl-amd64 + uses: actions/upload-artifact@v2 + with: + name: chezmoi-linux-musl-amd64 + path: dist/chezmoi-cgo-musl_linux_amd64/chezmoi - name: Artifact chezmoi2-macos-amd64 uses: actions/upload-artifact@v2 with: name: chezmoi2-macos-amd64 path: dist/chezmoi2-nocgo_darwin_amd64/chezmoi - - name: Artifact chezmoi-windows-amd64 + + - name: Artifact chezmoi-macos-amd64 uses: actions/upload-artifact@v2 with: - name: chezmoi-windows-amd64 + name: chezmoi-macos-amd64 path: dist/chezmoi-nocgo_darwin_amd64/chezmoi generate: runs-on: ubuntu-18.04
fix
Musl and Glibc Linux Binaries
2d76d647ac818589a28592119cf3b30b1d82254b
2023-05-04 05:13:10
Tom Payne
chore: Add chezmoiassert package
false
diff --git a/pkg/chezmoiassert/chezmoiassert.go b/pkg/chezmoiassert/chezmoiassert.go new file mode 100644 index 00000000000..afc328068bd --- /dev/null +++ b/pkg/chezmoiassert/chezmoiassert.go @@ -0,0 +1,43 @@ +// Package chezmoiassert implements testing assertions not implemented by +// github.com/alecthomas/assert/v2. +package chezmoiassert + +import ( + "fmt" + "testing" + + "github.com/alecthomas/assert/v2" +) + +func PanicsWithError(tb testing.TB, expected error, fn func(), msgAndArgs ...interface{}) { + tb.Helper() + defer func() { + if value, ok := recover().(error); ok { + assert.Equal(tb, expected, value, msgAndArgs...) + } else { + msg := formatMsgAndArgs("Expected function to panic with error", msgAndArgs...) + tb.Fatal(msg) + } + }() + fn() +} + +func PanicsWithErrorString(tb testing.TB, errString string, fn func(), msgAndArgs ...interface{}) { + tb.Helper() + defer func() { + if value, ok := recover().(error); ok { + assert.EqualError(tb, value, errString, msgAndArgs...) + } else { + msg := formatMsgAndArgs("Expected function to panic with error string", msgAndArgs...) + tb.Fatal(msg) + } + }() + fn() +} + +func formatMsgAndArgs(dflt string, msgAndArgs ...interface{}) string { + if len(msgAndArgs) == 0 { + return dflt + } + return fmt.Sprintf(msgAndArgs[0].(string), msgAndArgs[1:]...) //nolint:forcetypeassert +}
chore
Add chezmoiassert package
4a9d0e4d5d04f7812678607151fd20cfea843e37
2024-04-22 07:13:07
Tom Payne
feat: Include name of target in error message
false
diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 127dad37ea1..22e77fd7efa 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -652,11 +652,14 @@ func (c *Config) applyArgs( switch err := sourceState.Apply(targetSystem, c.destSystem, c.persistentState, targetDirAbsPath, targetRelPath, applyOptions); { case errors.Is(err, fs.SkipDir): continue - case err != nil && c.keepGoing: - c.errorf("%v\n", err) - keptGoingAfterErr = true case err != nil: - return err + err = fmt.Errorf("%s: %w", targetRelPath, err) + if c.keepGoing { + c.errorf("%v\n", err) + keptGoingAfterErr = true + } else { + return err + } } } diff --git a/internal/cmd/testdata/scripts/apply.txtar b/internal/cmd/testdata/scripts/apply.txtar index 1189b40357f..cb00e269acc 100644 --- a/internal/cmd/testdata/scripts/apply.txtar +++ b/internal/cmd/testdata/scripts/apply.txtar @@ -69,3 +69,4 @@ grep -count=2 '# edited' $HOME/.file # test that chezmoi apply --source-path fails when called with a targetDirAbsPath ! exec chezmoi apply --force --source-path $HOME${/}.file +[!windows] stderr ${HOME@R}/\.file:\snot\sin\s${CHEZMOISOURCEDIR@R}$ diff --git a/internal/cmd/testdata/scripts/external.txtar b/internal/cmd/testdata/scripts/external.txtar index 853ba0d2f60..6e14a26ec80 100644 --- a/internal/cmd/testdata/scripts/external.txtar +++ b/internal/cmd/testdata/scripts/external.txtar @@ -97,7 +97,7 @@ chhome home11/user # test that checksums detect corrupt files ! exec chezmoi apply --force -stderr 'MD5 mismatch' +stderr \.file:\sMD5\smismatch stderr 'SHA256 mismatch' chhome home12/user diff --git a/internal/cmd/testdata/scripts/keepgoing.txtar b/internal/cmd/testdata/scripts/keepgoing.txtar index 8257576fa4e..9169aa4604e 100644 --- a/internal/cmd/testdata/scripts/keepgoing.txtar +++ b/internal/cmd/testdata/scripts/keepgoing.txtar @@ -8,6 +8,7 @@ mkhomedir cmp $HOME/1ok golden/1ok ! exists $HOME/2error ! exists $HOME/3ok +stderr '2error: template: 2error\.tmpl:2: unclosed action started at 2error\.tmpl:1' # test that chezmoi apply with --keep-going writes all files that it can without errors ! exec chezmoi apply --force --keep-going diff --git a/internal/cmd/testdata/scripts/noencryption.txtar b/internal/cmd/testdata/scripts/noencryption.txtar index 8d69cf65a4e..03cc6d5ed3a 100644 --- a/internal/cmd/testdata/scripts/noencryption.txtar +++ b/internal/cmd/testdata/scripts/noencryption.txtar @@ -6,7 +6,7 @@ stderr 'no encryption' # test that chezmoi apply without encryption fails ! exec chezmoi apply --force -stderr 'no encryption' +stderr \.encrypted:\sno\sencryption$ -- home/user/.encrypted -- # contents of .encrypted diff --git a/internal/cmd/testdata/scripts/scriptsdir_unix.txtar b/internal/cmd/testdata/scripts/scriptsdir_unix.txtar index 8b4f1759b92..b83266a2ad4 100644 --- a/internal/cmd/testdata/scripts/scriptsdir_unix.txtar +++ b/internal/cmd/testdata/scripts/scriptsdir_unix.txtar @@ -8,13 +8,13 @@ chhome home2/user # test that chezmoi apply fails if .chezmoiscripts contains a non-script ! exec chezmoi apply -stderr 'not a script' +stderr ${CHEZMOISOURCEDIR@R}/\.chezmoiscripts/dot_file:\snot\sa\sscript$ chhome home3/user # test that chezmoi apply fails if .chezmoiscripts contains duplicate targets ! exec chezmoi apply -stderr 'inconsistent state' +stderr \.chezmoiscripts/script\.sh:\sinconsistent\sstate chhome home4/user
feat
Include name of target in error message
951fc7e4ccc0b12ce5edcfc78b5042fc40fe1713
2021-10-18 02:07:21
Tom Payne
feat: Add default argument to promptString template function
false
diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index 4eae2ae5abd..4676dc2b670 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -122,7 +122,7 @@ Manage your dotfiles across multiple machines, securely. * [`passRaw` *pass-name*](#passraw-pass-name) * [`promptBool` *prompt* [*default*]](#promptbool-prompt-default) * [`promptInt` *prompt* [*default*]](#promptint-prompt-default) - * [`promptString` *prompt*](#promptstring-prompt) + * [`promptString` *prompt* [*default*]](#promptstring-prompt-default) * [`secret` [*arg*...]](#secret-arg) * [`secretJSON` [*arg*...]](#secretjson-arg) * [`stat` *name*](#stat-name) @@ -2380,10 +2380,11 @@ initial config file. --- -### `promptString` *prompt* +### `promptString` *prompt* [*default*] `promptString` prompts the user with *prompt* and returns the user's response -with all leading and trailing spaces stripped. It is only available when +with all leading and trailing spaces stripped. If *default* is passed and the +user's response is empty then it returns *default*. It is only available when generating the initial config file. #### `promptString` examples diff --git a/internal/cmd/executetemplatecmd.go b/internal/cmd/executetemplatecmd.go index fb5c8bc06b4..6de4d82ed13 100644 --- a/internal/cmd/executetemplatecmd.go +++ b/internal/cmd/executetemplatecmd.go @@ -88,11 +88,23 @@ func (c *Config) runExecuteTemplateCmd(cmd *cobra.Command, args []string) error return 0 } }, - "promptString": func(prompt string) string { - if value, ok := c.executeTemplate.promptString[prompt]; ok { - return value + "promptString": func(prompt string, args ...string) string { + switch len(args) { + case 0: + if value, ok := c.executeTemplate.promptString[prompt]; ok { + return value + } + return prompt + case 1: + if value, ok := c.executeTemplate.promptString[prompt]; ok { + return value + } + return args[0] + default: + err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1) + returnTemplateError(err) + return "" } - return prompt }, "stdinIsATTY": func() bool { return c.executeTemplate.stdinIsATTY diff --git a/internal/cmd/inittemplatefuncs.go b/internal/cmd/inittemplatefuncs.go index ced0730b5b2..ead96c99470 100644 --- a/internal/cmd/inittemplatefuncs.go +++ b/internal/cmd/inittemplatefuncs.go @@ -65,13 +65,32 @@ func (c *Config) promptInt(field string, args ...int64) int64 { } } -func (c *Config) promptString(field string) string { - value, err := c.readLine(fmt.Sprintf("%s? ", field)) - if err != nil { +func (c *Config) promptString(prompt string, args ...string) string { + switch len(args) { + case 0: + value, err := c.readLine(prompt + "? ") + if err != nil { + returnTemplateError(err) + return "" + } + return strings.TrimSpace(value) + case 1: + defaultStr := strings.TrimSpace(args[0]) + promptStr := prompt + " (default " + strconv.Quote(defaultStr) + ")? " + switch value, err := c.readLine(promptStr); { + case err != nil: + returnTemplateError(err) + return "" + case value == "": + return defaultStr + default: + return strings.TrimSpace(value) + } + default: + err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1) returnTemplateError(err) return "" } - return strings.TrimSpace(value) } func (c *Config) stdinIsATTY() bool { diff --git a/internal/cmd/inittemplatefuncs_test.go b/internal/cmd/inittemplatefuncs_test.go index 1a573cfb0c9..6064b874e46 100644 --- a/internal/cmd/inittemplatefuncs_test.go +++ b/internal/cmd/inittemplatefuncs_test.go @@ -151,3 +151,80 @@ func TestPromptInt(t *testing.T) { }) } } + +func TestPromptString(t *testing.T) { + for _, tc := range []struct { + name string + prompt string + args []string + stdinStr string + expectedStdoutStr string + expected string + expectedErr bool + }{ + { + name: "response_without_default", + prompt: "string", + stdinStr: "one\n", + expectedStdoutStr: "string? ", + expected: "one", + }, + { + name: "response_with_default", + prompt: "string", + args: []string{"one"}, + stdinStr: "two\n", + expectedStdoutStr: `string (default "one")? `, + expected: "two", + }, + { + name: "response_with_space_with_default", + prompt: "string", + args: []string{"one"}, + stdinStr: " two \n", + expectedStdoutStr: `string (default "one")? `, + expected: "two", + }, + { + name: "no_response_with_default_with_space", + prompt: "string", + args: []string{" one "}, + stdinStr: "\n", + expectedStdoutStr: `string (default "one")? `, + expected: "one", + }, + { + name: "no_response_with_default", + prompt: "string", + args: []string{"one"}, + stdinStr: "\n", + expectedStdoutStr: `string (default "one")? `, + expected: "one", + }, + { + name: "too_many_args", + prompt: "bool", + args: []string{"", ""}, + stdinStr: "\n", + expectedErr: true, + }, + } { + t.Run(tc.name, func(t *testing.T) { + stdin := strings.NewReader(tc.stdinStr) + stdout := &strings.Builder{} + config, err := newConfig( + withStdin(stdin), + withStdout(stdout), + ) + require.NoError(t, err) + if tc.expectedErr { + assert.Panics(t, func() { + config.promptString(tc.prompt, tc.args...) + }) + } else { + assert.Equal(t, tc.expected, config.promptString(tc.prompt, tc.args...)) + assert.Equal(t, tc.expectedStdoutStr, stdout.String()) + } + }) + } +} diff --git a/internal/cmd/testdata/scripts/executetemplate.txt b/internal/cmd/testdata/scripts/executetemplate.txt index 71ea936e683..5e909cebeab 100644 --- a/internal/cmd/testdata/scripts/executetemplate.txt +++ b/internal/cmd/testdata/scripts/executetemplate.txt @@ -64,6 +64,14 @@ stdout 1 chezmoi execute-template --init --promptString [email protected] '{{ promptString "email" }}' stdout '[email protected]' +# test --init --promptString without a default value +chezmoi execute-template --init '{{ promptString "value" }}' +stdout value + +# test --init --promptString with a default value +chezmoi execute-template --init '{{ promptString "value" "default" }}' +stdout default + -- golden/stdin.tmpl -- {{ "stdin-template" }} -- home/user/.config/chezmoi/chezmoi.toml --
feat
Add default argument to promptString template function
23777d09f63695d9051a06d3825d1c3ffebc2c15
2024-10-17 20:43:29
Ruslan Sayfutdinov
docs: Improve description for command arguments
false
diff --git a/assets/chezmoi.io/docs/reference/command-line-flags/common.md b/assets/chezmoi.io/docs/reference/command-line-flags/common.md index b12058d72be..526e6729605 100644 --- a/assets/chezmoi.io/docs/reference/command-line-flags/common.md +++ b/assets/chezmoi.io/docs/reference/command-line-flags/common.md @@ -6,10 +6,21 @@ The following flags apply to multiple commands where they are relevant. Set the output format. +## `-h`, `--help` + +Print help. + ## `-i`, `--include` *types* -Include target state entries of type *types*. *types* is a comma-separated list -of types: +Include target state entries of type *types*. + +!!! example + + `--include=files` specifies all files. + +### Available types + +*types* is a comma-separated list of types: | Type | Description | | ----------- | --------------------------- | @@ -29,19 +40,11 @@ Types can be preceded with `no` to remove them. Types can be explicitly excluded with the `--exclude` flag. -!!! example - - `--include=files` specifies all files. - ## `--init` Regenerate and reread the config file from the config file template before computing the target state. -## `--interactive` - -Prompt before applying each target. - ## `-o`, `--output` *filename* Write the output to *filename* instead of stdout. @@ -54,11 +57,6 @@ Also perform command on all parent directories of *target*. Recurse into subdirectories, `true` by default. -## `--source-path` - -Interpret *targets* passed to the command as paths in the source directory -rather than the destination directory. - ## `--tree` Print paths as a tree instead of a list. @@ -70,8 +68,7 @@ is set. ## `-x`, `--exclude` *types* -Exclude target state entries of type *types*. *types* is defined as in the -`--include` flag and defaults to `none`. +Exclude target state entries of type [*types*](#available-types). Defaults to `none`. !!! example diff --git a/assets/chezmoi.io/docs/reference/command-line-flags/global.md b/assets/chezmoi.io/docs/reference/command-line-flags/global.md index 31c7a348a1d..0ad6d373df2 100644 --- a/assets/chezmoi.io/docs/reference/command-line-flags/global.md +++ b/assets/chezmoi.io/docs/reference/command-line-flags/global.md @@ -40,14 +40,18 @@ changes that would be made without making them. Make changes without prompting. -## `-h`, `--help` +## `--interactive` -Print help. +Prompt before applying each target. ## `-k`, `--keep-going` Keep going as far as possible after a encountering an error. +## `--mode` `file`|`symlink` + +Mode of operation. The default is `file`. + ## `--no-pager` Do not use the pager. @@ -90,6 +94,11 @@ if no cached external is available. Use *directory* as the source directory. +## `--source-path` + +Interpret *targets* passed to the command as paths in the source directory +rather than the destination directory. + ## `--use-builtin-age` *value* > Configuration: `useBuiltinAge` diff --git a/assets/chezmoi.io/docs/reference/commands/add.md b/assets/chezmoi.io/docs/reference/commands/add.md index be8b2b7c501..ed0317d6ef4 100644 --- a/assets/chezmoi.io/docs/reference/commands/add.md +++ b/assets/chezmoi.io/docs/reference/commands/add.md @@ -17,12 +17,24 @@ This implies the `--template` option. templates with unwanted variable substitutions. Carefully review any templates it generates. +## `--create` + +Add files that should exist, irrespective of their contents. + ## `--encrypt` > Configuration: `add.encrypt` Encrypt files using the defined encryption method. +## `--exact` + +Set the `exact` attribute on added directories. + +## `-x`, `--exclude` *types* + +Exclude entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `none`. + ## `-f`, `--force` Add *target*s, even if doing so would cause a source template to be @@ -33,13 +45,9 @@ overwritten. If the last part of a target is a symlink, add the target of the symlink instead of the symlink itself. -## `--exact` - -Set the `exact` attribute on added directories. - ## `-i`, `--include` *types* -Only add entries of type *types*. +Only add entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `all`. ## `-p`, `--prompt` @@ -51,7 +59,7 @@ Suppress warnings about adding ignored entries. ## `-r`, `--recursive` -Recursively add all files, directories, and symlinks. +Recursively add all files, directories, and symlinks, `true` by default. Can be disabled with `--recursive=false`. ## `-s`, `--secrets` `ignore`|`warning`|`error` diff --git a/assets/chezmoi.io/docs/reference/commands/age.md b/assets/chezmoi.io/docs/reference/commands/age.md index 9416a043484..5db360f9d83 100644 --- a/assets/chezmoi.io/docs/reference/commands/age.md +++ b/assets/chezmoi.io/docs/reference/commands/age.md @@ -2,13 +2,17 @@ Interact with age's passphrase-based encryption. -!!! hint +# `age encrypt` [*file*...] - To get a full list of subcommands run: +## `-p`, `--passphrase` - ```console - $ chezmoi age help - ``` +Encrypt with a passphrase. + +# `age decrypt` [*file*...] + +## `-p`, `--passphrase` + +Decrypt with a passphrase. !!! example diff --git a/assets/chezmoi.io/docs/reference/commands/apply.md b/assets/chezmoi.io/docs/reference/commands/apply.md index 553320796d1..6fda4fbbe24 100644 --- a/assets/chezmoi.io/docs/reference/commands/apply.md +++ b/assets/chezmoi.io/docs/reference/commands/apply.md @@ -5,9 +5,21 @@ no targets are specified, the state of all targets are ensured. If a target has been modified since chezmoi last wrote it then the user will be prompted if they want to overwrite the file. +## `-x`, `--exclude` *types* + +Exclude entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `none`. + ## `-i`, `--include` *types* -Only add entries of type *types*. +Only add entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `all`. + +## `--init` + +Recreate config file from template. + +## `-r`, `--recursive` + +Recurse into subdirectories, `true` by default. Can be disabled with `--recursive=false`. ## `--source-path` diff --git a/assets/chezmoi.io/docs/reference/commands/archive.md b/assets/chezmoi.io/docs/reference/commands/archive.md index 841a1fb7971..99495332a52 100644 --- a/assets/chezmoi.io/docs/reference/commands/archive.md +++ b/assets/chezmoi.io/docs/reference/commands/archive.md @@ -3,20 +3,44 @@ Generate an archive of the target state, or only the targets specified. This can be piped into `tar` to inspect the target state. -## `-f`, `--format` `tar`|`tar.gz`|`tgz`|`zip` +## `-x`, `--exclude` *types* + +Exclude entries of type [*types*](../command-line-flags/common.md#-i-include-types), defaults to `none`. + +## `-f`, `--format` *format* Write the archive in *format*. If `--output` is set the format is guessed from the extension, otherwise the default is `tar`. +| Supported formats | +| ----------------- | +| `tar` | +| `tar.bz2` | +| `tar.gz` | +| `tar.xz` | +| `tar.zst` | +| `tbz2` | +| `tgz` | +| `txz` | +| `zip` | + ## `-i`, `--include` *types* -Only include entries of type *types*. +Only add entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `all`. + +## `--init` + +Recreate config file from template. ## `-z`, `--gzip` Compress the archive with gzip. This is automatically set if the format is `tar.gz` or `tgz` and is ignored if the format is `zip`. +## `-r`, `--recursive` + +Recurse into subdirectories, `true` by default. Can be disabled with `--recursive=false`. + !!! example ```console diff --git a/assets/chezmoi.io/docs/reference/commands/chattr.md b/assets/chezmoi.io/docs/reference/commands/chattr.md index 3124522a17f..ea81a3e789d 100644 --- a/assets/chezmoi.io/docs/reference/commands/chattr.md +++ b/assets/chezmoi.io/docs/reference/commands/chattr.md @@ -39,6 +39,10 @@ Multiple modifications may be specified by separating them with a comma (`,`). If you use the `-`*modifier* form then you must put *modifier* after a `--` to prevent chezmoi from interpreting `-`*modifier* as an option. +## `-r`, `--recursive` + +Recurse into subdirectories. + !!! example ```console diff --git a/assets/chezmoi.io/docs/reference/commands/data.md b/assets/chezmoi.io/docs/reference/commands/data.md index d04ea63cca3..8ec4406dde3 100644 --- a/assets/chezmoi.io/docs/reference/commands/data.md +++ b/assets/chezmoi.io/docs/reference/commands/data.md @@ -4,7 +4,7 @@ Write the computed template data to stdout. ## `-f`, `--format` `json`|`yaml` -Set the output format. +Set the output format, `json` by default. !!! example diff --git a/assets/chezmoi.io/docs/reference/commands/destroy.md b/assets/chezmoi.io/docs/reference/commands/destroy.md index 6b5927e0452..9a3ccbea994 100644 --- a/assets/chezmoi.io/docs/reference/commands/destroy.md +++ b/assets/chezmoi.io/docs/reference/commands/destroy.md @@ -15,3 +15,7 @@ Remove *target* from the source state, the destination directory, and the state. ## `-f`, `--force` Destroy without prompting. + +## `-r`, `--recursive` + +Recurse into subdirectories. diff --git a/assets/chezmoi.io/docs/reference/commands/diff.md b/assets/chezmoi.io/docs/reference/commands/diff.md index 63cf7322635..49c0544ab43 100644 --- a/assets/chezmoi.io/docs/reference/commands/diff.md +++ b/assets/chezmoi.io/docs/reference/commands/diff.md @@ -15,12 +15,17 @@ respectively. The default value of `diff.args` is template arguments then `{{ .Destination }}` and `{{ .Target }}` will be appended automatically. -## `--reverse` +## `-x`, `--exclude` *types* -> Configuration: `diff.reverse` +Exclude entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `none`. -Reverse the direction of the diff, i.e. show the changes to the target required -to match the destination. +## `-i`, `--include` *types* + +Only add entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `all`. + +## `--init` + +Recreate config file from template. ## `--pager` *pager* @@ -28,6 +33,21 @@ to match the destination. Pager to use for output. +## `-r`, `--recursive` + +Recurse into subdirectories. + +## `--reverse` + +> Configuration: `diff.reverse` + +Reverse the direction of the diff, i.e. show the changes to the target required +to match the destination. + +## `--script-contents` + +Show script contents, defaults to `true`. + !!! example ```console diff --git a/assets/chezmoi.io/docs/reference/commands/dump-config.md b/assets/chezmoi.io/docs/reference/commands/dump-config.md index 89a3fbe09ce..06cf445b5a3 100644 --- a/assets/chezmoi.io/docs/reference/commands/dump-config.md +++ b/assets/chezmoi.io/docs/reference/commands/dump-config.md @@ -2,6 +2,10 @@ Dump the configuration. +## `-f`, `--format` `json`|`yaml` + +Set the output format, `json` by default. + !!! example ```console diff --git a/assets/chezmoi.io/docs/reference/commands/dump.md b/assets/chezmoi.io/docs/reference/commands/dump.md index c62b65e6f70..780668bf481 100644 --- a/assets/chezmoi.io/docs/reference/commands/dump.md +++ b/assets/chezmoi.io/docs/reference/commands/dump.md @@ -3,13 +3,25 @@ Dump the target state of *target*s. If no targets are specified, then the entire target state. +## `-x`, `--exclude` *types* + +Exclude entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `none`. + ## `-f`, `--format` `json`|`yaml` -Set the output format. +Set the output format, default to `json`. ## `-i`, `--include` *types* -Only include entries of type *types*. +Only add entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `all`. + +## `--init` + +Recreate config file from template. + +## `-r`, `--recursive` + +Recurse into subdirectories, `true` by default. Can be disabled with `--recursive=false`. !!! example diff --git a/assets/chezmoi.io/docs/reference/commands/edit.md b/assets/chezmoi.io/docs/reference/commands/edit.md index 0627dab3a50..bf0a0289901 100644 --- a/assets/chezmoi.io/docs/reference/commands/edit.md +++ b/assets/chezmoi.io/docs/reference/commands/edit.md @@ -18,6 +18,10 @@ editor with filenames which match the target filename, unless the Apply target immediately after editing. Ignored if there are no targets. +## `-x`, `--exclude` *types* + +Exclude entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `none`. + ## `--hardlink` *bool* > Configuration: `edit.hardlink` @@ -26,6 +30,14 @@ Invoke the editor with a hard link to the source file with a name matching the target filename. This can help the editor determine the type of the file correctly. This is the default. +## `-i`, `--include` *types* + +Only add entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `all`. + +## `--init` + +Recreate config file from template. + ## `--watch` > Configuration: `edit.watch` diff --git a/assets/chezmoi.io/docs/reference/commands/ignored.md b/assets/chezmoi.io/docs/reference/commands/ignored.md index d967b033ed9..fd1acacb881 100644 --- a/assets/chezmoi.io/docs/reference/commands/ignored.md +++ b/assets/chezmoi.io/docs/reference/commands/ignored.md @@ -2,6 +2,10 @@ Print the list of entries ignored by chezmoi. +## `-t`, `--tree` + +Print paths as a tree. + !!! example ```console diff --git a/assets/chezmoi.io/docs/reference/commands/import.md b/assets/chezmoi.io/docs/reference/commands/import.md index 4c4dd4ab640..9800fe96c03 100644 --- a/assets/chezmoi.io/docs/reference/commands/import.md +++ b/assets/chezmoi.io/docs/reference/commands/import.md @@ -16,6 +16,14 @@ Set the destination (in the source state) where the archive will be imported. Set the `exact` attribute on all imported directories. +## `-x`, `--exclude` *types* + +Exclude entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `none`. + +## `-i`, `--include` *types* + +Only add entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `all`. + ## `-r`, `--remove-destination` Remove destination (in the source state) before importing. diff --git a/assets/chezmoi.io/docs/reference/commands/init.md b/assets/chezmoi.io/docs/reference/commands/init.md index c73574b5473..93480730a98 100644 --- a/assets/chezmoi.io/docs/reference/commands/init.md +++ b/assets/chezmoi.io/docs/reference/commands/init.md @@ -55,6 +55,25 @@ existing template data. Clone the repo with depth *depth*. +## `-x`, `--exclude` *types* + +Exclude entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `none`. + +## `--guess-repo-url` *bool* + +Guess the repo URL from the *repo* argument. This defaults to `true`. + +## `-i`, `--include` *types* + +Only add entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `all`. + +## `--one-shot` + +`--one-shot` is the equivalent of `--apply`, `--depth=1`, `--force`, `--purge`, +and `--purge-binary`. It attempts to install your dotfiles with chezmoi and +then remove all traces of chezmoi from the system. This is useful for setting +up temporary environments (e.g. Docker containers). + ## `--prompt` Force the `prompt*Once` template functions to prompt. @@ -92,17 +111,6 @@ a comma-separated list of *prompt*`=`*value* pairs. If `promptString` is called with a *prompt* that does not match any of *pairs*, then it prompts the user for a value. -## `--guess-repo-url` *bool* - -Guess the repo URL from the *repo* argument. This defaults to `true`. - -## `--one-shot` - -`--one-shot` is the equivalent of `--apply`, `--depth=1`, `--force`, `--purge`, -and `--purge-binary`. It attempts to install your dotfiles with chezmoi and -then remove all traces of chezmoi from the system. This is useful for setting -up temporary environments (e.g. Docker containers). - ## `--purge` Remove the source and config directories after applying. diff --git a/assets/chezmoi.io/docs/reference/commands/managed.md b/assets/chezmoi.io/docs/reference/commands/managed.md index 65463f01dc2..212e59e421e 100644 --- a/assets/chezmoi.io/docs/reference/commands/managed.md +++ b/assets/chezmoi.io/docs/reference/commands/managed.md @@ -4,11 +4,23 @@ List all managed entries in the destination directory under all *path*s in alphabetical order. When no *path*s are supplied, list all managed entries in the destination directory in alphabetical order. +## `-x`, `--exclude` *types* + +Exclude entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `none`. + +## `-i`, `--include` *types* + +Only add entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `all`. + ## `-p`, `--path-style` `absolute`|`relative`|`source-absolute`|`source-relative` Print paths in the given style. Relative paths are relative to the destination directory. The default is `relative`. +## `-t`, `--tree` + +Print paths as a tree. + !!! example ```console diff --git a/assets/chezmoi.io/docs/reference/commands/merge-all.md b/assets/chezmoi.io/docs/reference/commands/merge-all.md index 7ddc6205ad8..e5b23e6bdd2 100644 --- a/assets/chezmoi.io/docs/reference/commands/merge-all.md +++ b/assets/chezmoi.io/docs/reference/commands/merge-all.md @@ -3,6 +3,14 @@ Perform a three-way merge for file whose actual state does not match its target state. The merge is performed with `chezmoi merge`. +## `--init` + +Recreate config file from template. + +## `-r`, `--recursive` + +Recurse into subdirectories, `true` by default. Can be disabled with `--recursive=false`. + !!! example ```console diff --git a/assets/chezmoi.io/docs/reference/commands/purge.md b/assets/chezmoi.io/docs/reference/commands/purge.md index a1b7582314a..e4dbf6254df 100644 --- a/assets/chezmoi.io/docs/reference/commands/purge.md +++ b/assets/chezmoi.io/docs/reference/commands/purge.md @@ -3,6 +3,10 @@ Remove chezmoi's configuration, state, and source directory, but leave the target state intact. +## `-P`, `--binary` + +Purge chezmoi binary. + ## `-f`, `--force` Remove without prompting. diff --git a/assets/chezmoi.io/docs/reference/commands/re-add.md b/assets/chezmoi.io/docs/reference/commands/re-add.md index 5d35ac97b93..bdc60d16ff2 100644 --- a/assets/chezmoi.io/docs/reference/commands/re-add.md +++ b/assets/chezmoi.io/docs/reference/commands/re-add.md @@ -7,9 +7,17 @@ files are ignored. Directories are recursed into by default. If no *target*s are specified then all modified files are re-added. If one or more *target*s are given then only those targets are re-added. +## `-x`, `--exclude` *types* + +Exclude entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `none`. + +## `-i`, `--include` *types* + +Only add entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `all`. + ## `-r`, `--recursive` -Recursively add files in subdirectories. +Recursively add files in subdirectories, `true` by default. Can be disabled with `--recursive=false`. !!! hint diff --git a/assets/chezmoi.io/docs/reference/commands/secret.md b/assets/chezmoi.io/docs/reference/commands/secret.md index 9753287f6bc..3eec0c0fd24 100644 --- a/assets/chezmoi.io/docs/reference/commands/secret.md +++ b/assets/chezmoi.io/docs/reference/commands/secret.md @@ -9,13 +9,39 @@ manager. Normally you would use chezmoi's existing template functions to retriev If you need to pass flags to the secret manager's CLI you must separate them with `--` to prevent chezmoi from interpreting them. -!!! hint +# `secret keyring delete` - To get a full list of subcommands run: +## `--service` *string* - ```console - $ chezmoi secret help - ``` +Name of the service. + +## `--user` *string* + +Name of the user. + +# `secret keyring get` + +## `--service` *string* + +Name of the service. + +## `--user` *string* + +Name of the user. + +# `secret keyring set` + +## `--service` *string* + +Name of the service. + +## `--user` *string* + +Name of the user. + +## `--value` *string* + +New value. !!! example diff --git a/assets/chezmoi.io/docs/reference/commands/state.md b/assets/chezmoi.io/docs/reference/commands/state.md index da61bba7ffc..70e3c4edf86 100644 --- a/assets/chezmoi.io/docs/reference/commands/state.md +++ b/assets/chezmoi.io/docs/reference/commands/state.md @@ -10,6 +10,40 @@ Manipulate the persistent state. $ chezmoi state help ``` +# Available subcommands + +## `data` + +Print the raw data in the persistent state. + +## `delete` + +Delete a value from the persistent state. + +## `delete-bucket` + +Delete a bucket from the persistent state. + +## `dump` + +Generate a dump of the persistent state. + +## `get` + +Get a value from the persistent state. + +## `get-bucket` + +Get a bucket from the persistent state. + +## `reset` + +Reset the persistent state. + +## `set` + +Set a value from the persistent state + !!! example ```console diff --git a/assets/chezmoi.io/docs/reference/commands/status.md b/assets/chezmoi.io/docs/reference/commands/status.md index 5d9bb8ddf1e..23ff9fa171c 100644 --- a/assets/chezmoi.io/docs/reference/commands/status.md +++ b/assets/chezmoi.io/docs/reference/commands/status.md @@ -16,9 +16,26 @@ running [`chezmoi apply`](apply.md) will have. | `M` | Modified | Entry was modified | Entry will be modified | | `R` | Run | Not applicable | Script will be run | +## `-x`, `--exclude` *types* + +Exclude entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `none`. + ## `-i`, `--include` *types* -Only include entries of type *types*. +Only add entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `all`. + +## `--init` + +Recreate config file from template. + +## `-p`, `--path-style` `absolute`|`relative`|`source-absolute`|`source-relative` + +Print paths in the given style. Relative paths are relative to the destination +directory. The default is `relative`. + +## `-r`, `--recursive` + +Recurse into subdirectories, `true` by default. Can be disabled with `--recursive=false`. !!! example diff --git a/assets/chezmoi.io/docs/reference/commands/unmanaged.md b/assets/chezmoi.io/docs/reference/commands/unmanaged.md index 5c711644bf7..b9cb65fb67c 100644 --- a/assets/chezmoi.io/docs/reference/commands/unmanaged.md +++ b/assets/chezmoi.io/docs/reference/commands/unmanaged.md @@ -5,11 +5,15 @@ unmanaged files in the destination directory. It is an error to supply *path*s that are not found on the filesystem. -## `-p`, `--path-style` `absolute`|`relative` +## `-p`, `--path-style` `absolute`|`relative`|`source-absolute`|`source-relative` Print paths in the given style. Relative paths are relative to the destination directory. The default is `relative`. +## `-t`, `--tree` + +Print paths as a tree. + !!! example ```console diff --git a/assets/chezmoi.io/docs/reference/commands/update.md b/assets/chezmoi.io/docs/reference/commands/update.md index 7d53974e7ed..ee40346c585 100644 --- a/assets/chezmoi.io/docs/reference/commands/update.md +++ b/assets/chezmoi.io/docs/reference/commands/update.md @@ -7,13 +7,29 @@ If `update.command` is set then chezmoi will run `update.command` with --autostash --rebase [--recurse-submodules]` , using chezmoi's builtin git if `useBuiltinGit` is `true` or if `git.command` cannot be found in `$PATH`. +## `--apply` + +Apply changes after pulling, `true` by default. Can be disabled with `--apply=false`. + +## `-x`, `--exclude` *types* + +Exclude entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `none`. + ## `-i`, `--include` *types* -Only update entries of type *types*. +Only add entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `all`. + +## `--init` + +Recreate config file from template. + +## `--recurse-submodules` + +Update submodules recursively. This defaults to `true`. Can be disabled with `--recurse-submodules=false`. -## `--recurse-submodules` *bool* +## `-r`, `--recursive` -Update submodules recursively. This defaults to `true`. +Recurse into subdirectories, `true` by default. Can be disabled with `--recursive=false`. !!! example diff --git a/assets/chezmoi.io/docs/reference/commands/upgrade.md b/assets/chezmoi.io/docs/reference/commands/upgrade.md index 99a39e44d84..b8b5f11ae53 100644 --- a/assets/chezmoi.io/docs/reference/commands/upgrade.md +++ b/assets/chezmoi.io/docs/reference/commands/upgrade.md @@ -16,3 +16,19 @@ requests should be sufficient for most cases. If you installed chezmoi using a package manager, the `upgrade` command might have been removed by the package maintainer. + +## `--executable` *filename* + +Set name of executable to replace. + +## `--method` *method* + +Set upgrade method. + +| Methods | Description | +| ---------------------- | ---------------------------------------------------------------------------------- | +| `brew-upgrade` | Run `brew upgrade chezmoi`. | +| `replace-executable` | Download the latest released executable from Github. | +| `snap-refresh` | Run `snap refresh chezmoi`. | +| `sudo-upgrade-package` | Same as `upgrade-package` but use `sudo`. | +| `upgrade-package` | Download and install `.apk`, `.deb` or `.rpm` package. Run `pacman` on Arch Linux. | diff --git a/assets/chezmoi.io/docs/reference/commands/verify.md b/assets/chezmoi.io/docs/reference/commands/verify.md index 29693626308..63b7dddf72b 100644 --- a/assets/chezmoi.io/docs/reference/commands/verify.md +++ b/assets/chezmoi.io/docs/reference/commands/verify.md @@ -4,9 +4,21 @@ Verify that all *target*s match their target state. chezmoi exits with code 0 (success) if all targets match their target state, or 1 (failure) otherwise. If no targets are specified then all targets are checked. +## `-x`, `--exclude` *types* + +Exclude entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `none`. + ## `-i`, `--include` *types* -Only include entries of type *types*. +Only add entries of type [*types*](../command-line-flags/common.md#available-types), defaults to `all`. + +## `--init` + +Recreate config file from template. + +## `-r`, `--recursive` + +Recurse into subdirectories, `true` by default. Can be disabled with `--recursive=false`. !!! example diff --git a/internal/chezmoi/mode.go b/internal/chezmoi/mode.go index 98866178873..9ecda625a46 100644 --- a/internal/chezmoi/mode.go +++ b/internal/chezmoi/mode.go @@ -43,5 +43,5 @@ func (m Mode) String() string { // Type implements github.com/spf13/flag.Value.Type. func (m Mode) Type() string { - return "mode" + return "file|symlink" } diff --git a/internal/cmd/diffcmd.go b/internal/cmd/diffcmd.go index 7f2d90ba730..dcc49fc84e2 100644 --- a/internal/cmd/diffcmd.go +++ b/internal/cmd/diffcmd.go @@ -39,7 +39,8 @@ func (c *Config) newDiffCmd() *cobra.Command { diffCmd.Flags().VarP(c.Diff.include, "include", "i", "Include entry types") diffCmd.Flags().BoolVar(&c.Diff.init, "init", c.Diff.init, "Recreate config file from template") diffCmd.Flags().StringVar(&c.Diff.Pager, "pager", c.Diff.Pager, "Set pager") - diffCmd.Flags().BoolVarP(&c.Diff.parentDirs, "parent-dirs", "P", c.apply.parentDirs, "Print the diff of all parent directories") + diffCmd.Flags(). + BoolVarP(&c.Diff.parentDirs, "parent-dirs", "P", c.apply.parentDirs, "Print the diff of all parent directories") diffCmd.Flags().BoolVarP(&c.Diff.recursive, "recursive", "r", c.Diff.recursive, "Recurse into subdirectories") diffCmd.Flags().BoolVar(&c.Diff.Reverse, "reverse", c.Diff.Reverse, "Reverse the direction of the diff") diffCmd.Flags().BoolVar(&c.Diff.ScriptContents, "script-contents", c.Diff.ScriptContents, "Show script contents") diff --git a/internal/cmd/removecmd.go b/internal/cmd/removecmd.go index 6d0b3813bf7..7225c7acfe3 100644 --- a/internal/cmd/removecmd.go +++ b/internal/cmd/removecmd.go @@ -8,7 +8,7 @@ import ( func (c *Config) newRemoveCmd() *cobra.Command { removeCmd := &cobra.Command{ - Deprecated: "remove has been removed, use forget or destroy instead", + Deprecated: "use forget or destroy instead", Use: "remove", Aliases: []string{"rm"}, RunE: c.runRemoveCmd, diff --git a/internal/cmd/statuscmd.go b/internal/cmd/statuscmd.go index 1789c7a4074..84363f5c3d5 100644 --- a/internal/cmd/statuscmd.go +++ b/internal/cmd/statuscmd.go @@ -41,7 +41,8 @@ func (c *Config) newStatusCmd() *cobra.Command { statusCmd.Flags().VarP(c.Status.PathStyle, "path-style", "p", "Path style") statusCmd.Flags().VarP(c.Status.include, "include", "i", "Include entry types") statusCmd.Flags().BoolVar(&c.Status.init, "init", c.Status.init, "Recreate config file from template") - statusCmd.Flags().BoolVarP(&c.Status.parentDirs, "parent-dirs", "P", c.Status.parentDirs, "Show status of all parent directories") + statusCmd.Flags(). + BoolVarP(&c.Status.parentDirs, "parent-dirs", "P", c.Status.parentDirs, "Show status of all parent directories") statusCmd.Flags().BoolVarP(&c.Status.recursive, "recursive", "r", c.Status.recursive, "Recurse into subdirectories") return statusCmd diff --git a/internal/cmd/testdata/scripts/remove.txtar b/internal/cmd/testdata/scripts/remove.txtar index a69485a99bd..9a4a114ac97 100644 --- a/internal/cmd/testdata/scripts/remove.txtar +++ b/internal/cmd/testdata/scripts/remove.txtar @@ -1,7 +1,7 @@ # test that chezmoi remove produces an error ! exec chezmoi remove -stderr 'remove has been removed, use forget or destroy instead' +stderr 'Command "remove" is deprecated, use forget or destroy instead' # test that chezmoi rm produces an error ! exec chezmoi rm -stderr 'remove has been removed, use forget or destroy instead' +stderr 'Command "remove" is deprecated, use forget or destroy instead'
docs
Improve description for command arguments
7086c5cf446dc4eb7931ed6df6369b97a8480ff2
2023-03-08 03:19:13
Tom Payne
feat: Disallow managing chezmoi files with chezmoi
false
diff --git a/pkg/chezmoi/sourcestate.go b/pkg/chezmoi/sourcestate.go index 7cd59322315..ca244e43c8c 100644 --- a/pkg/chezmoi/sourcestate.go +++ b/pkg/chezmoi/sourcestate.go @@ -284,18 +284,19 @@ type ReplaceFunc func(targetRelPath RelPath, newSourceStateEntry, oldSourceState // AddOptions are options to SourceState.Add. type AddOptions struct { - AutoTemplate bool // Automatically create templates, if possible. - Create bool // Add create_ entries instead of normal entries. - Encrypt bool // Encrypt files. - EncryptedSuffix string // Suffix for encrypted files. - Exact bool // Add the exact_ attribute to added directories. - Filter *EntryTypeFilter // Entry type filter. - OnIgnoreFunc func(RelPath) // Function to call when a target is ignored. - PreAddFunc PreAddFunc // Function to be called before a source entry is added. - RemoveDir RelPath // Directory to remove before adding. - ReplaceFunc ReplaceFunc // Function to be called before a source entry is replaced. - Template bool // Add the .tmpl attribute to added files. - TemplateSymlinks bool // Add symlinks with targets in the source or home directories as templates. + AutoTemplate bool // Automatically create templates, if possible. + Create bool // Add create_ entries instead of normal entries. + Encrypt bool // Encrypt files. + EncryptedSuffix string // Suffix for encrypted files. + Exact bool // Add the exact_ attribute to added directories. + Filter *EntryTypeFilter // Entry type filter. + OnIgnoreFunc func(RelPath) // Function to call when a target is ignored. + PreAddFunc PreAddFunc // Function to be called before a source entry is added. + ProtectedAbsPaths []AbsPath // Paths that must not be added. + RemoveDir RelPath // Directory to remove before adding. + ReplaceFunc ReplaceFunc // Function to be called before a source entry is replaced. + Template bool // Add the .tmpl attribute to added files. + TemplateSymlinks bool // Add symlinks with targets in the source or home directories as templates. } // Add adds destAbsPathInfos to s. @@ -303,6 +304,17 @@ func (s *SourceState) Add( sourceSystem System, persistentState PersistentState, destSystem System, destAbsPathInfos map[AbsPath]fs.FileInfo, options *AddOptions, ) error { + for destAbsPath := range destAbsPathInfos { + for _, protectedAbsPath := range options.ProtectedAbsPaths { + if protectedAbsPath.Empty() { + continue + } + if strings.HasPrefix(destAbsPath.String(), protectedAbsPath.String()) { + return fmt.Errorf("%s: cannot add chezmoi file to chezmoi (%s is protected)", destAbsPath, protectedAbsPath) + } + } + } + type sourceUpdate struct { destAbsPath AbsPath entryState *EntryState diff --git a/pkg/cmd/addcmd.go b/pkg/cmd/addcmd.go index bb0d1bbbc21..5c27096d559 100644 --- a/pkg/cmd/addcmd.go +++ b/pkg/cmd/addcmd.go @@ -148,15 +148,27 @@ func (c *Config) runAddCmd(cmd *cobra.Command, args []string, sourceState *chezm return err } + persistentStateFileAbsPath, err := c.persistentStateFile() + if err != nil { + return err + } + return sourceState.Add(c.sourceSystem, c.persistentState, c.destSystem, destAbsPathInfos, &chezmoi.AddOptions{ - AutoTemplate: c.Add.autoTemplate, - Create: c.Add.create, - Encrypt: c.Add.encrypt, - EncryptedSuffix: c.encryption.EncryptedSuffix(), - Exact: c.Add.exact, - Filter: c.Add.filter, - OnIgnoreFunc: c.defaultOnIgnoreFunc, - PreAddFunc: c.defaultPreAddFunc, + AutoTemplate: c.Add.autoTemplate, + Create: c.Add.create, + Encrypt: c.Add.encrypt, + EncryptedSuffix: c.encryption.EncryptedSuffix(), + Exact: c.Add.exact, + Filter: c.Add.filter, + OnIgnoreFunc: c.defaultOnIgnoreFunc, + PreAddFunc: c.defaultPreAddFunc, + ProtectedAbsPaths: []chezmoi.AbsPath{ + c.CacheDirAbsPath, + c.WorkingTreeAbsPath, + c.configFileAbsPath, + persistentStateFileAbsPath, + c.sourceDirAbsPath, + }, ReplaceFunc: c.defaultReplaceFunc, Template: c.Add.template, TemplateSymlinks: c.Add.TemplateSymlinks, diff --git a/pkg/cmd/testdata/scripts/issue1832.txtar b/pkg/cmd/testdata/scripts/issue1832.txtar index 941fa698c78..b94ce7633be 100644 --- a/pkg/cmd/testdata/scripts/issue1832.txtar +++ b/pkg/cmd/testdata/scripts/issue1832.txtar @@ -3,7 +3,7 @@ # test that chezmoi add succeeds when changing the permissions of an intermediate directory exec chezmoi add $HOME/.config/fish/config chmod 700 $HOME/.config -exec chezmoi add --force $HOME/.config +exec chezmoi add --force --recursive=false $HOME/.config -- home/user/.config/fish/config -- # contents of .config/fish/config diff --git a/pkg/cmd/testdata/scripts/issue2820.txtar b/pkg/cmd/testdata/scripts/issue2820.txtar new file mode 100644 index 00000000000..d187dde8521 --- /dev/null +++ b/pkg/cmd/testdata/scripts/issue2820.txtar @@ -0,0 +1,17 @@ +# test that chezmoi add refuses to add files in chezmoi's source directory +! exec chezmoi add $CHEZMOISOURCEDIR +stderr 'cannot add chezmoi file to chezmoi' + +# test that chezmoi add refuses to add files in chezmoi's config directory +! exec chezmoi add $CHEZMOICONFIGDIR +stderr 'cannot add chezmoi file to chezmoi' + +# test that chezmoi add refuses to add files in chezmoi's source directory when already in that directory +cd $CHEZMOISOURCEDIR +exists dot_file +! exec chezmoi add dot_file +stderr 'cannot add chezmoi file to chezmoi' + +-- home/user/.config/chezmoi/chezmoi.toml -- +-- home/user/.local/share/chezmoi/dot_file -- +# contents of .file
feat
Disallow managing chezmoi files with chezmoi
a3de4a83a22bd248f83a7ab5fa15345ce226bada
2024-09-10 04:04:21
Tom Payne
docs: Add FAQ entry on running a script when a git-repo external changes
false
diff --git a/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/usage.md b/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/usage.md index f62aaf49f38..f9e257350db 100644 --- a/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/usage.md +++ b/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/usage.md @@ -150,6 +150,18 @@ results in {{ .Target }} ``` +## How do I run a script when a `git-repo` external changes? + +Use a `run_onchange_after_*.tmpl` script that includes the HEAD commit. For example, +if `~/.emacs.d` is a `git-repo` external, then create: + +``` title="~/.local/share/chezmoi/run_onchange_after_emacs.d.tmpl" +#!/bin/sh + +# {{ output "git" "-C" (joinPath .chezmoi.homeDir ".emacs.d") "rev-parse" "HEAD" }} +echo "~/emacs.d updated" +``` + ## How do I enable shell completions? chezmoi includes shell completions for
docs
Add FAQ entry on running a script when a git-repo external changes
2e4236c71e9e119aaee80fe84caa056c3a569b7c
2024-03-31 23:11:48
Tom Payne
fix: Don't traverse into ignored directories when adding files
false
diff --git a/go.mod b/go.mod index 8d4af66addd..1e4755ef50e 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a github.com/twpayne/go-pinentry/v3 v3.0.1 github.com/twpayne/go-shell v0.4.0 - github.com/twpayne/go-vfs/v5 v5.0.3 + github.com/twpayne/go-vfs/v5 v5.0.4 github.com/twpayne/go-xdg/v6 v6.1.2 github.com/ulikunitz/xz v0.5.11 github.com/zalando/go-keyring v0.2.4 diff --git a/go.sum b/go.sum index a7ff7ad845c..2ed7cb93888 100644 --- a/go.sum +++ b/go.sum @@ -423,8 +423,8 @@ github.com/twpayne/go-shell v0.4.0 h1:RAAMbjEj7mcwDdwC7SiFHGUKR+WDAURU6mnyd3r2p2 github.com/twpayne/go-shell v0.4.0/go.mod h1:MP3aUA0TQ3IGoJc15ahjb+7A7wZH4NeGrvLZ/aFQsHc= github.com/twpayne/go-vfs/v4 v4.3.0 h1:rTqFzzOQ/6ESKTSiwVubHlCBedJDOhQyVSnw8rQNZhU= github.com/twpayne/go-vfs/v4 v4.3.0/go.mod h1:tq2UVhnUepesc0lSnPJH/jQ8HruGhzwZe2r5kDFpEIw= -github.com/twpayne/go-vfs/v5 v5.0.3 h1:9jeacSMvwh8sSLCuS4Ay0QmyAv1ToG1ITeQn6+Zsq1k= -github.com/twpayne/go-vfs/v5 v5.0.3/go.mod h1:zTPFJUbgsEMFNSWnWQlLq9wh4AN83edZzx3VXbxrS1w= +github.com/twpayne/go-vfs/v5 v5.0.4 h1:/ne3h+rW7f5YOyOFguz+3ztfUwzOLR0Vts3y0mMAitg= +github.com/twpayne/go-vfs/v5 v5.0.4/go.mod h1:zTPFJUbgsEMFNSWnWQlLq9wh4AN83edZzx3VXbxrS1w= github.com/twpayne/go-xdg/v6 v6.1.2 h1:KbfCsAP4bBR5+dzfTIh/M9onOPCSqlYsIER79IKwt+s= github.com/twpayne/go-xdg/v6 v6.1.2/go.mod h1:BFHclQaEPLq3jRRYjf1PdFzUEvAfPeLjNymIO/7/7o4= github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= diff --git a/internal/cmd/addcmd.go b/internal/cmd/addcmd.go index 480518416a5..f94028a6f8a 100644 --- a/internal/cmd/addcmd.go +++ b/internal/cmd/addcmd.go @@ -164,8 +164,9 @@ func (c *Config) defaultReplaceFunc( func (c *Config) runAddCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error { destAbsPathInfos, err := c.destAbsPathInfos(sourceState, args, destAbsPathInfosOptions{ - follow: c.Mode == chezmoi.ModeSymlink || c.Add.follow, - recursive: c.Add.recursive, + follow: c.Mode == chezmoi.ModeSymlink || c.Add.follow, + onIgnoreFunc: c.defaultOnIgnoreFunc, + recursive: c.Add.recursive, }) if err != nil { return err diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 9647df26923..96daea78b4f 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -1071,6 +1071,7 @@ func (c *Config) defaultSourceDir(fileSystem vfs.Stater, bds *xdg.BaseDirectoryS type destAbsPathInfosOptions struct { follow bool ignoreNotExist bool + onIgnoreFunc func(chezmoi.RelPath) recursive bool } @@ -1089,9 +1090,14 @@ func (c *Config) destAbsPathInfos( if err != nil { return nil, err } - if _, err := c.targetRelPath(destAbsPath); err != nil { + targetRelPath, err := c.targetRelPath(destAbsPath) + if err != nil { return nil, err } + if sourceState.Ignore(targetRelPath) { + options.onIgnoreFunc(targetRelPath) + continue + } if options.recursive { walkFunc := func(destAbsPath chezmoi.AbsPath, fileInfo fs.FileInfo, err error) error { switch { @@ -1100,12 +1106,26 @@ func (c *Config) destAbsPathInfos( case err != nil: return err } + + targetRelPath, err := c.targetRelPath(destAbsPath) + if err != nil { + return err + } + if sourceState.Ignore(targetRelPath) { + options.onIgnoreFunc(targetRelPath) + if fileInfo.IsDir() { + return fs.SkipDir + } + return nil + } + if options.follow && fileInfo.Mode().Type() == fs.ModeSymlink { fileInfo, err = c.destSystem.Stat(destAbsPath) if err != nil { return err } } + return sourceState.AddDestAbsPathInfos(destAbsPathInfos, c.destSystem, destAbsPath, fileInfo) } if err := chezmoi.Walk(c.destSystem, destAbsPath, walkFunc); err != nil { diff --git a/internal/cmd/mackupcmd_darwin.go b/internal/cmd/mackupcmd_darwin.go index 0e0ed986a82..a3aa708ef16 100644 --- a/internal/cmd/mackupcmd_darwin.go +++ b/internal/cmd/mackupcmd_darwin.go @@ -97,6 +97,7 @@ func (c *Config) runMackupAddCmd(cmd *cobra.Command, args []string, sourceState destAbsPathInfos, err := c.destAbsPathInfos(sourceState, addArgs, destAbsPathInfosOptions{ follow: c.Add.follow, ignoreNotExist: true, + onIgnoreFunc: c.defaultOnIgnoreFunc, recursive: c.Add.recursive, }) if err != nil { diff --git a/internal/cmd/testdata/scripts/add.txtar b/internal/cmd/testdata/scripts/add.txtar index b931ac09d1c..6b8699b2f4a 100644 --- a/internal/cmd/testdata/scripts/add.txtar +++ b/internal/cmd/testdata/scripts/add.txtar @@ -59,7 +59,7 @@ chhome home3/user # test that chezmoi add respects .chezmoiignore exec chezmoi add $HOME${/}.dir exists $CHEZMOISOURCEDIR/dot_dir/file -stderr 'warning: ignoring' +stderr 'warning: ignoring .dir/ignore' ! exists $CHEZMOISOURCEDIR/dot_dir/ignore chhome home4/user diff --git a/internal/cmd/testdata/scripts/issue3630.txtar b/internal/cmd/testdata/scripts/issue3630.txtar new file mode 100644 index 00000000000..5ef9ffa8e1c --- /dev/null +++ b/internal/cmd/testdata/scripts/issue3630.txtar @@ -0,0 +1,14 @@ +# test that chezmoi add does not traverse into ignored directories +chmod 000 $HOME/.dir/private +exec chezmoi add $HOME${/}.dir +stderr 'warning: ignoring .dir/private' +cmp $CHEZMOISOURCEDIR/dot_dir/public/file golden/file + +-- golden/file -- +# contents of .dir/public/file +-- home/user/.dir/private/file -- +# contents of .dir/private/file +-- home/user/.dir/public/file -- +# contents of .dir/public/file +-- home/user/.local/share/chezmoi/.chezmoiignore -- +.dir/private
fix
Don't traverse into ignored directories when adding files
2b6393e005972343a4aba3d57399cf4d83b2bb55
2022-10-31 17:41:58
Tom Payne
chore: Fix template expansion in goreleaser config
false
diff --git a/.goreleaser.yaml b/.goreleaser.yaml index b5d85b591af..6f3682c5757 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -195,7 +195,7 @@ scoop: bucket: owner: twpayne name: scoop-bucket - token: ${{ .Env.SCOOP_GITHUB_TOKEN }} + token: '{{ .Env.SCOOP_GITHUB_TOKEN }}' commit_author: name: Tom Payne email: [email protected]
chore
Fix template expansion in goreleaser config
4748397a0341cd5f6500880ede84fb3b5225d626
2022-11-01 17:39:09
dependabot[bot]
chore(deps): bump golangci/golangci-lint-action from 3.2.0 to 3.3.0
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5a173bbc198..07b962ace16 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -376,7 +376,7 @@ jobs: with: cache: true go-version: ${{ env.GO_VERSION }} - - uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc + - uses: golangci/golangci-lint-action@07db5389c99593f11ad7b44463c2d4233066a9b1 with: version: v${{ env.GOLANGCI_LINT_VERSION }} args: --timeout=5m
chore
bump golangci/golangci-lint-action from 3.2.0 to 3.3.0
6e9281d6fe14d80b2b44beea4593a9a66c91844a
2024-10-24 22:36:55
Ruslan Sayfutdinov
docs: Update shell completions section
false
diff --git a/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/usage.md b/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/usage.md index 1ab99c08f44..3ae25a5bc9e 100644 --- a/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/usage.md +++ b/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/usage.md @@ -188,7 +188,7 @@ Or, approximate the week number with template functions: ``` title="~/.local/share/chezmoi/run_once_weekly.tmpl" #!/bin/sh -# {{ min (ceil (divf now.YearDay 7)) 52 }} +# {{ div now.YearDay 7 }} echo "new week" ``` @@ -196,13 +196,15 @@ echo "new week" chezmoi includes shell completions for [`bash`](https://www.gnu.org/software/bash/), [`fish`](https://fishshell.com/), -[PowerShell](https://learn.microsoft.com/en-us/powershell/), and +[`powershell`](https://learn.microsoft.com/en-us/powershell/), and [`zsh`](https://zsh.sourceforge.io/). If you have installed chezmoi via your -package manager then the shell completion should already be installed. Please -[open an issue](https://github.com/twpayne/chezmoi/issues/new/choose) if this is -not working correctly. - -chezmoi provides a `completion` command and a `completion` template function -which return the shell completions for the given shell. These can be used -either as a one-off or as part of your dotfiles repo. The details of how to use -these depend on your shell. +package manager then the shell completion should already be installed. +For PowerShell, you need to manually add the completion script to your profile. +Please [open an issue](https://github.com/twpayne/chezmoi/issues/new/choose) +if this is not working correctly. + +chezmoi provides a [`completion`](/reference/commands/completion.md) command +and a [`completion`](/reference/templates/functions/completion.md) template +function which return the shell completions for the given shell. +These can be used either as a one-off or as part of your dotfiles repo. +The details of how to use these depend on your shell.
docs
Update shell completions section
c16bea0f2afff02d190c38a69c7501771c5d1427
2022-07-01 13:16:18
dependabot[bot]
chore(deps): bump github.com/stretchr/testify from 1.7.4 to 1.8.0
false
diff --git a/go.mod b/go.mod index 6427803ff3d..ff7dd8de799 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/spf13/afero v1.8.2 github.com/spf13/cobra v1.5.0 github.com/spf13/viper v1.12.0 - github.com/stretchr/testify v1.7.4 + github.com/stretchr/testify v1.8.0 github.com/twpayne/go-pinentry v0.2.0 github.com/twpayne/go-shell v0.3.1 github.com/twpayne/go-vfs/v4 v4.1.0 diff --git a/go.sum b/go.sum index 947cfea1712..19472b44337 100644 --- a/go.sum +++ b/go.sum @@ -525,8 +525,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.7.4 h1:wZRexSlwd7ZXfKINDLsO4r7WBt3gTKONc6K/VesHvHM= -github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t6PwAXzs= github.com/subosito/gotenv v1.4.0 h1:yAzM1+SmVcz5R4tXGsNMu1jUl2aOJXoiWUCEwwnGrvs= github.com/subosito/gotenv v1.4.0/go.mod h1:mZd6rFysKEcUhUHXJk0C/08wAgyDBFuwEYL7vWWGaGo=
chore
bump github.com/stretchr/testify from 1.7.4 to 1.8.0
3bbc07751d6caa2c4525be67cfc935bfa1f7057f
2024-11-08 22:06:20
Ruslan Sayfutdinov
chore: Split test-ubuntu job by umask
false
diff --git a/.github/workflows/clear-pr-caches.yml b/.github/workflows/clear-pr-caches.yml index 5011f9f9790..0e4115ad6a1 100644 --- a/.github/workflows/clear-pr-caches.yml +++ b/.github/workflows/clear-pr-caches.yml @@ -1,3 +1,5 @@ +name: clear-pr-caches + on: pull_request: types: [ closed ] diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cac66dc7934..c3c2edf9d3f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -269,6 +269,12 @@ jobs: name: chezmoi-windows-amd64 path: dist/chezmoi-nocgo_windows_amd64_v1/chezmoi.exe test-ubuntu: + strategy: + fail-fast: false + matrix: + umask: + - "022" + - "002" needs: changes runs-on: ubuntu-20.04 # use older Ubuntu for older glibc permissions: @@ -308,18 +314,12 @@ jobs: - name: run run: | go run . --version - - name: test-umask-022 - if: github.event_name == 'push' || needs.changes.outputs.code == 'true' - env: - CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} - run: | - go test -ldflags="-X github.com/twpayne/chezmoi/v2/internal/chezmoitest.umaskStr=0o022" -race -timeout=1h ./... - - name: test-umask-002 + - name: test-umask-${{ matrix.umask }} if: github.event_name == 'push' || needs.changes.outputs.code == 'true' env: CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} run: | - go test -ldflags="-X github.com/twpayne/chezmoi/v2/internal/chezmoitest.umaskStr=0o002" -race -timeout=1h ./... + go test -ldflags="-X github.com/twpayne/chezmoi/v2/internal/chezmoitest.umaskStr=0o${{ matrix.umask }}" -race -timeout=1h ./... test-website: runs-on: ubuntu-22.04 permissions:
chore
Split test-ubuntu job by umask
5a590a18c2f4820cb7a955107560c63671954c84
2025-02-01 18:27:56
Tom Payne
chore: Update dependencies
false
diff --git a/go.mod b/go.mod index 9851a0b0262..75c8053b4af 100644 --- a/go.mod +++ b/go.mod @@ -10,9 +10,9 @@ require ( github.com/Masterminds/sprig/v3 v3.3.0 github.com/Shopify/ejson v1.5.3 github.com/alecthomas/assert/v2 v2.11.0 - github.com/aws/aws-sdk-go-v2 v1.34.0 - github.com/aws/aws-sdk-go-v2/config v1.29.2 - github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.14 + github.com/aws/aws-sdk-go-v2 v1.36.0 + github.com/aws/aws-sdk-go-v2/config v1.29.4 + github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.16 github.com/bmatcuk/doublestar/v4 v4.8.1 github.com/bradenhilton/mozillainstallhash v1.0.1 github.com/charmbracelet/bubbles v0.20.0 @@ -21,7 +21,7 @@ require ( github.com/coreos/go-semver v0.3.1 github.com/fsnotify/fsnotify v1.8.0 github.com/go-git/go-git/v5 v5.13.2 - github.com/goccy/go-yaml v1.15.15 + github.com/goccy/go-yaml v1.15.16 github.com/google/go-github/v68 v68.0.0 github.com/google/renameio/v2 v2.0.0 github.com/gopasspw/gopass v1.15.15 @@ -37,7 +37,7 @@ require ( github.com/rogpeppe/go-internal v1.13.1 github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 github.com/spf13/cobra v1.8.1 - github.com/spf13/pflag v1.0.5 + github.com/spf13/pflag v1.0.6 github.com/tailscale/hujson v0.0.0-20241010212012-29efb4a0184b github.com/tobischo/gokeepasslib/v3 v3.6.1 github.com/twpayne/go-expect v0.0.2-0.20241130000624-916db2914efd @@ -47,7 +47,7 @@ require ( github.com/twpayne/go-xdg/v6 v6.1.3 github.com/ulikunitz/xz v0.5.12 github.com/zalando/go-keyring v0.2.6 - github.com/zricethezav/gitleaks/v8 v8.23.2 + github.com/zricethezav/gitleaks/v8 v8.23.3 go.etcd.io/bbolt v1.3.11 go.uber.org/automaxprocs v1.6.0 golang.org/x/crypto v0.32.0 @@ -68,7 +68,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.1.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.3.3 // indirect github.com/BobuSumisu/aho-corasick v1.0.3 // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.3.1 // indirect @@ -77,16 +77,16 @@ require ( github.com/alecthomas/chroma/v2 v2.15.0 // indirect github.com/alecthomas/repr v0.4.0 // indirect github.com/atotto/clipboard v0.1.4 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.55 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.25 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.29 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.29 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.17.57 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.27 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.31 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.31 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.8.2 // indirect github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.2 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.10 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.24.12 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.11 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.33.10 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.12 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.24.14 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.13 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.33.12 // indirect github.com/aws/smithy-go v1.22.2 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect @@ -95,12 +95,12 @@ require ( github.com/caspr-io/yamlpath v0.0.0-20200722075116-502e8d113a9b // indirect github.com/charmbracelet/harmonica v0.2.0 // indirect github.com/charmbracelet/lipgloss v1.0.0 // indirect - github.com/charmbracelet/x/ansi v0.7.0 // indirect + github.com/charmbracelet/x/ansi v0.8.0 // indirect github.com/charmbracelet/x/term v0.2.1 // indirect github.com/cloudflare/circl v1.5.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect github.com/creack/pty/v2 v2.0.0-20231209135443-03db72c7b76c // indirect - github.com/cyphar/filepath-securejoin v0.4.0 // indirect + github.com/cyphar/filepath-securejoin v0.4.1 // indirect github.com/danieljoos/wincred v1.2.2 // indirect github.com/dlclark/regexp2 v1.11.4 // indirect github.com/dustin/go-humanize v1.0.1 // indirect @@ -155,7 +155,7 @@ require ( github.com/sagikazarmark/locafero v0.7.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/shopspring/decimal v1.4.0 // indirect - github.com/skeema/knownhosts v1.3.0 // indirect + github.com/skeema/knownhosts v1.3.1 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.12.0 // indirect github.com/spf13/cast v1.7.1 // indirect @@ -174,7 +174,7 @@ require ( github.com/yuin/goldmark-emoji v1.0.4 // indirect go.opentelemetry.io/proto/otlp v1.5.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect + golang.org/x/exp v0.0.0-20250128182459-e0ece0dbea4c // indirect golang.org/x/net v0.34.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/tools v0.29.0 // indirect diff --git a/go.sum b/go.sum index 0381aee4be1..64ee7ec464d 100644 --- a/go.sum +++ b/go.sum @@ -48,8 +48,8 @@ github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.1.0 h1:eXnN9 github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.1.0/go.mod h1:XIpam8wumeZ5rVMuhdDQLMfIPDf1WO3IzrCRO3e3e3o= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= -github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2 h1:kYRSnvJju5gYVyhkij+RTJ/VR6QIUaCfWeaFm2ycsjQ= -github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.3.3 h1:H5xDQaE3XowWfhZRUpnfC+rGZMEVoSiji+b+/HFAPU4= +github.com/AzureAD/microsoft-authentication-library-for-go v1.3.3/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/BobuSumisu/aho-corasick v1.0.3 h1:uuf+JHwU9CHP2Vx+wAy6jcksJThhJS9ehR8a+4nPE9g= github.com/BobuSumisu/aho-corasick v1.0.3/go.mod h1:hm4jLcvZKI2vRF2WDU1N4p/jpWtpOzp3nLmi9AzX/XE= github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= @@ -89,32 +89,32 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= -github.com/aws/aws-sdk-go-v2 v1.34.0 h1:9iyL+cjifckRGEVpRKZP3eIxVlL06Qk1Tk13vreaVQU= -github.com/aws/aws-sdk-go-v2 v1.34.0/go.mod h1:JgstGg0JjWU1KpVJjD5H0y0yyAIpSdKEq556EI6yOOM= -github.com/aws/aws-sdk-go-v2/config v1.29.2 h1:JuIxOEPcSKpMB0J+khMjznG9LIhIBdmqNiEcPclnwqc= -github.com/aws/aws-sdk-go-v2/config v1.29.2/go.mod h1:HktTHregOZwNSM/e7WTfVSu9RCX+3eOv+6ij27PtaYs= -github.com/aws/aws-sdk-go-v2/credentials v1.17.55 h1:CDhKnDEaGkLA5ZszV/qw5uwN5M8rbv9Cl0JRN+PRsaM= -github.com/aws/aws-sdk-go-v2/credentials v1.17.55/go.mod h1:kPD/vj+RB5MREDUky376+zdnjZpR+WgdBBvwrmnlmKE= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.25 h1:kU7tmXNaJ07LsyN3BUgGqAmVmQtq0w6duVIHAKfp0/w= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.25/go.mod h1:OiC8+OiqrURb1wrwmr/UbOVLFSWEGxjinj5C299VQdo= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.29 h1:Ej0Rf3GMv50Qh4G4852j2djtoDb7AzQ7MuQeFHa3D70= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.29/go.mod h1:oeNTC7PwJNoM5AznVr23wxhLnuJv0ZDe5v7w0wqIs9M= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.29 h1:6e8a71X+9GfghragVevC5bZqvATtc3mAMgxpSNbgzF0= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.29/go.mod h1:c4jkZiQ+BWpNqq7VtrxjwISrLrt/VvPq3XiopkUIolI= +github.com/aws/aws-sdk-go-v2 v1.36.0 h1:b1wM5CcE65Ujwn565qcwgtOTT1aT4ADOHHgglKjG7fk= +github.com/aws/aws-sdk-go-v2 v1.36.0/go.mod h1:5PMILGVKiW32oDzjj6RU52yrNrDPUHcbZQYr1sM7qmM= +github.com/aws/aws-sdk-go-v2/config v1.29.4 h1:ObNqKsDYFGr2WxnoXKOhCvTlf3HhwtoGgc+KmZ4H5yg= +github.com/aws/aws-sdk-go-v2/config v1.29.4/go.mod h1:j2/AF7j/qxVmsNIChw1tWfsVKOayJoGRDjg1Tgq7NPk= +github.com/aws/aws-sdk-go-v2/credentials v1.17.57 h1:kFQDsbdBAR3GZsB8xA+51ptEnq9TIj3tS4MuP5b+TcQ= +github.com/aws/aws-sdk-go-v2/credentials v1.17.57/go.mod h1:2kerxPUUbTagAr/kkaHiqvj/bcYHzi2qiJS/ZinllU0= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.27 h1:7lOW8NUwE9UZekS1DYoiPdVAqZ6A+LheHWb+mHbNOq8= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.27/go.mod h1:w1BASFIPOPUae7AgaH4SbjNbfdkxuggLyGfNFTn8ITY= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.31 h1:lWm9ucLSRFiI4dQQafLrEOmEDGry3Swrz0BIRdiHJqQ= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.31/go.mod h1:Huu6GG0YTfbPphQkDSo4dEGmQRTKb9k9G7RdtyQWxuI= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.31 h1:ACxDklUKKXb48+eg5ROZXi1vDgfMyfIA/WyvqHcHI0o= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.31/go.mod h1:yadnfsDwqXeVaohbGc/RaD287PuyRw2wugkh5ZL2J6k= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.2 h1:Pg9URiobXy85kgFev3og2CuOZ8JZUBENF+dcgWBaYNk= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.2/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.2 h1:D4oz8/CzT9bAEYtVhSBmFj2dNOtaHOtMKc2vHBwYizA= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.2/go.mod h1:Za3IHqTQ+yNcRHxu1OFucBh0ACZT4j4VQFF0BqpZcLY= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.10 h1:hN4yJBGswmFTOVYqmbz1GBs9ZMtQe8SrYxPwrkrlRv8= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.10/go.mod h1:TsxON4fEZXyrKY+D+3d2gSTyJkGORexIYab9PTf56DA= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.14 h1:rhT0h8cSV5ZNZWy67Eqe3OQTFGRu9xwgyFsuGeIXmGQ= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.14/go.mod h1:CLEjbx0xH3ptihCb1l0XlrqoGfWD9xU0na47/s7fR/s= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.12 h1:kznaW4f81mNMlREkU9w3jUuJvU5g/KsqDV43ab7Rp6s= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.12/go.mod h1:bZy9r8e0/s0P7BSDHgMLXK2KvdyRRBIQ2blKlvLt0IU= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.11 h1:mUwIpAvILeKFnRx4h1dEgGEFGuV8KJ3pEScZWVFYuZA= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.11/go.mod h1:JDJtD+b8HNVv71axz8+S5492KM8wTzHRFpMKQbPlYxw= -github.com/aws/aws-sdk-go-v2/service/sts v1.33.10 h1:g9d+TOsu3ac7SgmY2dUf1qMgu/uJVTlQ4VCbH6hRxSw= -github.com/aws/aws-sdk-go-v2/service/sts v1.33.10/go.mod h1:WZfNmntu92HO44MVZAubQaz3qCuIdeOdog2sADfU6hU= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.12 h1:O+8vD2rGjfihBewr5bT+QUfYUHIxCVgG61LHoT59shM= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.12/go.mod h1:usVdWJaosa66NMvmCrr08NcWDBRv4E6+YFG2pUdw1Lk= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.16 h1:tIgXdHiHVELZm56dCK7fQ8c4gFMoz6AkhHksrxpmAFQ= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.16/go.mod h1:5WGcD7Mks8G/VNlpHp2ZwfP5pVIZp0zp8nauLU7NuLM= +github.com/aws/aws-sdk-go-v2/service/sso v1.24.14 h1:c5WJ3iHz7rLIgArznb3JCSQT3uUMiz9DLZhIX+1G8ok= +github.com/aws/aws-sdk-go-v2/service/sso v1.24.14/go.mod h1:+JJQTxB6N4niArC14YNtxcQtwEqzS3o9Z32n7q33Rfs= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.13 h1:f1L/JtUkVODD+k1+IiSJUUv8A++2qVr+Xvb3xWXETMU= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.13/go.mod h1:tvqlFoja8/s0o+UruA1Nrezo/df0PzdunMDDurUfg6U= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.12 h1:fqg6c1KVrc3SYWma/egWue5rKI4G2+M4wMQN2JosNAA= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.12/go.mod h1:7Yn+p66q/jt38qMoVfNvjbm3D89mGBnkwDcijgtih8w= github.com/aws/smithy-go v1.22.2 h1:6D9hW43xKFrRx/tXXfAlIZc4JI+yQe6snnWcQyxSyLQ= github.com/aws/smithy-go v1.22.2/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= @@ -153,8 +153,8 @@ github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao= github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg= github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= -github.com/charmbracelet/x/ansi v0.7.0 h1:/QfFmiXOGGwN6fRbzvQaYp7fu1pkxpZ3qFBZWBsP404= -github.com/charmbracelet/x/ansi v0.7.0/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q= +github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE= +github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= @@ -174,8 +174,8 @@ github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= github.com/creack/pty/v2 v2.0.0-20231209135443-03db72c7b76c h1:5l8y/PgjeX1aUyZxXabtAf2ahCYQaqWzlFzQgU16o0U= github.com/creack/pty/v2 v2.0.0-20231209135443-03db72c7b76c/go.mod h1:1gZ4PfMDNcYx8FxDdnF/6HYP327cTeB/ru6UdoWVQvw= -github.com/cyphar/filepath-securejoin v0.4.0 h1:PioTG9TBRSApBpYGnDU8HC+miIsX8vitBH9LGNNMoLQ= -github.com/cyphar/filepath-securejoin v0.4.0/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= +github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s= +github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0= github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -242,8 +242,8 @@ github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7 github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/goccy/go-yaml v1.15.15 h1:5turdzAlutS2Q7/QR/9R99Z1K0J00qDb4T0pHJcZ5ew= -github.com/goccy/go-yaml v1.15.15/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= +github.com/goccy/go-yaml v1.15.16 h1:PMTVcGI9uNPIn7KLs0H7KC1rE+51yPl5YNh4i8rGuRA= +github.com/goccy/go-yaml v1.15.16/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -337,8 +337,6 @@ github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGAR github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4= github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jsimonetti/pwscheme v0.0.0-20220922140336-67a4d090f150 h1:ta6N7DaOQEACq28cLa0iRqXIbchByN9Lfll08CT2GBc= github.com/jsimonetti/pwscheme v0.0.0-20220922140336-67a4d090f150/go.mod h1:SiNTKDgjKQORnazFVHXhpny7UtU0iJOqtxd7R7sCfDI= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -502,8 +500,8 @@ github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+D github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY= -github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M= +github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8= +github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M= github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY= @@ -521,8 +519,9 @@ github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3k github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= +github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -584,8 +583,8 @@ github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8u github.com/zalando/go-keyring v0.2.6/go.mod h1:2TCrxYrbUNYfNS/Kgy/LSrkSQzZ5UPVH85RwfczwvcI= github.com/zeebo/blake3 v0.2.4 h1:KYQPkhpRtcqh0ssGYcKLG1JYvddkEA8QwCM/yBqhaZI= github.com/zeebo/blake3 v0.2.4/go.mod h1:7eeQ6d2iXWRGF6npfaxl2CU+xy2Fjo2gxeyZGCRUjcE= -github.com/zricethezav/gitleaks/v8 v8.23.2 h1:JcR9f7RxFfsVep32PBEFIMTLQaQY0/EjCUII0cLEHfI= -github.com/zricethezav/gitleaks/v8 v8.23.2/go.mod h1:j8lWGw/glcyisjpSfIynRvXjrsJp9AkoY+4bOz95Zak= +github.com/zricethezav/gitleaks/v8 v8.23.3 h1:BPXmKQI35VvRCHWnJ7PTODWnI18wh9KOwatsrOzKHqA= +github.com/zricethezav/gitleaks/v8 v8.23.3/go.mod h1:j8lWGw/glcyisjpSfIynRvXjrsJp9AkoY+4bOz95Zak= go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0= go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I= go.etcd.io/etcd/api/v3 v3.5.12 h1:W4sw5ZoU2Juc9gBWuLk5U6fHfNVyY1WC5g9uiXZio/c= @@ -639,8 +638,8 @@ golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= golang.org/x/crypto/x509roots/fallback v0.0.0-20250118192723-a8ea4be81f07 h1:Tuk3hxOkRoX4Xwph6/tRU1wGumEsVYM2TZfvAC6MllM= golang.org/x/crypto/x509roots/fallback v0.0.0-20250118192723-a8ea4be81f07/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8= -golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0kKxwaAIqN/il7x4voA= -golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU= +golang.org/x/exp v0.0.0-20250128182459-e0ece0dbea4c h1:KL/ZBHXgKGVmuZBZ01Lt57yE5ws8ZPSkkihmEyq7FXc= +golang.org/x/exp v0.0.0-20250128182459-e0ece0dbea4c/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
chore
Update dependencies
d95f2f9e7fed938022e8045fa224af1e222c767f
2021-10-10 00:40:05
Tom Payne
chore: Tidy up purge command code
false
diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 1bd7c8c1e3d..4b08aacbdc2 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -974,70 +974,6 @@ func (c *Config) diffFile(path chezmoi.RelPath, fromData []byte, fromMode fs.Fil return c.pageOutputString(builder.String(), c.Diff.Pager) } -// doPurge is the core purge functionality. It removes all files and directories -// associated with chezmoi. -func (c *Config) doPurge(purgeOptions *purgeOptions) error { - if c.persistentState != nil { - if err := c.persistentState.Close(); err != nil { - return err - } - } - - persistentStateFileAbsPath, err := c.persistentStateFile() - if err != nil { - return err - } - absPaths := []chezmoi.AbsPath{ - c.CacheDirAbsPath, - c.configFileAbsPath.Dir(), - c.configFileAbsPath, - persistentStateFileAbsPath, - c.WorkingTreeAbsPath, - c.SourceDirAbsPath, - } - if purgeOptions != nil && purgeOptions.binary { - executable, err := os.Executable() - // Special case: do not purge the binary if it is a test binary created - // by go test as this would break later tests. - if err == nil && !strings.Contains(executable, "test") { - absPaths = append(absPaths, chezmoi.NewAbsPath(executable)) - } - } - - // Remove all paths that exist. - for _, absPath := range absPaths { - switch _, err := c.destSystem.Stat(absPath); { - case errors.Is(err, fs.ErrNotExist): - continue - case err != nil: - return err - } - - if !c.force { - switch choice, err := c.promptChoice(fmt.Sprintf("Remove %s", absPath), yesNoAllQuit); { - case err != nil: - return err - case choice == "yes": - case choice == "no": - continue - case choice == "all": - c.force = true - case choice == "quit": - return nil - } - } - - switch err := c.destSystem.RemoveAll(absPath); { - case errors.Is(err, fs.ErrPermission): - continue - case err != nil: - return err - } - } - - return nil -} - // editor returns the path to the user's editor and any extra arguments. func (c *Config) editor() (string, []string) { // If the user has set and edit command then use it. diff --git a/internal/cmd/purgecmd.go b/internal/cmd/purgecmd.go index de56b29ff2f..503543fe1a2 100644 --- a/internal/cmd/purgecmd.go +++ b/internal/cmd/purgecmd.go @@ -1,7 +1,15 @@ package cmd import ( + "errors" + "fmt" + "io/fs" + "os" + "strings" + "github.com/spf13/cobra" + + "github.com/twpayne/chezmoi/v2/internal/chezmoi" ) type purgeCmdConfig struct { @@ -33,3 +41,67 @@ func (c *Config) runPurgeCmd(cmd *cobra.Command, args []string) error { binary: c.purge.binary, }) } + +// doPurge is the core purge functionality. It removes all files and directories +// associated with chezmoi. +func (c *Config) doPurge(purgeOptions *purgeOptions) error { + if c.persistentState != nil { + if err := c.persistentState.Close(); err != nil { + return err + } + } + + persistentStateFileAbsPath, err := c.persistentStateFile() + if err != nil { + return err + } + absPaths := []chezmoi.AbsPath{ + c.CacheDirAbsPath, + c.configFileAbsPath.Dir(), + c.configFileAbsPath, + persistentStateFileAbsPath, + c.WorkingTreeAbsPath, + c.SourceDirAbsPath, + } + if purgeOptions != nil && purgeOptions.binary { + executable, err := os.Executable() + // Special case: do not purge the binary if it is a test binary created + // by go test as this would break later tests. + if err == nil && !strings.Contains(executable, "test") { + absPaths = append(absPaths, chezmoi.NewAbsPath(executable)) + } + } + + // Remove all paths that exist. + for _, absPath := range absPaths { + switch _, err := c.destSystem.Stat(absPath); { + case errors.Is(err, fs.ErrNotExist): + continue + case err != nil: + return err + } + + if !c.force { + switch choice, err := c.promptChoice(fmt.Sprintf("Remove %s", absPath), yesNoAllQuit); { + case err != nil: + return err + case choice == "yes": + case choice == "no": + continue + case choice == "all": + c.force = true + case choice == "quit": + return nil + } + } + + switch err := c.destSystem.RemoveAll(absPath); { + case errors.Is(err, fs.ErrPermission): + continue + case err != nil: + return err + } + } + + return nil +}
chore
Tidy up purge command code
d70fd280143ef6d7bba51a5587164bc7681b8256
2024-10-27 01:05:19
Tom Payne
chore: Update GitHub Actions
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5e524e4658f..48d379f0d29 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -284,7 +284,7 @@ jobs: - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed with: go-version: ${{ env.GO_VERSION }} - - uses: astral-sh/setup-uv@f3bcaebff5eace81a1c062af9f9011aae482ca9d + - uses: astral-sh/setup-uv@3b9817b1bf26186f03ab8277bab9b827ea5cc254 with: version: ${{ env.UV_VERSION }} - name: install-website-dependencies @@ -456,7 +456,7 @@ jobs: - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed with: go-version: ${{ env.GO_VERSION }} - - uses: astral-sh/setup-uv@f3bcaebff5eace81a1c062af9f9011aae482ca9d + - uses: astral-sh/setup-uv@3b9817b1bf26186f03ab8277bab9b827ea5cc254 with: version: ${{ env.UV_VERSION }} - name: prepare-chezmoi.io
chore
Update GitHub Actions
44c5670385f8ae3f82f0ba4e1d920a0aea803f8c
2024-09-23 04:10:04
Tom Payne
chore: Update social media links
false
diff --git a/assets/chezmoi.io/docs/links/social-media.md b/assets/chezmoi.io/docs/links/social-media.md index 3cff9b62d1d..b73034d0da7 100644 --- a/assets/chezmoi.io/docs/links/social-media.md +++ b/assets/chezmoi.io/docs/links/social-media.md @@ -5,7 +5,7 @@ | Hacker News | [`chezmoi`](https://hn.algolia.com/?dateRange=all&page=0&prefix=false&query=chezmoi&sort=byDate&type=comment) | | LinkedIn | [`chezmoi dotfiles`](https://www.linkedin.com/search/results/all/?keywords=chezmoi%20dotfiles&origin=GLOBAL_SEARCH_HEADER) | | Reddit | [`chezmoi`](https://www.reddit.com/search/?q=chezmoi&sort=new) | -| Stack Overflow | [`chezmoi`](https://stackoverflow.com/questions/tagged/chezmoi) +| Stack Overflow | [`chezmoi`](https://stackoverflow.com/questions/tagged/chezmoi) | | Twitter | [`chezmoi dotfiles`](https://twitter.com/search?q=chezmoi%20dotfiles&f=live) | | Twitter | [`chezmoi.io`](https://twitter.com/search?q=chezmoi.io&f=live) | -| YouTube | [`chezmoi dotfiles`](https://www.youtube.com/results?search_query=chezmoi+dotfiles) | +| YouTube | [`chezmoi dotfiles`](https://www.youtube.com/results?search_query=%22chezmoi%22+dotfiles) |
chore
Update social media links
c57c263d51fa1a030f0ec67657de40b4311f42b7
2022-06-24 00:39:24
Tom Payne
chore: Fix website deployment
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5fcd5b3d51c..3319d403a86 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -433,6 +433,7 @@ jobs: needs: - release steps: + - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - name: install-website-dependencies run: pip3 install mkdocs-material mkdocs-mermaid2-plugin mkdocs-redirects mkdocs-simple-hooks - name: deploy-website
chore
Fix website deployment
b39d545eda16f7da025a4e26ba02b16f22878693
2023-10-01 13:10:34
dependabot[bot]
chore(deps): bump reviewdog/action-misspell from 1.13.1 to 1.14.0
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 378255fc951..e68f7240c5c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,7 +60,7 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - - uses: reviewdog/action-misspell@9257f108197b44e37995c98bea6ee4a5b9ffc3b0 + - uses: reviewdog/action-misspell@cc799b020b057600b66eedf2b6e97ca26137de21 with: locale: US test-alpine:
chore
bump reviewdog/action-misspell from 1.13.1 to 1.14.0
100905a2291f529629b3159e68eefa2378512700
2024-02-17 06:09:24
Tom Payne
chore: Bump golangci-lint version
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7fe7e0ac7ed..de61f384e68 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ env: FIND_TYPOS_VERSION: 0.0.3 GO_VERSION: 1.22.0 GOFUMPT_VERSION: 0.6.0 - GOLANGCI_LINT_VERSION: 1.56.1 + GOLANGCI_LINT_VERSION: 1.56.2 GOLINES_VERSION: 0.12.2 GOVERSIONINFO_VERSION: 1.4.0 RAGE_VERSION: 0.10.0
chore
Bump golangci-lint version
08e9b0b99efb64797ecdb16bb0c08c89677b68a1
2023-12-21 06:35:07
Tom Payne
docs: Fix guide on clearing state of run_onchange_ scripts
false
diff --git a/assets/chezmoi.io/docs/user-guide/use-scripts-to-perform-actions.md b/assets/chezmoi.io/docs/user-guide/use-scripts-to-perform-actions.md index 348f1eba2ff..2977a51e1af 100644 --- a/assets/chezmoi.io/docs/user-guide/use-scripts-to-perform-actions.md +++ b/assets/chezmoi.io/docs/user-guide/use-scripts-to-perform-actions.md @@ -133,7 +133,15 @@ does not create `dconf.ini` in your home directory. ## Clear the state of all `run_onchange_` and `run_once_` scripts chezmoi stores whether and when `run_onchange_` and `run_once_` scripts have -been run in the `scriptState` bucket of its persistent state. To clear the state, run: +been run in its persistent state. + +To clear the state of `run_onchange_` scripts, run: + +```console +$ chezmoi state delete-bucket --bucket=entryState +``` + +To clear the state of `run_once_` scripts, run: ```console $ chezmoi state delete-bucket --bucket=scriptState diff --git a/internal/cmd/testdata/scripts/issue3421.txtar b/internal/cmd/testdata/scripts/issue3421.txtar new file mode 100644 index 00000000000..a650148bae3 --- /dev/null +++ b/internal/cmd/testdata/scripts/issue3421.txtar @@ -0,0 +1,29 @@ +[windows] skip 'UNIX only' + +# test that chezmoi runs run_once_ and run_onchange_ scripts only once +exec chezmoi apply +stdout once +stdout onchange +exec chezmoi apply +! stdout . + +# test that chezmoi runs run_once_ scripts after chezmoi state delete-bucket --bucket=scriptState +exec chezmoi state delete-bucket --bucket=scriptState +exec chezmoi apply +stdout once +! stdout onchange + +# test that chezmoi runs run_once_ scripts after chezmoi state delete-bucket --bucket=entryState +exec chezmoi state delete-bucket --bucket=entryState +exec chezmoi apply +! stdout once +stdout onchange + +-- home/user/.local/share/chezmoi/run_once_once.sh -- +#!/bin/sh + +echo once +-- home/user/.local/share/chezmoi/run_onchange_onchange.sh -- +#!/bin/sh + +echo onchange
docs
Fix guide on clearing state of run_onchange_ scripts
0a22983b7ae66c12b8a8ecfcfc1cd96d8c238b5e
2023-02-13 23:06:05
Tom Payne
feat: Display progress bars by default when stdout is a TTY
false
diff --git a/assets/chezmoi.io/docs/reference/command-line-flags/global.md b/assets/chezmoi.io/docs/reference/command-line-flags/global.md index 1a9cba5fce6..63d47183ed8 100644 --- a/assets/chezmoi.io/docs/reference/command-line-flags/global.md +++ b/assets/chezmoi.io/docs/reference/command-line-flags/global.md @@ -60,9 +60,10 @@ Read and write the persistent state from *filename*. By default, chezmoi stores its persistent state in `chezmoistate.boltdb` in the same directory as its configuration file. -## `--progress` +## `--progress` *value* -Show progress when downloading externals. +Show progress when downloading externals. *value* can be `on`, `off`, or `auto`. +The default is `auto` which shows progress bars when stdout is a terminal. ## `-R`, `--refresh-externals` [*value*] diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index cb26355a26f..48ad9b8745c 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -91,7 +91,7 @@ type ConfigFile struct { Mode chezmoi.Mode `json:"mode" mapstructure:"mode" yaml:"mode"` Pager string `json:"pager" mapstructure:"pager" yaml:"pager"` PINEntry pinEntryConfig `json:"pinentry" mapstructure:"pinentry" yaml:"pinentry"` - Progress bool `json:"progress" mapstructure:"progress" yaml:"progress"` + Progress autoBool `json:"progress" mapstructure:"progress" yaml:"progress"` Safe bool `json:"safe" mapstructure:"safe" yaml:"safe"` ScriptEnv map[string]string `json:"scriptEnv" mapstructure:"scriptEnv" yaml:"scriptEnv"` ScriptTempDir chezmoi.AbsPath `json:"scriptTempDir" mapstructure:"scriptTempDir" yaml:"scriptTempDir"` //nolint:lll @@ -1373,7 +1373,7 @@ func (c *Config) newRootCmd() (*cobra.Command, error) { persistentFlags.VarP(&c.DestDirAbsPath, "destination", "D", "Set destination directory") persistentFlags.Var(&c.Mode, "mode", "Mode") persistentFlags.Var(&c.persistentStateAbsPath, "persistent-state", "Set persistent state file") - persistentFlags.BoolVar(&c.Progress, "progress", c.Progress, "Display progress bars") + persistentFlags.Var(&c.Progress, "progress", "Display progress bars") persistentFlags.BoolVar(&c.Safe, "safe", c.Safe, "Safely replace files and symlinks") persistentFlags.VarP(&c.SourceDirAbsPath, "source", "S", "Set source directory") persistentFlags.Var(&c.UseBuiltinAge, "use-builtin-age", "Use builtin age") @@ -1945,6 +1945,14 @@ func (c *Config) persistentStateFile() (chezmoi.AbsPath, error) { return defaultConfigFileAbsPath.Dir().Join(persistentStateFileRelPath), nil } +// progressAutoFunc detects whether progress bars should be displayed. +func (c *Config) progressAutoFunc() bool { + if stdout, ok := c.stdout.(*os.File); ok { + return term.IsTerminal(int(stdout.Fd())) + } + return false +} + func (c *Config) newTemplateData() *templateData { // Determine the user's username and group, if possible. // @@ -2379,6 +2387,9 @@ func newConfigFile(bds *xdg.BaseDirectorySpecification) ConfigFile { }, Interpreters: defaultInterpreters, Pager: os.Getenv("PAGER"), + Progress: autoBool{ + auto: true, + }, PINEntry: pinEntryConfig{ Options: pinEntryDefaultOptions, }, diff --git a/pkg/cmd/readhttpresponse.go b/pkg/cmd/readhttpresponse.go index 1e673415785..34aabec4065 100644 --- a/pkg/cmd/readhttpresponse.go +++ b/pkg/cmd/readhttpresponse.go @@ -114,7 +114,7 @@ func (m httpSpinnerModel) View() string { func (c *Config) readHTTPResponse(resp *http.Response) ([]byte, error) { switch { - case c.noTTY || !c.Progress: + case c.noTTY || !c.Progress.Value(c.progressAutoFunc): return io.ReadAll(resp.Body) case resp.ContentLength >= 0:
feat
Display progress bars by default when stdout is a TTY
ec3b443f7fc221b5699c6e8c3005e9dafd554c5e
2022-10-18 02:39:50
dependabot[bot]
chore(deps): bump actions/checkout from 3.0.2 to 3.1.0
false
diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index 94d5ec34dea..a5aa3ec5def 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -6,7 +6,7 @@ jobs: govulncheck: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - name: go-version id: go-version run: | diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ccabcc0163a..a45dfabb2d6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,7 @@ jobs: outputs: code: ${{ steps.filter.outputs.code }} steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - id: filter uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 with: @@ -43,7 +43,7 @@ jobs: permissions: security-events: write steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 1 - uses: github/codeql-action/init@807578363a7869ca324a79039e6db9c843e0e100 @@ -55,7 +55,7 @@ jobs: if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - name: test env: CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} @@ -66,7 +66,7 @@ jobs: if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - name: test env: CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} @@ -77,7 +77,7 @@ jobs: if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: macos-12 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 with: path: ~/.vagrant.d @@ -92,7 +92,7 @@ jobs: if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - name: test env: CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} @@ -103,7 +103,7 @@ jobs: if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: macos-12 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 with: path: ~/.vagrant.d @@ -122,7 +122,7 @@ jobs: if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f with: cache: true @@ -149,7 +149,7 @@ jobs: if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: macos-11 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f with: cache: true @@ -179,7 +179,7 @@ jobs: needs: changes runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f with: cache: true @@ -229,7 +229,7 @@ jobs: needs: changes runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 0 - uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f @@ -275,7 +275,7 @@ jobs: test-website: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - name: install-website-dependencies run: pip3 install mkdocs-material mkdocs-mermaid2-plugin mkdocs-redirects mkdocs-simple-hooks - name: build-website @@ -285,7 +285,7 @@ jobs: if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: windows-2019 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f with: cache: true @@ -325,7 +325,7 @@ jobs: check: runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f with: cache: true @@ -352,7 +352,7 @@ jobs: if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f with: cache: true @@ -389,7 +389,7 @@ jobs: run: snapcraft whoami env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 0 - uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f @@ -421,7 +421,7 @@ jobs: - release runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 0 - name: prepare-chezmoi.io diff --git a/.github/workflows/misspell.yml b/.github/workflows/misspell.yml index 7a7e12bcbe8..bc136c73e2f 100644 --- a/.github/workflows/misspell.yml +++ b/.github/workflows/misspell.yml @@ -13,7 +13,7 @@ jobs: name: spellcheck runs-on: ubuntu-latest steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # pin@v3 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # pin@v3 - name: misspell uses: reviewdog/action-misspell@811b1e15f531430be3a5784e3d591bd657df18b0 # pin@v1 with:
chore
bump actions/checkout from 3.0.2 to 3.1.0
0254d2d4ede01da65a0303512b8ddc254e3add06
2022-01-31 08:28:10
Tom Payne
chore: Move internal commands back into internal directory
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0a1b61b7530..b680f7dd4c5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -466,7 +466,7 @@ jobs: ignore: completions - name: Whitespace run: | - go run ./pkg/cmds/lint-whitespace + go run ./internal/cmds/lint-whitespace - name: Typos run: | go install github.com/twpayne/[email protected] diff --git a/.golangci.yml b/.golangci.yml index 3f6df742b02..86999aaebba 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -121,7 +121,7 @@ issues: - forbidigo - gosec - lll - path: ^pkg/cmds/ + path: ^internal/cmds/ - linters: - gosec - lll diff --git a/Makefile b/Makefile index 5d3960577b4..01cdb897ce4 100644 --- a/Makefile +++ b/Makefile @@ -100,7 +100,7 @@ generate: .PHONY: lint lint: ensure-golangci-lint ./bin/golangci-lint run - ${GO} run ./pkg/cmds/lint-whitespace + ${GO} run ./internal/cmds/lint-whitespace .PHONY: format format: ensure-gofumpt diff --git a/pkg/cmds/generate-install.sh/install.sh.tmpl b/internal/cmds/generate-install.sh/install.sh.tmpl similarity index 100% rename from pkg/cmds/generate-install.sh/install.sh.tmpl rename to internal/cmds/generate-install.sh/install.sh.tmpl diff --git a/pkg/cmds/generate-install.sh/main.go b/internal/cmds/generate-install.sh/main.go similarity index 96% rename from pkg/cmds/generate-install.sh/main.go rename to internal/cmds/generate-install.sh/main.go index 87a8d47b93c..41e932bfa32 100644 --- a/pkg/cmds/generate-install.sh/main.go +++ b/internal/cmds/generate-install.sh/main.go @@ -113,7 +113,7 @@ func run() error { }) // Generate install.sh. - installShTemplate, err := template.ParseFiles("pkg/cmds/generate-install.sh/install.sh.tmpl") + installShTemplate, err := template.ParseFiles("internal/cmds/generate-install.sh/install.sh.tmpl") if err != nil { return err } diff --git a/pkg/cmds/generate-install.sh/main_test.go b/internal/cmds/generate-install.sh/main_test.go similarity index 100% rename from pkg/cmds/generate-install.sh/main_test.go rename to internal/cmds/generate-install.sh/main_test.go diff --git a/pkg/cmds/lint-whitespace/main.go b/internal/cmds/lint-whitespace/main.go similarity index 100% rename from pkg/cmds/lint-whitespace/main.go rename to internal/cmds/lint-whitespace/main.go diff --git a/pkg/cmds/lint-whitespace/main_test.go b/internal/cmds/lint-whitespace/main_test.go similarity index 100% rename from pkg/cmds/lint-whitespace/main_test.go rename to internal/cmds/lint-whitespace/main_test.go diff --git a/main.go b/main.go index 1891fd96987..5220872df02 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ //go:generate go run . completion fish -o completions/chezmoi.fish //go:generate go run . completion powershell -o completions/chezmoi.ps1 //go:generate go run . completion zsh -o completions/chezmoi.zsh -//go:generate go run ./pkg/cmds/generate-install.sh -o assets/scripts/install.sh +//go:generate go run ./internal/cmds/generate-install.sh -o assets/scripts/install.sh package main
chore
Move internal commands back into internal directory
485a10e4edb0bab2eff41d9acd8f6e7063b0976f
2023-01-17 05:02:55
Tom Payne
feat: Check config file format in doctor command
false
diff --git a/pkg/cmd/doctorcmd.go b/pkg/cmd/doctorcmd.go index 3e758eb7738..494af9a5288 100644 --- a/pkg/cmd/doctorcmd.go +++ b/pkg/cmd/doctorcmd.go @@ -490,7 +490,11 @@ func (c *configFileCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsP if filenameAbsPath != c.expected { return checkResultFailed, fmt.Sprintf("found %s, expected %s", filenameAbsPath, c.expected) } - if _, err := system.ReadFile(filenameAbsPath); err != nil { + config, err := newConfig() + if err != nil { + return checkResultError, err.Error() + } + if err := config.decodeConfigFile(filenameAbsPath, &config.ConfigFile); err != nil { return checkResultError, fmt.Sprintf("%s: %v", filenameAbsPath, err) } fileInfo, err := system.Stat(filenameAbsPath) diff --git a/pkg/cmd/testdata/scripts/issue2695.txtar b/pkg/cmd/testdata/scripts/issue2695.txtar new file mode 100644 index 00000000000..a5b59ba7079 --- /dev/null +++ b/pkg/cmd/testdata/scripts/issue2695.txtar @@ -0,0 +1,37 @@ +# test that chezmoi status returns an error when the JSON config file is invalid +! exec chezmoi status +stderr 'invalid config' + +# check that chezmoi doctor warns about invalid JSON config files +! exec chezmoi doctor +stdout 'error\s+config-file\s+.*invalid character' + +chhome home2/user + +# test that chezmoi status returns an error when the TOML config file is invalid +! exec chezmoi status +stderr 'invalid config' + +# check that chezmoi doctor warns about invalid TOML config files +! exec chezmoi doctor +stdout 'error\s+config-file\s+.*incomplete number' + +chhome home3/user + +# test that chezmoi status returns an error when the YAML config file is invalid +! exec chezmoi status +stderr 'invalid config' + +# check that chezmoi doctor warns about invalid YAML config files +! exec chezmoi doctor +stdout 'error\s+config-file\s+.*unmarshal errors' + +-- home/user/.config/chezmoi/chezmoi.json -- +{ + "string": unquoted +} +-- home2/user/.config/chezmoi/chezmoi.toml -- +[example] + string = unquoted +-- home3/user/.config/chezmoi/chezmoi.yaml -- +string
feat
Check config file format in doctor command
7a7ae81afa76bc10ad4e588fa2bc992f5db33f50
2025-01-13 05:35:36
Tom Payne
chore: Update GitHub Actions
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 92dfb4c0196..0ce8f44d9bc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -244,31 +244,31 @@ jobs: args: release --skip=sign --snapshot --timeout=1h - name: upload-artifact-chezmoi-darwin-amd64 if: github.event_name == 'push' || needs.changes.outputs.code == 'true' - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 with: name: chezmoi-darwin-amd64 path: dist/chezmoi-nocgo_darwin_amd64_v1/chezmoi - name: upload-artifact-chezmoi-darwin-arm64 if: github.event_name == 'push' || needs.changes.outputs.code == 'true' - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 with: name: chezmoi-darwin-arm64 path: dist/chezmoi-nocgo_darwin_arm64_v8.0/chezmoi - name: upload-artifact-chezmoi-linux-amd64 if: github.event_name == 'push' || needs.changes.outputs.code == 'true' - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 with: name: chezmoi-linux-amd64 path: dist/chezmoi-cgo-glibc_linux_amd64_v1/chezmoi - name: upload-artifact-chezmoi-linux-musl-amd64 if: github.event_name == 'push' || needs.changes.outputs.code == 'true' - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 with: name: chezmoi-linux-amd64-musl path: dist/chezmoi-cgo-musl_linux_amd64_v1/chezmoi - name: upload-artifact-chezmoi-windows-amd64.exe if: github.event_name == 'push' || needs.changes.outputs.code == 'true' - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 with: name: chezmoi-windows-amd64 path: dist/chezmoi-nocgo_windows_amd64_v1/chezmoi.exe
chore
Update GitHub Actions
2e39ef3127b8a7754fb56eeabda9344484b1990c
2021-09-28 01:02:31
Tom Payne
chore: Fix parsing of git unmerged status lines
false
diff --git a/internal/git/status.go b/internal/git/status.go index 2b1737f7cfb..618d36eee88 100644 --- a/internal/git/status.go +++ b/internal/git/status.go @@ -209,30 +209,34 @@ func ParseStatusPorcelainV2(output []byte) (*Status, error) { if m == nil { return nil, ParseError(text) } - m1, err := strconv.ParseInt(text[m[6]:m[7]], 8, 64) + m1, err := strconv.ParseInt(text[m[8]:m[9]], 8, 64) if err != nil { return nil, err } - m2, err := strconv.ParseInt(text[m[8]:m[9]], 8, 64) + m2, err := strconv.ParseInt(text[m[10]:m[11]], 8, 64) if err != nil { return nil, err } - m3, err := strconv.ParseInt(text[m[10]:m[11]], 8, 64) + m3, err := strconv.ParseInt(text[m[12]:m[13]], 8, 64) if err != nil { return nil, err } - mW, err := strconv.ParseInt(text[m[12]:m[13]], 8, 64) + mW, err := strconv.ParseInt(text[m[14]:m[15]], 8, 64) if err != nil { return nil, err } us := UnmergedStatus{ - X: text[m[2]], - Y: text[m[4]], - Sub: text[m[6]:m[7]], - M1: m1, - M2: m2, - M3: m3, - MW: mW, + X: text[m[2]], + Y: text[m[4]], + Sub: text[m[6]:m[7]], + M1: m1, + M2: m2, + M3: m3, + MW: mW, + H1: text[m[16]:m[17]], + H2: text[m[18]:m[19]], + H3: text[m[20]:m[21]], + Path: text[m[22]:m[23]], } status.Unmerged = append(status.Unmerged, us) case '?': diff --git a/internal/git/status_test.go b/internal/git/status_test.go index 0ddd24692c9..755f01fdbb7 100644 --- a/internal/git/status_test.go +++ b/internal/git/status_test.go @@ -139,6 +139,27 @@ func TestParseStatusPorcelainV2(t *testing.T) { }, }, }, + { + name: "unmerged", + outputStr: "u UU N... 100644 100644 100644 100644 78981922613b2afb6025042ff6bd878ac1994e85 0f7bc766052a5a0ee28a393d51d2370f96d8ceb8 422c2b7ab3b3c668038da977e4e93a5fc623169c README.md\n", + expectedStatus: &Status{ + Unmerged: []UnmergedStatus{ + { + X: 'U', + Y: 'U', + Sub: "N...", + M1: 0o100644, + M2: 0o100644, + M3: 0o100644, + MW: 0o100644, + H1: "78981922613b2afb6025042ff6bd878ac1994e85", + H2: "0f7bc766052a5a0ee28a393d51d2370f96d8ceb8", + H3: "422c2b7ab3b3c668038da977e4e93a5fc623169c", + Path: "README.md", + }, + }, + }, + }, { name: "untracked", outputStr: "? chezmoi.go\n",
chore
Fix parsing of git unmerged status lines
57ee74ada4d93f5c307951190377e02036d870fc
2024-12-10 15:17:41
Ruslan Sayfutdinov
fix: Replace Expand-Archive with System.IO.Compression.ZipFile
false
diff --git a/assets/scripts/install.ps1 b/assets/scripts/install.ps1 index 8928ec83e1a..0596f31905e 100644 --- a/assets/scripts/install.ps1 +++ b/assets/scripts/install.ps1 @@ -191,7 +191,8 @@ function Expand-ChezmoiArchive ($path) { & tar --extract --gzip --file $path --directory $parent } if ($path.EndsWith('.zip')) { - Expand-Archive -Path $path -DestinationPath $parent + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($path, $parent) } }
fix
Replace Expand-Archive with System.IO.Compression.ZipFile
c4017f56a50b9848fd75e3ac4e83b82a7fafc5d8
2023-01-17 13:47:40
jeff
docs: Fix typo in merge user guide
false
diff --git a/assets/chezmoi.io/docs/user-guide/tools/merge.md b/assets/chezmoi.io/docs/user-guide/tools/merge.md index 180f65316dc..0a6212a67b9 100644 --- a/assets/chezmoi.io/docs/user-guide/tools/merge.md +++ b/assets/chezmoi.io/docs/user-guide/tools/merge.md @@ -2,9 +2,9 @@ ## Use a custom merge command -By default, chezmoi uses `vimdiff.` You can use a custom command by setting the +By default, chezmoi uses `vimdiff`. You can use a custom command by setting the `merge.command` and `merge.args` configuration variables. The elements of -`merge.args` are interprested as templates with the variables `.Destination`, +`merge.args` are interpreted as templates with the variables `.Destination`, `.Source`, and `.Target` containing filenames of the file in the destination state, source state, and target state respectively. For example, to use [neovim's diff mode](https://neovim.io/doc/user/diff.html), specify:
docs
Fix typo in merge user guide
703f0de6843e78040ef99c2d75593f460e2beb61
2024-05-25 19:58:05
Tom Payne
chore: Update dependencies
false
diff --git a/go.mod b/go.mod index a3bfc1c4158..0cf8dd2e68c 100644 --- a/go.mod +++ b/go.mod @@ -13,12 +13,12 @@ require ( github.com/Shopify/ejson v1.5.1 github.com/alecthomas/assert/v2 v2.9.0 github.com/aws/aws-sdk-go-v2 v1.27.0 - github.com/aws/aws-sdk-go-v2/config v1.27.15 - github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.28.9 + github.com/aws/aws-sdk-go-v2/config v1.27.16 + github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.29.1 github.com/bmatcuk/doublestar/v4 v4.6.1 github.com/bradenhilton/mozillainstallhash v1.0.1 github.com/charmbracelet/bubbles v0.18.0 - github.com/charmbracelet/bubbletea v0.26.2 + github.com/charmbracelet/bubbletea v0.26.3 github.com/charmbracelet/glamour v0.7.0 github.com/coreos/go-semver v0.3.1 github.com/fsnotify/fsnotify v1.7.0 @@ -68,26 +68,30 @@ require ( github.com/Masterminds/semver/v3 v3.2.1 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/ProtonMail/go-crypto v1.0.0 // indirect - github.com/alecthomas/chroma/v2 v2.13.0 // indirect + github.com/alecthomas/chroma/v2 v2.14.0 // indirect github.com/alecthomas/repr v0.4.0 // indirect github.com/alessio/shellescape v1.4.2 // indirect github.com/atotto/clipboard v0.1.4 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.15 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.17.16 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.3 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.7 // indirect github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.7 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.9 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.20.8 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.2 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.28.9 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.20.9 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.3 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.28.10 // indirect github.com/aws/smithy-go v1.20.2 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/bradenhilton/cityhash v1.0.0 // indirect github.com/charmbracelet/harmonica v0.2.0 // indirect - github.com/charmbracelet/lipgloss v0.10.0 // indirect + github.com/charmbracelet/lipgloss v0.11.0 // indirect + github.com/charmbracelet/x/ansi v0.1.1 // indirect + github.com/charmbracelet/x/input v0.1.1 // indirect + github.com/charmbracelet/x/term v0.1.1 // indirect + github.com/charmbracelet/x/windows v0.1.2 // indirect github.com/cloudflare/circl v1.3.8 // indirect github.com/creack/pty/v2 v2.0.0-20231209135443-03db72c7b76c // indirect github.com/cyphar/filepath-securejoin v0.2.5 // indirect @@ -133,7 +137,7 @@ require ( github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/rs/zerolog v1.32.0 // indirect + github.com/rs/zerolog v1.33.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/shopspring/decimal v1.4.0 // indirect @@ -144,10 +148,11 @@ require ( github.com/spf13/viper v1.18.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/yuin/goldmark v1.7.1 // indirect github.com/yuin/goldmark-emoji v1.0.2 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect + golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d // indirect golang.org/x/net v0.25.0 // indirect golang.org/x/text v0.15.0 // indirect golang.org/x/tools v0.21.0 // indirect diff --git a/go.sum b/go.sum index b60b97c4146..228d9b189c3 100644 --- a/go.sum +++ b/go.sum @@ -46,12 +46,10 @@ github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0k github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/Shopify/ejson v1.5.1 h1:LVphADjSUMao+VPux/2GE5CYVW9U30/XLmStmjKXCQI= github.com/Shopify/ejson v1.5.1/go.mod h1:bVvQ3MaBCfMOkIp1rWZcot3TruYXCc7qUUbI1tjs/YM= -github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= -github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= github.com/alecthomas/assert/v2 v2.9.0 h1:ZcLG8ccMEtlMLkLW4gwGpBWBb0N8MUCmsy1lYBVd1xQ= github.com/alecthomas/assert/v2 v2.9.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/chroma/v2 v2.13.0 h1:VP72+99Fb2zEcYM0MeaWJmV+xQvz5v5cxRHd+ooU1lI= -github.com/alecthomas/chroma/v2 v2.13.0/go.mod h1:BUGjjsD+ndS6eX37YgTchSEG+Jg9Jv1GiZs9sqPqztk= +github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= +github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0= @@ -66,10 +64,10 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aws/aws-sdk-go-v2 v1.27.0 h1:7bZWKoXhzI+mMR/HjdMx8ZCC5+6fY0lS5tr0bbgiLlo= github.com/aws/aws-sdk-go-v2 v1.27.0/go.mod h1:ffIFB97e2yNsv4aTSGkqtHnppsIJzw7G7BReUZ3jCXM= -github.com/aws/aws-sdk-go-v2/config v1.27.15 h1:uNnGLZ+DutuNEkuPh6fwqK7LpEiPmzb7MIMA1mNWEUc= -github.com/aws/aws-sdk-go-v2/config v1.27.15/go.mod h1:7j7Kxx9/7kTmL7z4LlhwQe63MYEE5vkVV6nWg4ZAI8M= -github.com/aws/aws-sdk-go-v2/credentials v1.17.15 h1:YDexlvDRCA8ems2T5IP1xkMtOZ1uLJOCJdTr0igs5zo= -github.com/aws/aws-sdk-go-v2/credentials v1.17.15/go.mod h1:vxHggqW6hFNaeNC0WyXS3VdyjcV0a4KMUY4dKJ96buU= +github.com/aws/aws-sdk-go-v2/config v1.27.16 h1:knpCuH7laFVGYTNd99Ns5t+8PuRjDn4HnnZK48csipM= +github.com/aws/aws-sdk-go-v2/config v1.27.16/go.mod h1:vutqgRhDUktwSge3hrC3nkuirzkJ4E/mLj5GvI0BQas= +github.com/aws/aws-sdk-go-v2/credentials v1.17.16 h1:7d2QxY83uYl0l58ceyiSpxg9bSbStqBC6BeEeHEchwo= +github.com/aws/aws-sdk-go-v2/credentials v1.17.16/go.mod h1:Ae6li/6Yc6eMzysRL2BXlPYvnrLLBg3D11/AmOjw50k= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.3 h1:dQLK4TjtnlRGb0czOht2CevZ5l6RSyRWAnKeGd7VAFE= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.3/go.mod h1:TL79f2P6+8Q7dTsILpiVST+AL9lkF6PPGI167Ny0Cjw= github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.7 h1:lf/8VTF2cM+N4SLzaYJERKEWAXq8MOMpZfU6wEPWsPk= @@ -82,14 +80,14 @@ github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 h1:Ji0DY1x github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2/go.mod h1:5CsjAbs3NlGQyZNFACh+zztPDI7fU6eW9QsxjfnuBKg= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.9 h1:Wx0rlZoEJR7JwlSZcHnEa7CNjrSIyVxMFWGAaXy4fJY= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.9/go.mod h1:aVMHdE0aHO3v+f/iw01fmXV/5DbfQ3Bi9nN7nd9bE9Y= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.28.9 h1:qH8ovDAQkGLgYh/QEEKx/uSDL1vCIuVB2VIZJsVr4dA= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.28.9/go.mod h1:5mMk0DgUgaHlcqtN65fNyZI0ZDX3i9Cw+nwq75HKB3U= -github.com/aws/aws-sdk-go-v2/service/sso v1.20.8 h1:Kv1hwNG6jHC/sxMTe5saMjH6t6ZLkgfvVxyEjfWL1ks= -github.com/aws/aws-sdk-go-v2/service/sso v1.20.8/go.mod h1:c1qtZUWtygI6ZdvKppzCSXsDOq5I4luJPZ0Ud3juFCA= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.2 h1:nWBZ1xHCF+A7vv9sDzJOq4NWIdzFYm0kH7Pr4OjHYsQ= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.2/go.mod h1:9lmoVDVLz/yUZwLaQ676TK02fhCu4+PgRSmMaKR1ozk= -github.com/aws/aws-sdk-go-v2/service/sts v1.28.9 h1:Qp6Boy0cGDloOE3zI6XhNLNZgjNS8YmiFQFHe71SaW0= -github.com/aws/aws-sdk-go-v2/service/sts v1.28.9/go.mod h1:0Aqn1MnEuitqfsCNyKsdKLhDUOr4txD/g19EfiUqgws= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.29.1 h1:NSWsFzdHN41mJ5I/DOFzxgkKSYNHQADHn7Mu+lU/AKw= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.29.1/go.mod h1:5mMk0DgUgaHlcqtN65fNyZI0ZDX3i9Cw+nwq75HKB3U= +github.com/aws/aws-sdk-go-v2/service/sso v1.20.9 h1:aD7AGQhvPuAxlSUfo0CWU7s6FpkbyykMhGYMvlqTjVs= +github.com/aws/aws-sdk-go-v2/service/sso v1.20.9/go.mod h1:c1qtZUWtygI6ZdvKppzCSXsDOq5I4luJPZ0Ud3juFCA= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.3 h1:Pav5q3cA260Zqez42T9UhIlsd9QeypszRPwC9LdSSsQ= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.3/go.mod h1:9lmoVDVLz/yUZwLaQ676TK02fhCu4+PgRSmMaKR1ozk= +github.com/aws/aws-sdk-go-v2/service/sts v1.28.10 h1:69tpbPED7jKPyzMcrwSvhWcJ9bPnZsZs18NT40JwM0g= +github.com/aws/aws-sdk-go-v2/service/sts v1.28.10/go.mod h1:0Aqn1MnEuitqfsCNyKsdKLhDUOr4txD/g19EfiUqgws= github.com/aws/smithy-go v1.20.2 h1:tbp628ireGtzcHDDmLT/6ADHidqnwgF57XOXZe6tp4Q= github.com/aws/smithy-go v1.20.2/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= @@ -106,14 +104,22 @@ github.com/bwesterb/go-ristretto v1.2.3 h1:1w53tCkGhCQ5djbat3+MH0BAQ5Kfgbt56UZQ/ github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/charmbracelet/bubbles v0.18.0 h1:PYv1A036luoBGroX6VWjQIE9Syf2Wby2oOl/39KLfy0= github.com/charmbracelet/bubbles v0.18.0/go.mod h1:08qhZhtIwzgrtBjAcJnij1t1H0ZRjwHyGsy6AL11PSw= -github.com/charmbracelet/bubbletea v0.26.2 h1:Eeb+n75Om9gQ+I6YpbCXQRKHt5Pn4vMwusQpwLiEgJQ= -github.com/charmbracelet/bubbletea v0.26.2/go.mod h1:6I0nZ3YHUrQj7YHIHlM8RySX4ZIthTliMY+W8X8b+Gs= +github.com/charmbracelet/bubbletea v0.26.3 h1:iXyGvI+FfOWqkB2V07m1DF3xxQijxjY2j8PqiXYqasg= +github.com/charmbracelet/bubbletea v0.26.3/go.mod h1:bpZHfDHTYJC5g+FBK+ptJRCQotRC+Dhh3AoMxa/2+3Q= github.com/charmbracelet/glamour v0.7.0 h1:2BtKGZ4iVJCDfMF229EzbeR1QRKLWztO9dMtjmqZSng= github.com/charmbracelet/glamour v0.7.0/go.mod h1:jUMh5MeihljJPQbJ/wf4ldw2+yBP59+ctV36jASy7ps= github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ= github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao= -github.com/charmbracelet/lipgloss v0.10.0 h1:KWeXFSexGcfahHX+54URiZGkBFazf70JNMtwg/AFW3s= -github.com/charmbracelet/lipgloss v0.10.0/go.mod h1:Wig9DSfvANsxqkRsqj6x87irdy123SR4dOXlKa91ciE= +github.com/charmbracelet/lipgloss v0.11.0 h1:UoAcbQ6Qml8hDwSWs0Y1cB5TEQuZkDPH/ZqwWWYTG4g= +github.com/charmbracelet/lipgloss v0.11.0/go.mod h1:1UdRTH9gYgpcdNN5oBtjbu/IzNKtzVtb7sqN1t9LNn8= +github.com/charmbracelet/x/ansi v0.1.1 h1:CGAduulr6egay/YVbGc8Hsu8deMg1xZ/bkaXTPi1JDk= +github.com/charmbracelet/x/ansi v0.1.1/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/input v0.1.1 h1:YDOJaTUKCqtGnq9PHzx3pkkl4pXDOANUHmhH3DqMtM4= +github.com/charmbracelet/x/input v0.1.1/go.mod h1:jvdTVUnNWj/RD6hjC4FsoB0SeZCJ2ZBkiuFP9zXvZI0= +github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXDjF6yI= +github.com/charmbracelet/x/term v0.1.1/go.mod h1:wB1fHt5ECsu3mXYusyzcngVWWlu1KKUmmLhfgr/Flxw= +github.com/charmbracelet/x/windows v0.1.2 h1:Iumiwq2G+BRmgoayww/qfcvof7W/3uLoelhxojXlRWg= +github.com/charmbracelet/x/windows v0.1.2/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.8 h1:j+V8jJt09PoeMFIu2uh5JUyEaIHTXVOHslFoLNAKqwI= github.com/cloudflare/circl v1.3.8/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU= @@ -357,8 +363,8 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= -github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/crypt v0.17.0 h1:ZA/7pXyjkHoK4bW4mIdnCLvL8hd+Nrbiw7Dqk7D4qUk= @@ -432,6 +438,8 @@ github.com/urfave/cli v1.22.14 h1:ebbhrRiGK2i4naQJr+1Xj92HXZCrK7MsyTS/ob3HnAk= github.com/urfave/cli v1.22.14/go.mod h1:X0eDS6pD6Exaclxm99NJ3FiCDRED7vIHpx2mDOHLvkA= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= github.com/yuin/goldmark v1.3.7/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U= @@ -470,8 +478,8 @@ golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2Uz golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= -golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= +golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d h1:N0hmiNbwsSNwHBAvR3QB5w25pUwH4tK0Y/RltD1j1h4= +golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
chore
Update dependencies
b7fb2153c08f03b250f2c1da5075aaf4b1403770
2021-09-29 06:24:01
Tom Payne
fix: Allow modify_ scripts to be encrypted
false
diff --git a/internal/chezmoi/attr.go b/internal/chezmoi/attr.go index ccedbd0235f..c32ab7a49e1 100644 --- a/internal/chezmoi/attr.go +++ b/internal/chezmoi/attr.go @@ -188,6 +188,10 @@ func parseFileAttr(sourceName, encryptedSuffix string) FileAttr { case strings.HasPrefix(name, modifyPrefix): sourceFileType = SourceFileTypeModify name = mustTrimPrefix(name, modifyPrefix) + if strings.HasPrefix(name, encryptedPrefix) { + name = mustTrimPrefix(name, encryptedPrefix) + encrypted = true + } if strings.HasPrefix(name, privatePrefix) { name = mustTrimPrefix(name, privatePrefix) private = true diff --git a/internal/cmd/testdata/scripts/modifyencrypted.txt b/internal/cmd/testdata/scripts/modifyencrypted.txt new file mode 100644 index 00000000000..28c76007aff --- /dev/null +++ b/internal/cmd/testdata/scripts/modifyencrypted.txt @@ -0,0 +1,22 @@ +[windows] skip 'UNIX only' +[!exec:age] skip 'age not found in $PATH' + +mkageconfig + +# test that chezmoi applies encrypted modify scripts +mkdir $CHEZMOISOURCEDIR +chezmoi encrypt --output=$CHEZMOISOURCEDIR${/}modify_encrypted_dot_modify.age golden/modify.sh +grep '-----BEGIN AGE ENCRYPTED FILE-----' $CHEZMOISOURCEDIR/modify_encrypted_dot_modify.age +chezmoi apply --force +cmp $HOME/.modify golden/.modify-modified + +-- golden/.modify-modified -- +# contents of .modify +# modified +-- golden/modify.sh -- +#!/bin/sh + +cat +echo "# modified" +-- home/user/.modify -- +# contents of .modify
fix
Allow modify_ scripts to be encrypted
0c10ff7463bee7c31149a8866ce66ee5d5f184ed
2022-02-02 03:54:23
Tom Payne
chore: Add NullSystem
false
diff --git a/pkg/chezmoi/nullsystem.go b/pkg/chezmoi/nullsystem.go new file mode 100644 index 00000000000..ddb7033b370 --- /dev/null +++ b/pkg/chezmoi/nullsystem.go @@ -0,0 +1,6 @@ +package chezmoi + +type NullSystem struct { + emptySystemMixin + noUpdateSystemMixin +} diff --git a/pkg/chezmoi/nullsystem_test.go b/pkg/chezmoi/nullsystem_test.go new file mode 100644 index 00000000000..fa049b01fc1 --- /dev/null +++ b/pkg/chezmoi/nullsystem_test.go @@ -0,0 +1,3 @@ +package chezmoi + +var _ System = &NullSystem{}
chore
Add NullSystem
d99e8bd4bd10bea00c6994249e9fbebcd7274fc9
2023-12-21 22:18:43
Tom Payne
feat: Extend rbw and rbwFields template funcs to take extra args
false
diff --git a/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/rbw.md b/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/rbw.md index e27a526fa18..b7b9dd52aae 100644 --- a/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/rbw.md +++ b/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/rbw.md @@ -1,8 +1,8 @@ -# `rbw` [*arg*...] +# `rbw` *name* [*arg*...] `rbw` returns structured data retrieved from [Bitwarden](https://bitwarden.com) -using [`rbw`](https://github.com/doy/rbw). *arg*s are passed to `rbw get --raw` -and the output is parsed as JSON. +using [`rbw`](https://github.com/doy/rbw). *name* is passed to `rbw get --raw`, +along with any extra *arg*s, and the output is parsed as JSON. The output from `rbw get --raw` is cached so calling `rbw` multiple times with the same arguments will only invoke `rbw` once. @@ -11,5 +11,5 @@ the same arguments will only invoke `rbw` once. ``` username = {{ (rbw "test-entry").data.username }} - password = {{ (rbw "test-entry").data.password }} + password = {{ (rbw "test-entry" "--folder" "my-folder").data.password }} ``` diff --git a/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/rbwFields.md b/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/rbwFields.md index 7d84c183d55..04658600329 100644 --- a/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/rbwFields.md +++ b/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/rbwFields.md @@ -1,9 +1,9 @@ -# `rbwFields` *name* +# `rbwFields` *name* [*arg*...] `rbw` returns structured data retrieved from [Bitwarden](https://bitwarden.com) -using [`rbw`](https://github.com/doy/rbw). *arg*s are passed to `rbw get --raw` -and the output is parsed as JSON, and the elements of `fields` are returned as a dict -indexed by each field's `name`. +using [`rbw`](https://github.com/doy/rbw). *name* is passed to `rbw get --raw`, +along with any extra *arg*s, the output is parsed as JSON, and the elements +of `fields` are returned as a dict indexed by each field's `name`. The output from `rbw get --raw` is cached so calling `rbwFields` multiple times with the same arguments will only invoke `rbwFields` once. @@ -12,4 +12,5 @@ the same arguments will only invoke `rbwFields` once. ``` {{ (rbwFields "item").name.value }} + {{ (rbwFields "item" "--folder" "my-folder").name.value }} ``` diff --git a/internal/cmd/rbwtemplatefuncs.go b/internal/cmd/rbwtemplatefuncs.go index 1e52a714b67..6e700001d17 100644 --- a/internal/cmd/rbwtemplatefuncs.go +++ b/internal/cmd/rbwtemplatefuncs.go @@ -18,8 +18,8 @@ type rbwConfig struct { var rbwMinVersion = semver.Version{Major: 1, Minor: 7, Patch: 0} -func (c *Config) rbwFieldsTemplateFunc(name string) map[string]any { - args := []string{"get", "--raw", name} +func (c *Config) rbwFieldsTemplateFunc(name string, extraArgs ...string) map[string]any { + args := append([]string{"get", "--raw", name}, extraArgs...) output, err := c.rbwOutput(args) if err != nil { panic(err) @@ -39,8 +39,8 @@ func (c *Config) rbwFieldsTemplateFunc(name string) map[string]any { return result } -func (c *Config) rbwTemplateFunc(name string) map[string]any { - args := []string{"get", "--raw", name} +func (c *Config) rbwTemplateFunc(name string, extraArgs ...string) map[string]any { + args := append([]string{"get", "--raw", name}, extraArgs...) output, err := c.rbwOutput(args) if err != nil { panic(err) diff --git a/internal/cmd/testdata/scripts/rbw.txtar b/internal/cmd/testdata/scripts/rbw.txtar index 026aa6bc2b2..b59229eafa6 100644 --- a/internal/cmd/testdata/scripts/rbw.txtar +++ b/internal/cmd/testdata/scripts/rbw.txtar @@ -5,10 +5,18 @@ exec chezmoi execute-template '{{ (rbw "test-entry").data.password }}' stdout ^hunter2$ +# test rbw template function with extra args +exec chezmoi execute-template '{{ (rbw "test-entry" "--folder" "my-folder").data.password }}' +stdout ^correcthorsebatterystaple$ + # test rbwFields template function exec chezmoi execute-template '{{ (rbwFields "test-entry").something.value }}' stdout ^secret$ +# test rbwFields template function with extra args +exec chezmoi execute-template '{{ (rbwFields "test-entry" "--folder" "my-folder").something.value }}' +stdout ^enigma$ + -- bin/rbw -- #!/bin/sh @@ -44,6 +52,39 @@ case "$*" in } ] } +EOF + ;; +"get --raw test-entry --folder my-folder") + cat <<EOF +{ + "id": "adf723e1-ab03-4ff3-81aa-f5f3c2b68a5f", + "folder": null, + "name": "test-entry", + "data": { + "username": "foo", + "password": "correcthorsebatterystaple", + "totp": null, + "uris": [ + { + "uri": "example.com", + "match_type": null + } + ] + }, + "fields": [ + { + "name": "something", + "value": "enigma" + } + ], + "notes": "blah", + "history": [ + { + "last_used_date": "2022-08-18T23:24:47.994Z", + "password": "hunter2" + } + ] +} EOF ;; *) @@ -82,6 +123,36 @@ IF "%*" == "get --raw test-entry" ( echo. } echo. ] echo.} +) ELSE IF "%*" == "get --raw test-entry --folder my-folder" ( + echo.{ + echo. "id": "adf723e1-ab03-4ff3-81aa-f5f3c2b68a5f", + echo. "folder": null, + echo. "name": "test-entry", + echo. "data": { + echo. "username": "foo", + echo. "password": "correcthorsebatterystaple", + echo. "totp": null, + echo. "uris": [ + echo. { + echo. "uri": "example.com", + echo. "match_type": null + echo. } + echo. ] + echo. }, + echo. "fields": [ + echo. { + echo. "name": "something", + echo. "value": "enigma" + echo. } + echo. ], + echo. "notes": "blah", + echo. "history": [ + echo. { + echo. "last_used_date": "2022-08-18T23:24:47.994Z", + echo. "password": "hunter2" + echo. } + echo. ] + echo.} ) ELSE ( exit /b 1 )
feat
Extend rbw and rbwFields template funcs to take extra args
a2c5685a47094b020851b4c75270539706560738
2021-12-02 10:49:45
Tom Payne
fix: Read .chezmoiversion before other files
false
diff --git a/internal/chezmoi/chezmoi.go b/internal/chezmoi/chezmoi.go index fcb8fc5f05a..222b5a0dd17 100644 --- a/internal/chezmoi/chezmoi.go +++ b/internal/chezmoi/chezmoi.go @@ -10,6 +10,8 @@ import ( "path/filepath" "regexp" "strings" + + "github.com/coreos/go-semver/semver" ) var ( @@ -97,6 +99,17 @@ var modeTypeNames = map[fs.FileMode]string{ fs.ModeCharDevice: "char device", } +// A TooOldErrror is returned when the source state requires a newer version of +// chezmoi. +type TooOldError struct { + Have semver.Version + Need semver.Version +} + +func (e *TooOldError) Error() string { + return fmt.Sprintf("source state requires version %s or later, chezmoi is version %s", e.Need, e.Have) +} + type inconsistentStateError struct { targetRelPath RelPath origins []string diff --git a/internal/chezmoi/dumpsystem_test.go b/internal/chezmoi/dumpsystem_test.go index 6b54c5c4513..af5134be9d8 100644 --- a/internal/chezmoi/dumpsystem_test.go +++ b/internal/chezmoi/dumpsystem_test.go @@ -4,6 +4,7 @@ import ( "context" "testing" + "github.com/coreos/go-semver/semver" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" vfs "github.com/twpayne/go-vfs/v4" @@ -36,6 +37,11 @@ func TestDumpSystem(t *testing.T) { WithBaseSystem(system), WithSourceDir(NewAbsPath("/home/user/.local/share/chezmoi")), WithSystem(system), + WithVersion(semver.Version{ + Major: 1, + Minor: 2, + Patch: 3, + }), ) require.NoError(t, s.Read(ctx, nil)) requireEvaluateAll(t, s, system) diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go index 50ae8c97aa2..00ed65fec92 100644 --- a/internal/chezmoi/sourcestate.go +++ b/internal/chezmoi/sourcestate.go @@ -79,7 +79,7 @@ type SourceState struct { interpreters map[string]*Interpreter httpClient *http.Client logger *zerolog.Logger - minVersion semver.Version + version semver.Version mode Mode defaultTemplateDataFunc func() map[string]interface{} readTemplateData bool @@ -144,15 +144,6 @@ func WithLogger(logger *zerolog.Logger) SourceStateOption { } } -// WithMinVersion sets the minimum version. -func WithMinVersion(minVersion *semver.Version) SourceStateOption { - return func(s *SourceState) { - if minVersion != nil && s.minVersion.LessThan(*minVersion) { - s.minVersion = *minVersion - } - } -} - // WithMode sets the mode. func WithMode(mode Mode) SourceStateOption { return func(s *SourceState) { @@ -209,6 +200,13 @@ func WithTemplateOptions(templateOptions []string) SourceStateOption { } } +// WithVersion sets the version. +func WithVersion(version semver.Version) SourceStateOption { + return func(s *SourceState) { + s.version = version + } +} + // A targetStateEntryFunc returns a TargetStateEntry based on reading an AbsPath // on a System. type targetStateEntryFunc func(System, AbsPath) (TargetStateEntry, error) @@ -688,11 +686,6 @@ func (s *SourceState) Ignore(targetRelPath RelPath) bool { return s.ignore.match(targetRelPath.String()) } -// MinVersion returns the minimum version for which s is valid. -func (s *SourceState) MinVersion() semver.Version { - return s.minVersion -} - // MustEntry returns the source state entry associated with targetRelPath, and // panics if it does not exist. func (s *SourceState) MustEntry(targetRelPath RelPath) SourceStateEntry { @@ -801,7 +794,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error { } return vfs.SkipDir case fileInfo.Name() == VersionName: - return s.addVersionFile(sourceAbsPath) + return s.readVersionFile(sourceAbsPath) case strings.HasPrefix(fileInfo.Name(), Prefix): fallthrough case strings.HasPrefix(fileInfo.Name(), ignorePrefix): @@ -1113,24 +1106,6 @@ func (s *SourceState) addTemplatesDir(templatesDirAbsPath AbsPath) error { return WalkSourceDir(s.system, templatesDirAbsPath, walkFunc) } -// addVersionFile reads a .chezmoiversion file from source path and updates s's -// minimum version if it contains a more recent version than the current minimum -// version. -func (s *SourceState) addVersionFile(sourceAbsPath AbsPath) error { - data, err := s.system.ReadFile(sourceAbsPath) - if err != nil { - return err - } - version, err := semver.NewVersion(strings.TrimSpace(string(data))) - if err != nil { - return err - } - if s.minVersion.LessThan(*version) { - s.minVersion = *version - } - return nil -} - // executeTemplate executes the template at path and returns the result. func (s *SourceState) executeTemplate(templateAbsPath AbsPath) ([]byte, error) { data, err := s.system.ReadFile(templateAbsPath) @@ -1901,6 +1876,26 @@ func (s *SourceState) readScriptsDir(scriptsDirAbsPath AbsPath) (map[RelPath][]S return allSourceStateEntries, nil } +// readVersionFile reads a .chezmoiversion file from sourceAbsPath and returns +// an error if the version is newer that s's version. +func (s *SourceState) readVersionFile(sourceAbsPath AbsPath) error { + data, err := s.system.ReadFile(sourceAbsPath) + if err != nil { + return err + } + version, err := semver.NewVersion(strings.TrimSpace(string(data))) + if err != nil { + return err + } + if s.version.LessThan(*version) { + return &TooOldError{ + Have: s.version, + Need: *version, + } + } + return nil +} + // sourceStateEntry returns a new SourceStateEntry based on actualStateEntry. func (s *SourceState) sourceStateEntry( actualStateEntry ActualStateEntry, destAbsPath AbsPath, fileInfo fs.FileInfo, parentSourceRelPath SourceRelPath, diff --git a/internal/chezmoi/sourcestate_test.go b/internal/chezmoi/sourcestate_test.go index a21e6fcb9e2..2f56972f38c 100644 --- a/internal/chezmoi/sourcestate_test.go +++ b/internal/chezmoi/sourcestate_test.go @@ -1216,15 +1216,7 @@ func TestSourceStateRead(t *testing.T) { ".chezmoiversion": "1.2.3\n", }, }, - expectedSourceState: NewSourceState( - withMinVersion( - semver.Version{ - Major: 1, - Minor: 2, - Patch: 3, - }, - ), - ), + expectedSourceState: NewSourceState(), }, { name: "chezmoiversion_multiple", @@ -1236,27 +1228,7 @@ func TestSourceStateRead(t *testing.T) { }, }, }, - expectedSourceState: NewSourceState( - withEntries(map[RelPath]SourceStateEntry{ - NewRelPath("dir"): &SourceStateDir{ - origin: "dir", - sourceRelPath: NewSourceRelDirPath("dir"), - Attr: DirAttr{ - TargetName: "dir", - }, - targetStateEntry: &TargetStateDir{ - perm: 0o777 &^ chezmoitest.Umask, - }, - }, - }), - withMinVersion( - semver.Version{ - Major: 2, - Minor: 3, - Patch: 4, - }, - ), - ), + expectedError: "source state requires version 2.3.4 or later, chezmoi is version 1.2.3", }, { name: "ignore_dir", @@ -1288,6 +1260,11 @@ func TestSourceStateRead(t *testing.T) { WithDestDir(NewAbsPath("/home/user")), WithSourceDir(NewAbsPath("/home/user/.local/share/chezmoi")), WithSystem(system), + WithVersion(semver.Version{ + Major: 1, + Minor: 2, + Patch: 3, + }), ) err := s.Read(ctx, nil) if tc.expectedError != "" { @@ -1303,6 +1280,7 @@ func TestSourceStateRead(t *testing.T) { s.baseSystem = nil s.system = nil s.templateData = nil + s.version = semver.Version{} assert.Equal(t, tc.expectedSourceState, s) }) }) @@ -1533,6 +1511,7 @@ func TestWalkSourceDir(t *testing.T) { } expectedAbsPaths := []AbsPath{ sourceDirAbsPath, + sourceDirAbsPath.JoinString(".chezmoiversion"), sourceDirAbsPath.JoinString(".chezmoidata.json"), sourceDirAbsPath.JoinString(".chezmoidata.toml"), sourceDirAbsPath.JoinString(".chezmoidata.yaml"), @@ -1541,7 +1520,6 @@ func TestWalkSourceDir(t *testing.T) { sourceDirAbsPath.JoinString(".chezmoiexternal.yaml"), sourceDirAbsPath.JoinString(".chezmoiignore"), sourceDirAbsPath.JoinString(".chezmoiremove"), - sourceDirAbsPath.JoinString(".chezmoiversion"), sourceDirAbsPath.JoinString("dot_file"), } @@ -1604,12 +1582,6 @@ func withIgnore(ignore *patternSet) SourceStateOption { } } -func withMinVersion(minVersion semver.Version) SourceStateOption { - return func(s *SourceState) { - s.minVersion = minVersion - } -} - // withUserTemplateData adds template data. func withUserTemplateData(templateData map[string]interface{}) SourceStateOption { return func(s *SourceState) { diff --git a/internal/chezmoi/system.go b/internal/chezmoi/system.go index 46b8365b4db..be6a8f42d0a 100644 --- a/internal/chezmoi/system.go +++ b/internal/chezmoi/system.go @@ -176,6 +176,7 @@ func WalkSourceDir(system System, sourceDirAbsPath AbsPath, walkFunc WalkSourceD // source directory. More negative values are visited first. Entries with the // same order are visited alphabetically. The default order is zero. var sourceDirEntryOrder = map[string]int{ + ".chezmoiversion": -3, ".chezmoidata.json": -2, ".chezmoidata.toml": -2, ".chezmoidata.yaml": -2, diff --git a/internal/chezmoi/tarwritersystem_test.go b/internal/chezmoi/tarwritersystem_test.go index d2d488080c4..7a7ca9da922 100644 --- a/internal/chezmoi/tarwritersystem_test.go +++ b/internal/chezmoi/tarwritersystem_test.go @@ -7,6 +7,7 @@ import ( "io" "testing" + "github.com/coreos/go-semver/semver" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" vfs "github.com/twpayne/go-vfs/v4" @@ -39,6 +40,11 @@ func TestTARWriterSystem(t *testing.T) { WithBaseSystem(system), WithSourceDir(NewAbsPath("/home/user/.local/share/chezmoi")), WithSystem(system), + WithVersion(semver.Version{ + Major: 1, + Minor: 2, + Patch: 3, + }), ) require.NoError(t, s.Read(ctx, nil)) requireEvaluateAll(t, s, system) diff --git a/internal/chezmoi/zipwritersystem_test.go b/internal/chezmoi/zipwritersystem_test.go index 23469acb0e3..078fcbb0259 100644 --- a/internal/chezmoi/zipwritersystem_test.go +++ b/internal/chezmoi/zipwritersystem_test.go @@ -9,6 +9,7 @@ import ( "testing" "time" + "github.com/coreos/go-semver/semver" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" vfs "github.com/twpayne/go-vfs/v4" @@ -41,6 +42,11 @@ func TestZIPWriterSystem(t *testing.T) { WithBaseSystem(system), WithSourceDir(NewAbsPath("/home/user/.local/share/chezmoi")), WithSystem(system), + WithVersion(semver.Version{ + Major: 1, + Minor: 2, + Patch: 3, + }), ) require.NoError(t, s.Read(ctx, nil)) requireEvaluateAll(t, s, system) diff --git a/internal/cmd/config.go b/internal/cmd/config.go index e6ebd1d38ea..1d935ff80e7 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -150,7 +150,7 @@ type Config struct { verify verifyCmdConfig // Version information. - version *semver.Version + version semver.Version versionInfo VersionInfo versionStr string @@ -1362,16 +1362,22 @@ func (c *Config) newSourceState( sourceStateLogger := c.logger.With().Str(logComponentKey, logComponentValueSourceState).Logger() versionAbsPath := c.SourceDirAbsPath.JoinString(chezmoi.VersionName) - var minVersion *semver.Version switch data, err := c.baseSystem.ReadFile(versionAbsPath); { case errors.Is(err, fs.ErrNotExist): case err != nil: return nil, err default: - minVersion, err = semver.NewVersion(strings.TrimSpace(string(data))) + minVersion, err := semver.NewVersion(strings.TrimSpace(string(data))) if err != nil { return nil, fmt.Errorf("%s: %w", versionAbsPath, err) } + var zeroVersion semver.Version + if c.version != zeroVersion && c.version.LessThan(*minVersion) { + return nil, &chezmoi.TooOldError{ + Need: *minVersion, + Have: c.version, + } + } } c.SourceDirAbsPath, err = c.sourceDirAbsPath() @@ -1388,13 +1394,13 @@ func (c *Config) newSourceState( chezmoi.WithHTTPClient(httpClient), chezmoi.WithInterpreters(c.Interpreters), chezmoi.WithLogger(&sourceStateLogger), - chezmoi.WithMinVersion(minVersion), chezmoi.WithMode(c.Mode), chezmoi.WithPriorityTemplateData(c.Data), chezmoi.WithSourceDir(c.SourceDirAbsPath), chezmoi.WithSystem(c.sourceSystem), chezmoi.WithTemplateFuncs(c.templateFuncs), chezmoi.WithTemplateOptions(c.Template.Options), + chezmoi.WithVersion(c.version), }, options...)...) if err := s.Read(ctx, &chezmoi.ReadOptions{ @@ -1403,10 +1409,6 @@ func (c *Config) newSourceState( return nil, err } - if minVersion := s.MinVersion(); c.version != nil && !isDevVersion(c.version) && c.version.LessThan(minVersion) { - return nil, fmt.Errorf("source state requires version %s or later, chezmoi is version %s", minVersion, c.version) - } - return s, nil } @@ -2000,12 +2002,6 @@ func (c *Config) writeOutputString(data string) error { return c.writeOutput([]byte(data)) } -// isDevVersion returns true if version is a development version (i.e. that the -// major, minor, and patch version numbers are all zero). -func isDevVersion(v *semver.Version) bool { - return v.Major == 0 && v.Minor == 0 && v.Patch == 0 -} - // withVersionInfo sets the version information. func withVersionInfo(versionInfo VersionInfo) configOption { return func(c *Config) error { @@ -2034,7 +2030,9 @@ func withVersionInfo(versionInfo VersionInfo) configOption { if versionInfo.BuiltBy != "" { versionElems = append(versionElems, "built by "+versionInfo.BuiltBy) } - c.version = version + if version != nil { + c.version = *version + } c.versionInfo = versionInfo c.versionStr = strings.Join(versionElems, ", ") return nil diff --git a/internal/cmd/upgradecmd.go b/internal/cmd/upgradecmd.go index a9e968d144d..59f8e10ffaa 100644 --- a/internal/cmd/upgradecmd.go +++ b/internal/cmd/upgradecmd.go @@ -110,7 +110,8 @@ func (c *Config) runUpgradeCmd(cmd *cobra.Command, args []string) error { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - if c.version == nil && !c.force { + var zeroVersion semver.Version + if c.version == zeroVersion && !c.force { return errors.New("cannot upgrade dev version to latest released version unless --force is set") }
fix
Read .chezmoiversion before other files
caa9120078e0a259e518c6d2217fda2d7ec951f4
2022-03-18 21:45:31
hydrargyrum
docs: Update dconf example as dconf only reads stdin
false
diff --git a/assets/chezmoi.io/docs/user-guide/use-scripts-to-perform-actions.md b/assets/chezmoi.io/docs/user-guide/use-scripts-to-perform-actions.md index a96ce49552e..b5eb6e561b3 100644 --- a/assets/chezmoi.io/docs/user-guide/use-scripts-to-perform-actions.md +++ b/assets/chezmoi.io/docs/user-guide/use-scripts-to-perform-actions.md @@ -101,7 +101,7 @@ the following script as `run_once_dconf-load.sh.tmpl`: #!/bin/bash # dconf.ini hash: {{ include "dconf.ini" | sha256sum }} -dconf load / {{ joinPath .chezmoi.sourceDir "dconf.ini" | quote }} +dconf load / < {{ joinPath .chezmoi.sourceDir "dconf.ini" | quote }} ``` As the SHA256 sum of `dconf.ini` is included in a comment in the script, the
docs
Update dconf example as dconf only reads stdin
2dffe643a9fbabbe1ce1a9f11135aa2b292b073c
2024-01-24 20:11:56
Daniel Possenriede
docs: links to testing-templates
false
diff --git a/assets/chezmoi.io/docs/reference/commands/execute-template.md b/assets/chezmoi.io/docs/reference/commands/execute-template.md index e4370c12106..d663c040fe9 100644 --- a/assets/chezmoi.io/docs/reference/commands/execute-template.md +++ b/assets/chezmoi.io/docs/reference/commands/execute-template.md @@ -1,6 +1,7 @@ # `execute-template` [*template*...] -Execute *template*s. This is useful for testing templates or for calling +Execute *template*s. This is useful for [testing +templates](../../user-guide/templating.md#testing-templates) or for calling chezmoi from other scripts. *templates* are interpreted as literal templates, with no whitespace added to the output between arguments. If no templates are specified, the template is read from stdin. diff --git a/assets/chezmoi.io/docs/user-guide/manage-machine-to-machine-differences.md b/assets/chezmoi.io/docs/user-guide/manage-machine-to-machine-differences.md index a35ff1b600f..91377552a5f 100644 --- a/assets/chezmoi.io/docs/user-guide/manage-machine-to-machine-differences.md +++ b/assets/chezmoi.io/docs/user-guide/manage-machine-to-machine-differences.md @@ -93,7 +93,8 @@ create a file on disk, with the `execute-template` command, for example: $ chezmoi execute-template "{{ .chezmoi.os }}/{{ .chezmoi.arch }}" ``` -This is useful when developing or debugging templates. +This is useful when developing or [debugging +templates](../user-guide/templating.md#testing-templates). Some password managers allow you to store complete files. The files can be retrieved with chezmoi's template functions. For example, if you have a file
docs
links to testing-templates
209a16d806e60ef9c73632d0e2201c914ff0af8f
2025-02-18 19:36:49
Tom Payne
chore: Update dependencies
false
diff --git a/completions/chezmoi-completion.bash b/completions/chezmoi-completion.bash index 65819e529aa..c6ebe5d4ccb 100644 --- a/completions/chezmoi-completion.bash +++ b/completions/chezmoi-completion.bash @@ -110,7 +110,7 @@ __chezmoi_process_completion_results() { if (((directive & shellCompDirectiveFilterFileExt) != 0)); then # File extension filtering - local fullFilter filter filteringCmd + local fullFilter="" filter filteringCmd # Do not use quotes around the $completions variable or else newline # characters will be kept. @@ -141,20 +141,71 @@ __chezmoi_process_completion_results() { __chezmoi_handle_special_char "$cur" = # Print the activeHelp statements before we finish + __chezmoi_handle_activeHelp +} + +__chezmoi_handle_activeHelp() { + # Print the activeHelp statements if ((${#activeHelp[*]} != 0)); then - printf "\n"; - printf "%s\n" "${activeHelp[@]}" - printf "\n" - - # The prompt format is only available from bash 4.4. - # We test if it is available before using it. - if (x=${PS1@P}) 2> /dev/null; then - printf "%s" "${PS1@P}${COMP_LINE[@]}" - else - # Can't print the prompt. Just print the - # text the user had typed, it is workable enough. - printf "%s" "${COMP_LINE[@]}" + if [ -z $COMP_TYPE ]; then + # Bash v3 does not set the COMP_TYPE variable. + printf "\n"; + printf "%s\n" "${activeHelp[@]}" + printf "\n" + __chezmoi_reprint_commandLine + return fi + + # Only print ActiveHelp on the second TAB press + if [ $COMP_TYPE -eq 63 ]; then + printf "\n" + printf "%s\n" "${activeHelp[@]}" + + if ((${#COMPREPLY[*]} == 0)); then + # When there are no completion choices from the program, file completion + # may kick in if the program has not disabled it; in such a case, we want + # to know if any files will match what the user typed, so that we know if + # there will be completions presented, so that we know how to handle ActiveHelp. + # To find out, we actually trigger the file completion ourselves; + # the call to _filedir will fill COMPREPLY if files match. + if (((directive & shellCompDirectiveNoFileComp) == 0)); then + __chezmoi_debug "Listing files" + _filedir + fi + fi + + if ((${#COMPREPLY[*]} != 0)); then + # If there are completion choices to be shown, print a delimiter. + # Re-printing the command-line will automatically be done + # by the shell when it prints the completion choices. + printf -- "--" + else + # When there are no completion choices at all, we need + # to re-print the command-line since the shell will + # not be doing it itself. + __chezmoi_reprint_commandLine + fi + elif [ $COMP_TYPE -eq 37 ] || [ $COMP_TYPE -eq 42 ]; then + # For completion type: menu-complete/menu-complete-backward and insert-completions + # the completions are immediately inserted into the command-line, so we first + # print the activeHelp message and reprint the command-line since the shell won't. + printf "\n" + printf "%s\n" "${activeHelp[@]}" + + __chezmoi_reprint_commandLine + fi + fi +} + +__chezmoi_reprint_commandLine() { + # The prompt format is only available from bash 4.4. + # We test if it is available before using it. + if (x=${PS1@P}) 2> /dev/null; then + printf "%s" "${PS1@P}${COMP_LINE[@]}" + else + # Can't print the prompt. Just print the + # text the user had typed, it is workable enough. + printf "%s" "${COMP_LINE[@]}" fi } @@ -165,6 +216,8 @@ __chezmoi_extract_activeHelp() { local endIndex=${#activeHelpMarker} while IFS='' read -r comp; do + [[ -z $comp ]] && continue + if [[ ${comp:0:endIndex} == $activeHelpMarker ]]; then comp=${comp:endIndex} __chezmoi_debug "ActiveHelp found: $comp" @@ -187,16 +240,21 @@ __chezmoi_handle_completion_types() { # If the user requested inserting one completion at a time, or all # completions at once on the command-line we must remove the descriptions. # https://github.com/spf13/cobra/issues/1508 - local tab=$'\t' comp - while IFS='' read -r comp; do - [[ -z $comp ]] && continue - # Strip any description - comp=${comp%%$tab*} - # Only consider the completions that match - if [[ $comp == "$cur"* ]]; then - COMPREPLY+=("$comp") - fi - done < <(printf "%s\n" "${completions[@]}") + + # If there are no completions, we don't need to do anything + (( ${#completions[@]} == 0 )) && return 0 + + local tab=$'\t' + + # Strip any description and escape the completion to handled special characters + IFS=$'\n' read -ra completions -d '' < <(printf "%q\n" "${completions[@]%%$tab*}") + + # Only consider the completions that match + IFS=$'\n' read -ra COMPREPLY -d '' < <(IFS=$'\n'; compgen -W "${completions[*]}" -- "${cur}") + + # compgen looses the escaping so we need to escape all completions again since they will + # all be inserted on the command-line. + IFS=$'\n' read -ra COMPREPLY -d '' < <(printf "%q\n" "${COMPREPLY[@]}") ;; *) @@ -207,11 +265,25 @@ __chezmoi_handle_completion_types() { } __chezmoi_handle_standard_completion_case() { - local tab=$'\t' comp + local tab=$'\t' + + # If there are no completions, we don't need to do anything + (( ${#completions[@]} == 0 )) && return 0 # Short circuit to optimize if we don't have descriptions if [[ "${completions[*]}" != *$tab* ]]; then - IFS=$'\n' read -ra COMPREPLY -d '' < <(compgen -W "${completions[*]}" -- "$cur") + # First, escape the completions to handle special characters + IFS=$'\n' read -ra completions -d '' < <(printf "%q\n" "${completions[@]}") + # Only consider the completions that match what the user typed + IFS=$'\n' read -ra COMPREPLY -d '' < <(IFS=$'\n'; compgen -W "${completions[*]}" -- "${cur}") + + # compgen looses the escaping so, if there is only a single completion, we need to + # escape it again because it will be inserted on the command-line. If there are multiple + # completions, we don't want to escape them because they will be printed in a list + # and we don't want to show escape characters in that list. + if (( ${#COMPREPLY[@]} == 1 )); then + COMPREPLY[0]=$(printf "%q" "${COMPREPLY[0]}") + fi return 0 fi @@ -220,23 +292,39 @@ __chezmoi_handle_standard_completion_case() { # Look for the longest completion so that we can format things nicely while IFS='' read -r compline; do [[ -z $compline ]] && continue - # Strip any description before checking the length - comp=${compline%%$tab*} + + # Before checking if the completion matches what the user typed, + # we need to strip any description and escape the completion to handle special + # characters because those escape characters are part of what the user typed. + # Don't call "printf" in a sub-shell because it will be much slower + # since we are in a loop. + printf -v comp "%q" "${compline%%$tab*}" &>/dev/null || comp=$(printf "%q" "${compline%%$tab*}") + # Only consider the completions that match [[ $comp == "$cur"* ]] || continue + + # The completions matches. Add it to the list of full completions including + # its description. We don't escape the completion because it may get printed + # in a list if there are more than one and we don't want show escape characters + # in that list. COMPREPLY+=("$compline") + + # Strip any description before checking the length, and again, don't escape + # the completion because this length is only used when printing the completions + # in a list and we don't want show escape characters in that list. + comp=${compline%%$tab*} if ((${#comp}>longest)); then longest=${#comp} fi done < <(printf "%s\n" "${completions[@]}") - # If there is a single completion left, remove the description text + # If there is a single completion left, remove the description text and escape any special characters if ((${#COMPREPLY[*]} == 1)); then __chezmoi_debug "COMPREPLY[0]: ${COMPREPLY[0]}" - comp="${COMPREPLY[0]%%$tab*}" - __chezmoi_debug "Removed description from single completion, which is now: ${comp}" - COMPREPLY[0]=$comp - else # Format the descriptions + COMPREPLY[0]=$(printf "%q" "${COMPREPLY[0]%%$tab*}") + __chezmoi_debug "Removed description from single completion, which is now: ${COMPREPLY[0]}" + else + # Format the descriptions __chezmoi_format_comp_descriptions $longest fi } diff --git a/completions/chezmoi.ps1 b/completions/chezmoi.ps1 index 2912f5238e6..7b268791263 100644 --- a/completions/chezmoi.ps1 +++ b/completions/chezmoi.ps1 @@ -125,7 +125,10 @@ filter __chezmoi_escapeStringWithSpecialChars { if (-Not $Description) { $Description = " " } - @{Name="$Name";Description="$Description"} + New-Object -TypeName PSCustomObject -Property @{ + Name = "$Name" + Description = "$Description" + } } @@ -203,7 +206,12 @@ filter __chezmoi_escapeStringWithSpecialChars { __chezmoi_debug "Only one completion left" # insert space after value - [System.Management.Automation.CompletionResult]::new($($comp.Name | __chezmoi_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)") + $CompletionText = $($comp.Name | __chezmoi_escapeStringWithSpecialChars) + $Space + if ($ExecutionContext.SessionState.LanguageMode -eq "FullLanguage"){ + [System.Management.Automation.CompletionResult]::new($CompletionText, "$($comp.Name)", 'ParameterValue', "$($comp.Description)") + } else { + $CompletionText + } } else { # Add the proper number of spaces to align the descriptions @@ -218,7 +226,12 @@ filter __chezmoi_escapeStringWithSpecialChars { $Description = " ($($comp.Description))" } - [System.Management.Automation.CompletionResult]::new("$($comp.Name)$Description", "$($comp.Name)$Description", 'ParameterValue', "$($comp.Description)") + $CompletionText = "$($comp.Name)$Description" + if ($ExecutionContext.SessionState.LanguageMode -eq "FullLanguage"){ + [System.Management.Automation.CompletionResult]::new($CompletionText, "$($comp.Name)$Description", 'ParameterValue', "$($comp.Description)") + } else { + $CompletionText + } } } @@ -227,7 +240,13 @@ filter __chezmoi_escapeStringWithSpecialChars { # insert space after value # MenuComplete will automatically show the ToolTip of # the highlighted value at the bottom of the suggestions. - [System.Management.Automation.CompletionResult]::new($($comp.Name | __chezmoi_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)") + + $CompletionText = $($comp.Name | __chezmoi_escapeStringWithSpecialChars) + $Space + if ($ExecutionContext.SessionState.LanguageMode -eq "FullLanguage"){ + [System.Management.Automation.CompletionResult]::new($CompletionText, "$($comp.Name)", 'ParameterValue', "$($comp.Description)") + } else { + $CompletionText + } } # TabCompleteNext and in case we get something unknown @@ -235,7 +254,13 @@ filter __chezmoi_escapeStringWithSpecialChars { # Like MenuComplete but we don't want to add a space here because # the user need to press space anyway to get the completion. # Description will not be shown because that's not possible with TabCompleteNext - [System.Management.Automation.CompletionResult]::new($($comp.Name | __chezmoi_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)") + + $CompletionText = $($comp.Name | __chezmoi_escapeStringWithSpecialChars) + if ($ExecutionContext.SessionState.LanguageMode -eq "FullLanguage"){ + [System.Management.Automation.CompletionResult]::new($CompletionText, "$($comp.Name)", 'ParameterValue', "$($comp.Description)") + } else { + $CompletionText + } } } diff --git a/go.mod b/go.mod index 5ef428b66b2..5e99dcfa5be 100644 --- a/go.mod +++ b/go.mod @@ -21,8 +21,8 @@ require ( github.com/coreos/go-semver v0.3.1 github.com/fsnotify/fsnotify v1.8.0 github.com/go-git/go-git/v5 v5.13.2 - github.com/goccy/go-yaml v1.15.22 - github.com/google/go-github/v69 v69.1.0 + github.com/goccy/go-yaml v1.15.23 + github.com/google/go-github/v69 v69.2.0 github.com/google/renameio/v2 v2.0.0 github.com/gopasspw/gopass v1.15.15 github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 @@ -36,7 +36,7 @@ require ( github.com/pelletier/go-toml/v2 v2.2.3 github.com/rogpeppe/go-internal v1.13.1 github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 - github.com/spf13/cobra v1.8.1 + github.com/spf13/cobra v1.9.1 github.com/spf13/pflag v1.0.6 github.com/tailscale/hujson v0.0.0-20241010212012-29efb4a0184b github.com/tobischo/gokeepasslib/v3 v3.6.1 @@ -51,7 +51,7 @@ require ( go.etcd.io/bbolt v1.4.0 go.uber.org/automaxprocs v1.6.0 golang.org/x/crypto v0.33.0 - golang.org/x/crypto/x509roots/fallback v0.0.0-20250210163342-e47973b1c108 + golang.org/x/crypto/x509roots/fallback v0.0.0-20250214233241-911360c8a4f4 golang.org/x/oauth2 v0.26.0 golang.org/x/sync v0.11.0 golang.org/x/sys v0.30.0 @@ -87,7 +87,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/sso v1.24.15 // indirect github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.14 // indirect github.com/aws/aws-sdk-go-v2/service/sts v1.33.14 // indirect - github.com/aws/smithy-go v1.22.2 // indirect + github.com/aws/smithy-go v1.22.3 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/blang/semver/v4 v4.0.0 // indirect @@ -174,7 +174,7 @@ require ( github.com/yuin/goldmark-emoji v1.0.4 // indirect go.opentelemetry.io/proto/otlp v1.5.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect + golang.org/x/exp v0.0.0-20250215185904-eff6e970281f // indirect golang.org/x/net v0.35.0 // indirect golang.org/x/text v0.22.0 // indirect golang.org/x/tools v0.30.0 // indirect diff --git a/go.sum b/go.sum index 1561382bf9b..ffe9807a574 100644 --- a/go.sum +++ b/go.sum @@ -115,8 +115,8 @@ github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.14 h1:M/zwXiL2iXUrHputuXgmO94 github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.14/go.mod h1:RVwIw3y/IqxC2YEXSIkAzRDdEU1iRabDPaYjpGCbCGQ= github.com/aws/aws-sdk-go-v2/service/sts v1.33.14 h1:TzeR06UCMUq+KA3bDkujxK1GVGy+G8qQN/QVYzGLkQE= github.com/aws/aws-sdk-go-v2/service/sts v1.33.14/go.mod h1:dspXf/oYWGWo6DEvj98wpaTeqt5+DMidZD0A9BYTizc= -github.com/aws/smithy-go v1.22.2 h1:6D9hW43xKFrRx/tXXfAlIZc4JI+yQe6snnWcQyxSyLQ= -github.com/aws/smithy-go v1.22.2/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= +github.com/aws/smithy-go v1.22.3 h1:Z//5NuZCSW6R4PhQ93hShNbyBbn8BWCmCVCt+Q8Io5k= +github.com/aws/smithy-go v1.22.3/go.mod h1:t1ufH5HMublsJYulve2RKmHDC15xu1f26kHCp/HgceI= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= @@ -167,7 +167,6 @@ github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= @@ -242,8 +241,8 @@ github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7 github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/goccy/go-yaml v1.15.22 h1:iQI1hvCoiYYiVFq76P4AI8ImgDOfgiyKnl/AWjK8/gA= -github.com/goccy/go-yaml v1.15.22/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= +github.com/goccy/go-yaml v1.15.23 h1:WS0GAX1uNPDLUvLkNU2vXq6oTnsmfVFocjQ/4qA48qo= +github.com/goccy/go-yaml v1.15.23/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -267,8 +266,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github/v61 v61.0.0 h1:VwQCBwhyE9JclCI+22/7mLB1PuU9eowCXKY5pNlu1go= github.com/google/go-github/v61 v61.0.0/go.mod h1:0WR+KmsWX75G2EbpyGsGmradjo3IiciuI4BmdVCobQY= -github.com/google/go-github/v69 v69.1.0 h1:ljzwzEsHsc4qUqyHEJCNA1dMqvoTK3YX2NAaK6iprDg= -github.com/google/go-github/v69 v69.1.0/go.mod h1:xne4jymxLR6Uj9b7J7PyTpkMYstEMMwGZa0Aehh1azM= +github.com/google/go-github/v69 v69.2.0 h1:wR+Wi/fN2zdUx9YxSmYE0ktiX9IAR/BeePzeaUUbEHE= +github.com/google/go-github/v69 v69.2.0/go.mod h1:xne4jymxLR6Uj9b7J7PyTpkMYstEMMwGZa0Aehh1azM= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg= @@ -514,12 +513,11 @@ github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs= github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4= github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y= github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= -github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= -github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= +github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= +github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= @@ -636,10 +634,10 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= -golang.org/x/crypto/x509roots/fallback v0.0.0-20250210163342-e47973b1c108 h1:GiOI2rw2a9rM8uEVXiG+phdNIZRNiT3/ibJBBjdUYfk= -golang.org/x/crypto/x509roots/fallback v0.0.0-20250210163342-e47973b1c108/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8= -golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac h1:l5+whBCLH3iH2ZNHYLbAe58bo7yrN4mVcnkHDYz5vvs= -golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac/go.mod h1:hH+7mtFmImwwcMvScyxUhjuVHR3HGaDPMn9rMSUUbxo= +golang.org/x/crypto/x509roots/fallback v0.0.0-20250214233241-911360c8a4f4 h1:QDiVWrFJ2lyXzr3pJnIREQWR8S7jkjzuWJPJda8Ic8E= +golang.org/x/crypto/x509roots/fallback v0.0.0-20250214233241-911360c8a4f4/go.mod h1:lxN5T34bK4Z/i6cMaU7frUU57VkDXFD4Kamfl/cp9oU= +golang.org/x/exp v0.0.0-20250215185904-eff6e970281f h1:oFMYAjX0867ZD2jcNiLBrI9BdpmEkvPyi5YrBGXbamg= +golang.org/x/exp v0.0.0-20250215185904-eff6e970281f/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=
chore
Update dependencies
9f88c3ac09edccc759d7a7e000e088b862fa1b96
2022-12-10 23:13:37
Tom Payne
feat: Add verification of external checksums
false
diff --git a/assets/chezmoi.io/docs/reference/special-files-and-directories/chezmoiexternal-format.md b/assets/chezmoi.io/docs/reference/special-files-and-directories/chezmoiexternal-format.md index af9c2c97f7d..e23a886341f 100644 --- a/assets/chezmoi.io/docs/reference/special-files-and-directories/chezmoiexternal-format.md +++ b/assets/chezmoi.io/docs/reference/special-files-and-directories/chezmoiexternal-format.md @@ -35,6 +35,14 @@ Entries may have the following fields: | `refreshPeriod` | duration | `0` | Refresh period | | `stripComponents` | int | `0` | Number of leading directory components to strip from archives | | `url` | string | *none* | URL | +| `checksum.sha256` | string | *none* | Expected SHA256 checksum of data | +| `checksum.sha384` | string | *none* | Expected SHA384 checksum of data | +| `checksum.sha512` | string | *none* | Expected SHA512 checksum of data | +| `checksum.size` | int | *none* | Expected size of data | + +If any of the optional `checksum.sha256`, `checksum.sha384`, or +`checksum.sha512` fields are set, chezmoi will verify that the downloaded data +has the given checksum. The optional boolean `encrypted` field specifies whether the file or archive is encrypted. diff --git a/pkg/chezmoi/chezmoi.go b/pkg/chezmoi/chezmoi.go index 0bbb8a5c516..8737cbfe42b 100644 --- a/pkg/chezmoi/chezmoi.go +++ b/pkg/chezmoi/chezmoi.go @@ -4,7 +4,10 @@ package chezmoi import ( "bufio" "bytes" + "crypto/md5" //nolint:gosec + "crypto/sha1" //nolint:gosec "crypto/sha256" + "crypto/sha512" "fmt" "io" "io/fs" @@ -17,6 +20,7 @@ import ( "github.com/spf13/cobra" vfs "github.com/twpayne/go-vfs/v4" + "golang.org/x/crypto/ripemd160" //nolint:staticcheck "golang.org/x/exp/constraints" "golang.org/x/exp/maps" "golang.org/x/exp/slices" @@ -295,6 +299,12 @@ func isEmpty(data []byte) bool { return len(bytes.TrimSpace(data)) == 0 } +// md5Sum returns the MD5 sum of data. +func md5Sum(data []byte) []byte { + md5SumArr := md5.Sum(data) //nolint:gosec + return md5SumArr[:] +} + // modeTypeName returns a string representation of mode. func modeTypeName(mode fs.FileMode) string { if name, ok := FileModeTypeNames[mode.Type()]; ok { @@ -321,6 +331,29 @@ func mustTrimSuffix(s, suffix string) string { return s[:len(s)-len(suffix)] } +// ripemd160Sum returns the RIPEMD-160 sum of data. +func ripemd160Sum(data []byte) []byte { + return ripemd160.New().Sum(data) +} + +// sha1Sum returns the SHA1 sum of data. +func sha1Sum(data []byte) []byte { + sha1SumArr := sha1.Sum(data) //nolint:gosec + return sha1SumArr[:] +} + +// sha384Sum returns the SHA384 sum of data. +func sha384Sum(data []byte) []byte { + sha384SumArr := sha512.Sum384(data) + return sha384SumArr[:] +} + +// sha512Sum returns the SHA512 sum of data. +func sha512Sum(data []byte) []byte { + sha512SumArr := sha512.Sum512(data) + return sha512SumArr[:] +} + // sortedKeys returns the keys of V in order. func sortedKeys[K constraints.Ordered, V any](m map[K]V) []K { keys := maps.Keys(m) diff --git a/pkg/chezmoi/sourcestate.go b/pkg/chezmoi/sourcestate.go index 107ea5d85f6..0750536f8d9 100644 --- a/pkg/chezmoi/sourcestate.go +++ b/pkg/chezmoi/sourcestate.go @@ -59,7 +59,16 @@ type External struct { Encrypted bool `json:"encrypted" toml:"encrypted" yaml:"encrypted"` Exact bool `json:"exact" toml:"exact" yaml:"exact"` Executable bool `json:"executable" toml:"executable" yaml:"executable"` - Clone struct { + Checksum struct { + MD5 HexBytes `json:"md5" toml:"md5" yaml:"md5"` + RIPEMD160 HexBytes `json:"ripemd160" toml:"ripemd160" yaml:"ripemd160"` + SHA1 HexBytes `json:"sha1" toml:"sha1" yaml:"sha1"` + SHA256 HexBytes `json:"sha256" toml:"sha256" yaml:"sha256"` + SHA384 HexBytes `json:"sha384" toml:"sha384" yaml:"sha384"` + SHA512 HexBytes `json:"sha512" toml:"sha512" yaml:"sha512"` + Size int `json:"size" toml:"size" yaml:"size"` + } `json:"checksum" toml:"checksum" yaml:"checksum"` + Clone struct { Args []string `json:"args" toml:"args" yaml:"args"` } `json:"clone" toml:"clone" yaml:"clone"` Exclude []string `json:"exclude" toml:"exclude" yaml:"exclude"` @@ -1371,6 +1380,59 @@ func (s *SourceState) getExternalData( return nil, err } + if external.Checksum.Size != 0 { + if len(data) != external.Checksum.Size { + err = multierr.Append(err, fmt.Errorf("size mismatch: expected %d, got %d", + external.Checksum.Size, len(data))) + } + } + + if external.Checksum.MD5 != nil { + if gotMD5Sum := md5Sum(data); !bytes.Equal(gotMD5Sum, external.Checksum.MD5) { + err = multierr.Append(err, fmt.Errorf("MD5 mismatch: expected %s, got %s", + external.Checksum.MD5, hex.EncodeToString(gotMD5Sum))) + } + } + + if external.Checksum.RIPEMD160 != nil { + if gotRIPEMD160Sum := ripemd160Sum(data); !bytes.Equal(gotRIPEMD160Sum, external.Checksum.RIPEMD160) { + err = multierr.Append(err, fmt.Errorf("RIPEMD-160 mismatch: expected %s, got %s", + external.Checksum.RIPEMD160, hex.EncodeToString(gotRIPEMD160Sum))) + } + } + + if external.Checksum.SHA1 != nil { + if gotSHA1Sum := sha1Sum(data); !bytes.Equal(gotSHA1Sum, external.Checksum.SHA1) { + err = multierr.Append(err, fmt.Errorf("SHA1 mismatch: expected %s, got %s", + external.Checksum.SHA1, hex.EncodeToString(gotSHA1Sum))) + } + } + + if external.Checksum.SHA256 != nil { + if gotSHA256Sum := SHA256Sum(data); !bytes.Equal(gotSHA256Sum, external.Checksum.SHA256) { + err = multierr.Append(err, fmt.Errorf("SHA256 mismatch: expected %s, got %s", + external.Checksum.SHA256, hex.EncodeToString(gotSHA256Sum))) + } + } + + if external.Checksum.SHA384 != nil { + if gotSHA384Sum := sha384Sum(data); !bytes.Equal(gotSHA384Sum, external.Checksum.SHA384) { + err = multierr.Append(err, fmt.Errorf("SHA384 mismatch: expected %s, got %s", + external.Checksum.SHA384, hex.EncodeToString(gotSHA384Sum))) + } + } + + if external.Checksum.SHA512 != nil { + if gotSHA512Sum := sha512Sum(data); !bytes.Equal(gotSHA512Sum, external.Checksum.SHA512) { + err = multierr.Append(err, fmt.Errorf("SHA512 mismatch: expected %s, got %s", + external.Checksum.SHA512, hex.EncodeToString(gotSHA512Sum))) + } + } + + if err != nil { + return nil, fmt.Errorf("%s: %w", externalRelPath, err) + } + if external.Encrypted { data, err = s.encryption.Decrypt(data) if err != nil { diff --git a/pkg/cmd/testdata/scripts/external.txtar b/pkg/cmd/testdata/scripts/external.txtar index f84b8ad655a..7b75fef9203 100644 --- a/pkg/cmd/testdata/scripts/external.txtar +++ b/pkg/cmd/testdata/scripts/external.txtar @@ -84,6 +84,19 @@ chhome home9/user # test that duplicate equivalent directories are allowed exec chezmoi apply --force +chhome home10/user + +# test that checksums are verified +exec chezmoi apply --force +cp $HOME/.file golden/.file + +chhome home11/user + +# test that checksums detect corrupt files +! exec chezmoi apply --force +stderr 'MD5 mismatch' +stderr 'SHA256 mismatch' + -- archive/dir/file -- # contents of dir/file -- golden/.file -- @@ -99,6 +112,24 @@ exec chezmoi apply --force [".file"] type = "file" url = "{{ env "HTTPD_URL" }}/.file" +-- home10/user/.local/share/chezmoi/.chezmoiexternal.yaml -- +.file: + type: file + url: {{ env "HTTPD_URL" }}/.file + checksum: + size: 20 + md5: 49fe9018f97349cdd0a0ac7b7f668b05 + ripemd160: 2320636f6e74656e7473206f66202e66696c650a9c1185a5c5e9fc54612808977ee8f548b2258d31 + sha1: cb91d72dc73f6d984b33ac5745f1cf6f76745bd2 + sha256: 634a4dd193c7b3b926d2e08026aa81a416fd41cec52854863b974af422495663 + sha384: f8545bb66433eb514727bbc61c4e4939c436d38079767f39f12b8803d6472ca1dfcd101675b20cd525f7e3d02c368b61 + sha512: a68814ec3d16e8bd28c9291bbc596f0282687c5ba5d1f4c26c4e427166666a03c11df1dab3577b4483142764c37d4887def77244c4a52cb9852a234fa8cb15ba +-- home11/user/.local/share/chezmoi/.chezmoiexternal.toml -- +[".file"] + type = "file" + url = "{{ env "HTTPD_URL" }}/.corrupt-file" + checksum.md5 = "49fe9018f97349cdd0a0ac7b7f668b05" + checksum.sha256 = "634a4dd193c7b3b926d2e08026aa81a416fd41cec52854863b974af422495663" -- home2/user/.local/share/chezmoi/.chezmoiexternal.toml -- [".file"] type = "file" @@ -157,5 +188,7 @@ subdir: stripComponents = 1 -- home9/user/.local/share/chezmoi/dot_dir/file2 -- # contents of .dir/file2 +-- www/.corrupt-file -- +# corrupt contents of .file -- www/.file -- # contents of .file
feat
Add verification of external checksums
42d5f1a932f1b6735d8b32fae53f053b88b60a5d
2024-09-24 00:04:27
Tom Payne
chore: Update dependencies
false
diff --git a/go.mod b/go.mod index 0aed2c6e607..7813f86ae0d 100644 --- a/go.mod +++ b/go.mod @@ -11,9 +11,9 @@ require ( github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 github.com/Shopify/ejson v1.5.2 github.com/alecthomas/assert/v2 v2.11.0 - github.com/aws/aws-sdk-go-v2 v1.30.5 - github.com/aws/aws-sdk-go-v2/config v1.27.35 - github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.32.9 + github.com/aws/aws-sdk-go-v2 v1.31.0 + github.com/aws/aws-sdk-go-v2/config v1.27.36 + github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.33.0 github.com/bmatcuk/doublestar/v4 v4.6.1 github.com/bradenhilton/mozillainstallhash v1.0.1 github.com/charmbracelet/bubbles v0.20.0 @@ -26,13 +26,13 @@ require ( github.com/google/renameio/v2 v2.0.0 github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 github.com/itchyny/gojq v0.12.16 - github.com/klauspost/compress v1.17.9 + github.com/klauspost/compress v1.17.10 github.com/mitchellh/copystructure v1.2.0 github.com/mitchellh/mapstructure v1.5.0 github.com/muesli/combinator v0.3.0 github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a github.com/pelletier/go-toml/v2 v2.2.3 - github.com/rogpeppe/go-internal v1.12.0 + github.com/rogpeppe/go-internal v1.13.1 github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 @@ -45,7 +45,7 @@ require ( github.com/zalando/go-keyring v0.2.5 github.com/zricethezav/gitleaks/v8 v8.19.2 go.etcd.io/bbolt v1.3.11 - go.uber.org/automaxprocs v1.5.3 + go.uber.org/automaxprocs v1.6.0 golang.org/x/crypto v0.27.0 golang.org/x/crypto/x509roots/fallback v0.0.0-20240916204253-42ee18b96377 golang.org/x/oauth2 v0.23.0 @@ -73,17 +73,17 @@ require ( github.com/alecthomas/repr v0.4.0 // indirect github.com/alessio/shellescape v1.4.2 // indirect github.com/atotto/clipboard v0.1.4 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.33 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.13 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.17 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.17 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.17.34 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.4 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.19 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.22.8 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.8 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.30.8 // indirect - github.com/aws/smithy-go v1.20.4 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.23.0 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.0 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.31.0 // indirect + github.com/aws/smithy-go v1.21.0 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/bradenhilton/cityhash v1.0.0 // indirect diff --git a/go.sum b/go.sum index bb91e43b082..48580d73cf5 100644 --- a/go.sum +++ b/go.sum @@ -67,34 +67,34 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= -github.com/aws/aws-sdk-go-v2 v1.30.5 h1:mWSRTwQAb0aLE17dSzztCVJWI9+cRMgqebndjwDyK0g= -github.com/aws/aws-sdk-go-v2 v1.30.5/go.mod h1:CT+ZPWXbYrci8chcARI3OmI/qgd+f6WtuLOoaIA8PR0= -github.com/aws/aws-sdk-go-v2/config v1.27.35 h1:jeFgiWYNV0vrgdZqB4kZBjYNdy0IKkwrAjr2fwpHIig= -github.com/aws/aws-sdk-go-v2/config v1.27.35/go.mod h1:qnpEvTq8ZfjrCqmJGRfWZuF+lGZ/vG8LK2K0L/TY1gQ= -github.com/aws/aws-sdk-go-v2/credentials v1.17.33 h1:lBHAQQznENv0gLHAZ73ONiTSkCtr8q3pSqWrpbBBZz0= -github.com/aws/aws-sdk-go-v2/credentials v1.17.33/go.mod h1:MBuqCUOT3ChfLuxNDGyra67eskx7ge9e3YKYBce7wpI= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.13 h1:pfQ2sqNpMVK6xz2RbqLEL0GH87JOwSxPV2rzm8Zsb74= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.13/go.mod h1:NG7RXPUlqfsCLLFfi0+IpKN4sCB9D9fw/qTaSB+xRoU= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.17 h1:pI7Bzt0BJtYA0N/JEC6B8fJ4RBrEMi1LBrkMdFYNSnQ= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.17/go.mod h1:Dh5zzJYMtxfIjYW+/evjQ8uj2OyR/ve2KROHGHlSFqE= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.17 h1:Mqr/V5gvrhA2gvgnF42Zh5iMiQNcOYthFYwCyrnuWlc= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.17/go.mod h1:aLJpZlCmjE+V+KtN1q1uyZkfnUWpQGpbsn89XPKyzfU= +github.com/aws/aws-sdk-go-v2 v1.31.0 h1:3V05LbxTSItI5kUqNwhJrrrY1BAXxXt0sN0l72QmG5U= +github.com/aws/aws-sdk-go-v2 v1.31.0/go.mod h1:ztolYtaEUtdpf9Wftr31CJfLVjOnD/CVRkKOOYgF8hA= +github.com/aws/aws-sdk-go-v2/config v1.27.36 h1:4IlvHh6Olc7+61O1ktesh0jOcqmq/4WG6C2Aj5SKXy0= +github.com/aws/aws-sdk-go-v2/config v1.27.36/go.mod h1:IiBpC0HPAGq9Le0Xxb1wpAKzEfAQ3XlYgJLYKEVYcfw= +github.com/aws/aws-sdk-go-v2/credentials v1.17.34 h1:gmkk1l/cDGSowPRzkdxYi8edw+gN4HmVK151D/pqGNc= +github.com/aws/aws-sdk-go-v2/credentials v1.17.34/go.mod h1:4R9OEV3tgFMsok4ZeFpExn7zQaZRa9MRGFYnI/xC/vs= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14 h1:C/d03NAmh8C4BZXhuRNboF/DqhBkBCeDiJDcaqIT5pA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14/go.mod h1:7I0Ju7p9mCIdlrfS+JCgqcYD0VXz/N4yozsox+0o078= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18 h1:kYQ3H1u0ANr9KEKlGs/jTLrBFPo8P8NaH/w7A01NeeM= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18/go.mod h1:r506HmK5JDUh9+Mw4CfGJGSSoqIiLCndAuqXuhbv67Y= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18 h1:Z7IdFUONvTcvS7YuhtVxN99v2cCoHRXOS4mTr0B/pUc= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18/go.mod h1:DkKMmksZVVyat+Y+r1dEOgJEfUeA7UngIHWeKsi0yNc= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.4 h1:KypMCbLPPHEmf9DgMGw51jMj77VfGPAN2Kv4cfhlfgI= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.4/go.mod h1:Vz1JQXliGcQktFTN/LN6uGppAIRoLBR2bMvIMP0gOjc= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.19 h1:rfprUlsdzgl7ZL2KlXiUAoJnI/VxfHCvDFr2QDFj6u4= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.19/go.mod h1:SCWkEdRq8/7EK60NcvvQ6NXKuTcchAD4ROAsC37VEZE= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.32.9 h1:croIrE67fpV6wff+0M8jbrJZpKSlrqVGrCnqNU5rtoI= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.32.9/go.mod h1:BYr9P/rrcLNJ8A36nT15p8tpoVDZ5lroHuMn/njecBw= -github.com/aws/aws-sdk-go-v2/service/sso v1.22.8 h1:JRwuL+S1Qe1owZQoxblV7ORgRf2o0SrtzDVIbaVCdQ0= -github.com/aws/aws-sdk-go-v2/service/sso v1.22.8/go.mod h1:eEygMHnTKH/3kNp9Jr1n3PdejuSNcgwLe1dWgQtO0VQ= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.8 h1:+HpGETD9463PFSj7lX5+eq7aLDs85QUIA+NBkeAsscA= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.8/go.mod h1:bCbAxKDqNvkHxRaIMnyVPXPo+OaPRwvmgzMxbz1VKSA= -github.com/aws/aws-sdk-go-v2/service/sts v1.30.8 h1:bAi+4p5EKnni+jrfcAhb7iHFQ24bthOAV9t0taf3DCE= -github.com/aws/aws-sdk-go-v2/service/sts v1.30.8/go.mod h1:NXi1dIAGteSaRLqYgarlhP/Ij0cFT+qmCwiJqWh/U5o= -github.com/aws/smithy-go v1.20.4 h1:2HK1zBdPgRbjFOHlfeQZfpC4r72MOb9bZkiFwggKO+4= -github.com/aws/smithy-go v1.20.4/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5 h1:QFASJGfT8wMXtuP3D5CRmMjARHv9ZmzFUMJznHDOY3w= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5/go.mod h1:QdZ3OmoIjSX+8D1OPAzPxDfjXASbBMDsz9qvtyIhtik= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20 h1:Xbwbmk44URTiHNx6PNo0ujDE6ERlsCKJD3u1zfnzAPg= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20/go.mod h1:oAfOFzUB14ltPZj1rWwRc3d/6OgD76R8KlvU3EqM9Fg= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.33.0 h1:r+37fBAonXAmRx2MX0naWDKZpAaP2AOQ22cf9Cg71GA= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.33.0/go.mod h1:WyLS5qwXHtjKAONYZq/4ewdd+hcVsa3LBu77Ow5uj3k= +github.com/aws/aws-sdk-go-v2/service/sso v1.23.0 h1:fHySkG0IGj2nepgGJPmmhZYL9ndnsq1Tvc6MeuVQCaQ= +github.com/aws/aws-sdk-go-v2/service/sso v1.23.0/go.mod h1:XRlMvmad0ZNL+75C5FYdMvbbLkd6qiqz6foR1nA1PXY= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.0 h1:cU/OeQPNReyMj1JEBgjE29aclYZYtXcsPMXbTkVGMFk= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.0/go.mod h1:FnvDM4sfa+isJ3kDXIzAB9GAwVSzFzSy97uZ3IsHo4E= +github.com/aws/aws-sdk-go-v2/service/sts v1.31.0 h1:GNVxIHBTi2EgwCxpNiozhNasMOK+ROUA2Z3X+cSBX58= +github.com/aws/aws-sdk-go-v2/service/sts v1.31.0/go.mod h1:yMWe0F+XG0DkRZK5ODZhG7BEFYhLXi2dqGsv6tX0cgI= +github.com/aws/smithy-go v1.21.0 h1:H7L8dtDRk0P1Qm6y0ji7MCYMQObJ5R9CRpyPhRUkLYA= +github.com/aws/smithy-go v1.21.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= @@ -276,8 +276,8 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0= +github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -366,8 +366,8 @@ github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= @@ -475,8 +475,8 @@ go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8= -go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0= +go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= +go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
chore
Update dependencies
3a0b19e8ce5e093ab75cb3caeb52a6be8f6f1ade
2024-03-03 20:00:28
Tom Payne
fix: Add missing newlines in error messages
false
diff --git a/internal/cmd/purgecmd.go b/internal/cmd/purgecmd.go index baaf5202d8f..69f9cb8f637 100644 --- a/internal/cmd/purgecmd.go +++ b/internal/cmd/purgecmd.go @@ -92,7 +92,7 @@ func (c *Config) doPurge(options *doPurgeOptions) error { case runtime.GOOS == "windows": // On Windows the binary of a running process cannot be removed. // Warn the user, but otherwise continue. - c.errorf("cannot purge binary (%s) on Windows", executable) + c.errorf("cannot purge binary (%s) on Windows\n", executable) case strings.Contains(executable, "test"): // Special case: do not purge the binary if it is a test binary created // by go test as this will break later or concurrent tests. diff --git a/internal/cmd/unmanagedcmd.go b/internal/cmd/unmanagedcmd.go index 152ef4369d7..fa59e2864b7 100644 --- a/internal/cmd/unmanagedcmd.go +++ b/internal/cmd/unmanagedcmd.go @@ -54,7 +54,7 @@ func (c *Config) runUnmanagedCmd(cmd *cobra.Command, args []string, sourceState unmanagedRelPaths := make(map[chezmoi.RelPath]struct{}) walkFunc := func(destAbsPath chezmoi.AbsPath, fileInfo fs.FileInfo, err error) error { if err != nil { - c.errorf("%s: %v", destAbsPath, err) + c.errorf("%s: %v\n", destAbsPath, err) if fileInfo == nil || fileInfo.IsDir() { return fs.SkipDir }
fix
Add missing newlines in error messages
f80904a2cb89a50065bfdca6d00dd41ce08fb465
2022-11-23 04:56:28
Tom Payne
chore: Fix mips64le apk download links
false
diff --git a/assets/chezmoi.io/docs/install.md.tmpl b/assets/chezmoi.io/docs/install.md.tmpl index 7d215270838..0ba3a43a8ea 100644 --- a/assets/chezmoi.io/docs/install.md.tmpl +++ b/assets/chezmoi.io/docs/install.md.tmpl @@ -182,7 +182,7 @@ Download a package for your distribution and architecture. === "apk" -{{ range $arch := list "386" "amd64" "arm" "arm64" "loong64" "mips64" "mips64le" "ppc64" "ppc64le" "riscv64" "s390x" }} +{{ range $arch := list "386" "amd64" "arm" "arm64" "loong64" "mips64_hardfloat" "mips64le_hardfloat" "ppc64" "ppc64le" "riscv64" "s390x" }} [`{{ $arch }}`](https://github.com/twpayne/chezmoi/releases/download/v{{ $version }}/chezmoi_{{ $version }}_linux_{{ $arch }}.apk) {{- end }}
chore
Fix mips64le apk download links
7f6309734a6cefb663a789583a3f4775b4923af2
2023-01-17 05:00:31
Tom Payne
feat: Add --recursive flag to chattr command
false
diff --git a/pkg/cmd/chattrcmd.go b/pkg/cmd/chattrcmd.go index 2bed703a79d..15330774401 100644 --- a/pkg/cmd/chattrcmd.go +++ b/pkg/cmd/chattrcmd.go @@ -10,6 +10,10 @@ import ( "github.com/twpayne/chezmoi/v2/pkg/chezmoi" ) +type chattrCmdConfig struct { + recursive bool +} + type boolModifier int const ( @@ -81,6 +85,9 @@ func (c *Config) newChattrCmd() *cobra.Command { ), } + flags := chattrCmd.Flags() + flags.BoolVarP(&c.chattr.recursive, "recursive", "r", c.chattr.recursive, "Recurse into subdirectories") + return chattrCmd } @@ -144,6 +151,7 @@ func (c *Config) runChattrCmd(cmd *cobra.Command, args []string, sourceState *ch targetRelPaths, err := c.targetRelPaths(sourceState, args[1:], targetRelPathsOptions{ mustBeInSourceState: true, + recursive: c.chattr.recursive, }) if err != nil { return err @@ -151,7 +159,7 @@ func (c *Config) runChattrCmd(cmd *cobra.Command, args []string, sourceState *ch // Sort targets in reverse so we update children before their parent // directories. - sort.Sort(targetRelPaths) + sort.Sort(sort.Reverse(targetRelPaths)) encryptedSuffix := sourceState.Encryption().EncryptedSuffix() for _, targetRelPath := range targetRelPaths { diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index 60ca735d5e6..1944461d204 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -157,6 +157,7 @@ type Config struct { // Command configurations, not settable in the config file. apply applyCmdConfig archive archiveCmdConfig + chattr chattrCmdConfig dump dumpCmdConfig executeTemplate executeTemplateCmdConfig _import importCmdConfig diff --git a/pkg/cmd/testdata/scripts/chattr.txtar b/pkg/cmd/testdata/scripts/chattr.txtar index 9d427db106f..48fa9840388 100644 --- a/pkg/cmd/testdata/scripts/chattr.txtar +++ b/pkg/cmd/testdata/scripts/chattr.txtar @@ -128,6 +128,13 @@ exists $CHEZMOISOURCEDIR/modify_private_readonly_executable_dot_modify.tmpl exec chezmoi chattr --dry-run --verbose +executable $HOME${/}.file cmp stdout golden/chattr-diff +# test that chezmoi chattr --recursive noexact recurses into subdirectories +exists $CHEZMOISOURCEDIR/exact_readonly_dot_dir +exists $CHEZMOISOURCEDIR/exact_readonly_dot_dir/exact_subdir +exec chezmoi chattr --recursive noexact $HOME${/}.dir +exists $CHEZMOISOURCEDIR/readonly_dot_dir +exists $CHEZMOISOURCEDIR/readonly_dot_dir/subdir + -- golden/chattr-diff -- diff --git a/dot_file b/executable_dot_file rename from dot_file
feat
Add --recursive flag to chattr command
074899d69d87cf56809ecfe7c18c667c510a99a4
2022-07-08 23:29:22
Tom Payne
feat: Allow dashes in keys in template data in config file
false
diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index 2b5d89bb717..82b068cf127 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -213,7 +213,6 @@ var ( Suffix: ".asc", } - identifierRx = regexp.MustCompile(`\A[\pL_][\pL\p{Nd}_]*\z`) whitespaceRx = regexp.MustCompile(`\s+`) viperDecodeConfigOptions = []viper.DecoderConfigOption{ @@ -1832,7 +1831,7 @@ func (c *Config) readConfig() error { if err := viper.Unmarshal(&c.ConfigFile, viperDecodeConfigOptions...); err != nil { return err } - return c.validateData() + return nil } // readLine reads a line from stdin, trimming leading and trailing whitespace. @@ -2138,11 +2137,6 @@ func (c *Config) useBuiltinGitAutoFunc() bool { return true } -// validateData valides that the config data does not contain any invalid keys. -func (c *Config) validateData() error { - return validateKeys(c.Data, identifierRx) -} - // writeOutput writes data to the configured output. func (c *Config) writeOutput(data []byte) error { if c.outputAbsPath.Empty() || c.outputAbsPath == chezmoi.NewAbsPath("-") { diff --git a/pkg/cmd/config_test.go b/pkg/cmd/config_test.go index 3e73ef7e614..3c73ff894dc 100644 --- a/pkg/cmd/config_test.go +++ b/pkg/cmd/config_test.go @@ -156,58 +156,6 @@ func TestUpperSnakeCaseToCamelCase(t *testing.T) { } } -func TestValidateKeys(t *testing.T) { - for _, tc := range []struct { - data interface{} - expectedErr bool - }{ - { - data: nil, - expectedErr: false, - }, - { - data: map[string]interface{}{ - "foo": "bar", - "a": 0, - "_x9": false, - "ThisVariableIsExported": nil, - "αβ": "", - }, - expectedErr: false, - }, - { - data: map[string]interface{}{ - "foo-foo": "bar", - }, - expectedErr: true, - }, - { - data: map[string]interface{}{ - "foo": map[string]interface{}{ - "bar-bar": "baz", - }, - }, - expectedErr: true, - }, - { - data: map[string]interface{}{ - "foo": []interface{}{ - map[string]interface{}{ - "bar-bar": "baz", - }, - }, - }, - expectedErr: true, - }, - } { - if tc.expectedErr { - assert.Error(t, validateKeys(tc.data, identifierRx)) - } else { - assert.NoError(t, validateKeys(tc.data, identifierRx)) - } - } -} - func newTestConfig(t *testing.T, fileSystem vfs.FS, options ...configOption) *Config { t.Helper() system := chezmoi.NewRealSystem(fileSystem) diff --git a/pkg/cmd/util.go b/pkg/cmd/util.go index 08f228418bf..551cf71105b 100644 --- a/pkg/cmd/util.go +++ b/pkg/cmd/util.go @@ -1,8 +1,6 @@ package cmd import ( - "fmt" - "regexp" "strconv" "strings" "unicode" @@ -147,25 +145,3 @@ func upperSnakeCaseToCamelCaseMap(m map[string]interface{}) map[string]interface } return result } - -// validateKeys ensures that all keys in data match re. -func validateKeys(data interface{}, re *regexp.Regexp) error { - switch data := data.(type) { - case map[string]interface{}: - for key, value := range data { - if !re.MatchString(key) { - return fmt.Errorf("%s: invalid key", key) - } - if err := validateKeys(value, re); err != nil { - return err - } - } - case []interface{}: - for _, value := range data { - if err := validateKeys(value, re); err != nil { - return err - } - } - } - return nil -}
feat
Allow dashes in keys in template data in config file
4d47c70d90eaa0d759d66bc297352a370518e5c3
2021-11-11 02:33:49
Tom Payne
chore: Run full CI when Makefile changes
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f24da899c44..912a1d09785 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,7 @@ jobs: code: - '**/*.go' - '.github/workflows/**' - - 'go.*' + - 'Makefile' - 'assets/docker/**' - 'assets/vagrant/**' - 'internal/**'
chore
Run full CI when Makefile changes
fca55180573e2f287589287b539843cd7c1107dd
2022-06-05 03:17:05
Lue
chore: Revert nonstandard usage of install -t
false
diff --git a/assets/scripts/install.sh b/assets/scripts/install.sh index 70b7c1732a5..06c60bffc13 100644 --- a/assets/scripts/install.sh +++ b/assets/scripts/install.sh @@ -93,7 +93,7 @@ main() { install -d "${BINDIR}" fi BINARY="chezmoi${BINSUFFIX}" - install -t "${BINDIR}/" "${tmpdir}/${BINARY}" + install -- "${tmpdir}/${BINARY}" "${BINDIR}/" log_info "installed ${BINDIR}/${BINARY}" if [ -n "${1+n}" ]; then diff --git a/internal/cmds/generate-install.sh/install.sh.tmpl b/internal/cmds/generate-install.sh/install.sh.tmpl index f8532c1c73c..3bb1b98cd0c 100644 --- a/internal/cmds/generate-install.sh/install.sh.tmpl +++ b/internal/cmds/generate-install.sh/install.sh.tmpl @@ -93,7 +93,7 @@ main() { install -d "${BINDIR}" fi BINARY="chezmoi${BINSUFFIX}" - install -t "${BINDIR}/" "${tmpdir}/${BINARY}" + install -- "${tmpdir}/${BINARY}" "${BINDIR}/" log_info "installed ${BINDIR}/${BINARY}" if [ -n "${1+n}" ]; then
chore
Revert nonstandard usage of install -t
5c48afa7cc2cb1f1bd180207c95575fa6be42748
2023-01-31 01:10:48
dependabot[bot]
chore(deps): bump ludeeus/action-shellcheck from 1.1.0 to 2.0.0
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 800e4cb15c4..50e75cdc65f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -348,7 +348,7 @@ jobs: run: | go generate git diff --exit-code - - uses: ludeeus/action-shellcheck@94e0aab03ca135d11a35e5bfc14e6746dc56e7e9 + - uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 with: ignore: completions - name: lint-whitespace
chore
bump ludeeus/action-shellcheck from 1.1.0 to 2.0.0
7a4021bd498f7cb80e622d9f947e8c273a1fdd6b
2025-02-24 03:43:10
Jon Kinney
docs: Reference templates in password managers
false
diff --git a/assets/chezmoi.io/docs/user-guide/password-managers/index.md b/assets/chezmoi.io/docs/user-guide/password-managers/index.md index a756ba8a73b..0c1fb437ac0 100644 --- a/assets/chezmoi.io/docs/user-guide/password-managers/index.md +++ b/assets/chezmoi.io/docs/user-guide/password-managers/index.md @@ -1,6 +1,32 @@ -# Password manager integration +# Password Manager Integration -Template functions allow you to retrieve secrets from many popular password -managers. Using a password manager allows you to keep all your secrets in one -place, make your dotfiles repo public, and synchronize changes to secrets -across multiple machines. +Using a password manager with chezmoi enables you to maintain a public dotfiles +repository while keeping your secrets secure. chezmoi extends its [templating +capabilities][templating] by providing password manager specific *template +functions* for many popular password managers. + +When chezmoi applies a template with a secret referenced from a password +manager, it will automatically fetch the secret value and insert it into the +generated destination file. + +!!! example + + Here's a practical example of a `.zshrc.tmpl` file that retrieves an + CloudFlare API token from 1Password while maintaining other standard shell + configurations: + + ```zsh + # set up $PATH + # … + + # Cloudflare API Token retrieved from 1Password for use with flarectl + export CF_API_TOKEN='{{ onepasswordRead "op://Personal/cloudlfare-api-token/password" }}' + + # set up aliases and useful functions + ``` + + In this example, the `CF_API_TOKEN` is retrieved from a 1Password vault + named `Personal`, an item called `cloudflare-api-token`, and the `password` + field. + +[templating]: /user-guide/templating.md
docs
Reference templates in password managers
4569bf86f115aa0462bb1c1bfcdada5d5a050535
2022-10-18 01:52:24
dependabot[bot]
chore(deps): bump sigstore/cosign-installer from 2.7.0 to 2.8.0
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3cbd040e4ad..ae4f42f2fb5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -396,7 +396,7 @@ jobs: with: cache: true go-version: ${{ env.GO_VERSION }} - - uses: sigstore/cosign-installer@ced07f21fb1da67979f539bbc6304c16c0677e76 + - uses: sigstore/cosign-installer@7cc35d7fdbe70d4278a0c96779081e6fac665f88 - uses: goreleaser/goreleaser-action@ff11ca24a9b39f2d36796d1fbd7a4e39c182630a with: version: latest
chore
bump sigstore/cosign-installer from 2.7.0 to 2.8.0
0a19cd7292713af9e7a4b7adf4df415a67d0b381
2021-12-24 21:57:21
Tom Payne
chore: Update gpg integration tests for GnuPG 2.3.4
false
diff --git a/internal/chezmoitest/chezmoitest.go b/internal/chezmoitest/chezmoitest.go index 0b7c528c262..bb590f9e701 100644 --- a/internal/chezmoitest/chezmoitest.go +++ b/internal/chezmoitest/chezmoitest.go @@ -18,10 +18,7 @@ import ( "github.com/twpayne/chezmoi/v2/internal/chezmoilog" ) -var ( - ageRecipientRx = regexp.MustCompile(`(?m)^Public key: ([0-9a-z]+)\s*$`) - gpgKeyMarkedAsUltimatelyTrustedRx = regexp.MustCompile(`(?m)^gpg: key ([0-9A-F]+) marked as ultimately trusted\s*$`) -) +var ageRecipientRx = regexp.MustCompile(`(?m)^Public key: ([0-9a-z]+)\s*$`) // AgeGenerateKey generates an identity in identityFile and returns the // recipient. @@ -41,6 +38,7 @@ func AgeGenerateKey(identityFile string) (string, error) { // GPGGenerateKey generates GPG key in homeDir and returns the key and the // passphrase. func GPGGenerateKey(command, homeDir string) (key, passphrase string, err error) { + key = "chezmoi-test-gpg-key" //nolint:gosec passphrase = "chezmoi-test-gpg-passphrase" cmd := exec.Command( @@ -50,17 +48,10 @@ func GPGGenerateKey(command, homeDir string) (key, passphrase string, err error) "--no-tty", "--passphrase", passphrase, "--pinentry-mode", "loopback", - "--quick-generate-key", "chezmoi-test-gpg-key", + "--quick-generate-key", key, ) - output, err := chezmoilog.LogCmdCombinedOutput(cmd) - if err != nil { - return "", "", err - } - submatch := gpgKeyMarkedAsUltimatelyTrustedRx.FindSubmatch(output) - if submatch == nil { - return "", "", fmt.Errorf("key not found in %q", output) - } - return string(submatch[1]), passphrase, nil + err = chezmoilog.LogCmdRun(cmd) + return } // HomeDir returns the home directory.
chore
Update gpg integration tests for GnuPG 2.3.4
e8ed4c4622e0a84b119557f90fae892c74bdb448
2023-11-10 23:04:33
Oleh Prypin
refactor: Allow `mkdocs build` from any origin
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8ca8746870b..ea0c9f2433d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -257,7 +257,7 @@ jobs: pip3 install mkdocs==${{ env.MKDOCS_VERSION }} pip3 install -r assets/chezmoi.io/requirements.txt - name: build-website - run: ( cd assets/chezmoi.io && mkdocs build ) + run: mkdocs build -f assets/chezmoi.io/mkdocs.yml env: CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} test-windows: @@ -410,7 +410,7 @@ jobs: run: | pip3 install mkdocs==${{ env.MKDOCS_VERSION }} pip3 install -r assets/chezmoi.io/requirements.txt - ( cd assets/chezmoi.io && mkdocs build ) + mkdocs build -f assets/chezmoi.io/mkdocs.yml env: CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} - name: push-chezmoi.io diff --git a/assets/chezmoi.io/docs/hooks.py b/assets/chezmoi.io/docs/hooks.py index d8a32657e27..30d7ab40ce3 100644 --- a/assets/chezmoi.io/docs/hooks.py +++ b/assets/chezmoi.io/docs/hooks.py @@ -22,12 +22,13 @@ def on_pre_build(config, **kwargs): - docs_dir = PurePosixPath(config['docs_dir']) + config_dir = Path(config.config_file_path).parent + docs_dir = PurePosixPath(config.docs_dir) for src_path in templates: output_path = docs_dir.joinpath(src_path) template_path = output_path.parent / (output_path.name + '.tmpl') data_path = output_path.parent / (output_path.name + '.yaml') - args = ['go', 'run', '../../internal/cmds/execute-template'] + args = ['go', 'run', Path(config_dir, '../../internal/cmds/execute-template')] if Path(data_path).exists(): args.extend(['-data', data_path]) args.extend(['-output', output_path, template_path]) @@ -50,15 +51,16 @@ def on_files(files, config, **kwargs): def on_post_build(config, **kwargs): - site_dir = config['site_dir'] + config_dir = Path(config.config_file_path).parent + site_dir = config.site_dir # copy GitHub pages config - utils.copy_file('CNAME', Path(site_dir, 'CNAME')) + utils.copy_file(Path(config_dir, 'CNAME'), Path(site_dir, 'CNAME')) # copy installation scripts - utils.copy_file('../scripts/install.sh', Path(site_dir, 'get')) - utils.copy_file('../scripts/install-local-bin.sh', Path(site_dir, 'getlb')) - utils.copy_file('../scripts/install.ps1', Path(site_dir, 'get.ps1')) + utils.copy_file(Path(config_dir, '../scripts/install.sh'), Path(site_dir, 'get')) + utils.copy_file(Path(config_dir, '../scripts/install-local-bin.sh'), Path(site_dir, 'getlb')) + utils.copy_file(Path(config_dir, '../scripts/install.ps1'), Path(site_dir, 'get.ps1')) # copy cosign.pub - utils.copy_file('../cosign/cosign.pub', Path(site_dir, 'cosign.pub')) + utils.copy_file(Path(config_dir, '../cosign/cosign.pub'), Path(site_dir, 'cosign.pub'))
refactor
Allow `mkdocs build` from any origin
c189d22f8a6ccd6006ee2e5c3c64ac7f01d069e8
2021-10-02 19:32:37
Tom Payne
docs: Improve docs on externals
false
diff --git a/docs/HOWTO.md b/docs/HOWTO.md index 8339b9a4087..d276b3141f5 100644 --- a/docs/HOWTO.md +++ b/docs/HOWTO.md @@ -18,6 +18,7 @@ * [Configure VIM to run `chezmoi apply` whenever you save a dotfile](#configure-vim-to-run-chezmoi-apply-whenever-you-save-a-dotfile) * [Include dotfiles from elsewhere](#include-dotfiles-from-elsewhere) * [Include a subdirectory from another repository, like Oh My Zsh](#include-a-subdirectory-from-another-repository-like-oh-my-zsh) + * [Include a single file from another repository](#include-a-single-file-from-another-repository) * [Handle configuration files which are externally modified](#handle-configuration-files-which-are-externally-modified) * [Import archives](#import-archives) * [Manage machine-to-machine differences](#manage-machine-to-machine-differences) @@ -424,6 +425,25 @@ update Oh My Zsh and its plugins, refresh the downloaded archives. --- +### Include a single file from another repository + +Including single files uses the same mechanism as including a subdirectory +above, except with the external type `file` instead of `archive`. For example, +to include +[`plug.vim`](https://github.com/junegunn/vim-plug/blob/master/plug.vim) from +[`github.com/junegunn/vim-plug`](https://github.com/junegunn/vim-plug) in +`~/.vim/autoload/plug.vim` put the following in +`~/.local/share/chezmoi/.chezmoiexternals.toml`: + +```toml +[".vim/autoload/plug.vim"] + type = "file" + url = "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" + refreshPeriod = "1w" +``` + +--- + ### Handle configuration files which are externally modified Some programs modify their configuration files. When you next run `chezmoi diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index c146e5327e9..c4460823af8 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -700,6 +700,21 @@ Entries are indexed by target name relative to the directory of the must be defined in the source state. chezmoi will not create parent directories automatically. +Entries may have the following fields: + +| Variable | Type | Default value | Description | +| ----------------- | -------- | ------------- | ------------------------------------------------------------- | +| `type` | string | *none* | External type (`file` or `archive`) | +| `encrypted` | bool | `false` | Whether the external is encrypted | +| `exact` | bool | `false` | Add `exact_` attribute to directories in archive | +| `executable` | bool | `false` | Add `executable_` attribute to file | +| `filter.command` | string | *none* | Command to filter contents | +| `filter.args` | []string | *none* | Extra args to command to filter contents | +| `format` | string | *autodetect* | Format of archive | +| `refreshPeriod` | duration | `0` | Refresh period | +| `stripComponents` | int | `0` | Number of leading directory components to strip from archives | +| `url` | string | *none* | URL | + The optional boolean `encrypted` field specifies whether the file or archive is encrypted.
docs
Improve docs on externals
f0efc5cba344d798d389f4e12915ac4cc8e8be27
2023-08-13 21:16:30
Tom Payne
chore: Generate release notes from git log, not GitHub
false
diff --git a/.goreleaser.yaml b/.goreleaser.yaml index ed162cfc92b..c25004c70b0 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -110,7 +110,15 @@ archives: name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}-musl_{{ .Arch }}' changelog: - use: github-native + groups: + - title: Features + regexp: '^feat' + order: 0 + - title: Fixes + regexp: '^fix' + order: 1 + - title: Other + order: 999 checksum: extra_files:
chore
Generate release notes from git log, not GitHub
f87eed0eeff92c5d482647f6e9b412632dcfdbd5
2024-11-22 15:40:38
Tom Payne
chore: Update dependencies
false
diff --git a/go.mod b/go.mod index 6e48c1f5e0b..7696be8f55b 100644 --- a/go.mod +++ b/go.mod @@ -4,20 +4,20 @@ go 1.22.0 require ( filippo.io/age v1.2.0 - github.com/1password/onepassword-sdk-go v0.1.3 + github.com/1password/onepassword-sdk-go v0.1.4 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0 github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.3.0 github.com/Masterminds/sprig/v3 v3.3.0 github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 github.com/Shopify/ejson v1.5.3 github.com/alecthomas/assert/v2 v2.11.0 - github.com/aws/aws-sdk-go-v2 v1.32.4 - github.com/aws/aws-sdk-go-v2/config v1.28.4 - github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.5 + github.com/aws/aws-sdk-go-v2 v1.32.5 + github.com/aws/aws-sdk-go-v2/config v1.28.5 + github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.6 github.com/bmatcuk/doublestar/v4 v4.7.1 github.com/bradenhilton/mozillainstallhash v1.0.1 github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/bubbletea v1.2.2 + github.com/charmbracelet/bubbletea v1.2.3 github.com/charmbracelet/glamour v0.8.0 github.com/coreos/go-semver v0.3.1 github.com/fsnotify/fsnotify v1.8.0 @@ -64,32 +64,32 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.1.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.3.1 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2 // indirect github.com/BobuSumisu/aho-corasick v1.0.3 // indirect github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.3.0 // indirect + github.com/Masterminds/semver/v3 v3.3.1 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/ProtonMail/go-crypto v1.1.2 // indirect github.com/alecthomas/chroma/v2 v2.14.0 // indirect github.com/alecthomas/repr v0.4.0 // indirect github.com/atotto/clipboard v0.1.4 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.45 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.19 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.23 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.23 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.17.46 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.4 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.24.5 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.33.0 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.24.6 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 // indirect github.com/aws/smithy-go v1.22.1 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/bradenhilton/cityhash v1.0.0 // indirect github.com/charmbracelet/harmonica v0.2.0 // indirect github.com/charmbracelet/lipgloss v1.0.0 // indirect - github.com/charmbracelet/x/ansi v0.4.5 // indirect + github.com/charmbracelet/x/ansi v0.5.2 // indirect github.com/charmbracelet/x/term v0.2.1 // indirect github.com/cloudflare/circl v1.5.0 // indirect github.com/creack/pty/v2 v2.0.0-20231209135443-03db72c7b76c // indirect diff --git a/go.sum b/go.sum index 8835fac03a4..f2cfdbe6339 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ filippo.io/age v1.2.0 h1:vRDp7pUMaAJzXNIWJVAZnEf/Dyi4Vu4wI8S1LBzufhE= filippo.io/age v1.2.0/go.mod h1:JL9ew2lTN+Pyft4RiNGguFfOpewKwSHm5ayKD/A4004= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= -github.com/1password/onepassword-sdk-go v0.1.3 h1:PP8+pydBt40Uh21tXP9bmPCPTlBc23JW5iVpOjzssw4= -github.com/1password/onepassword-sdk-go v0.1.3/go.mod h1:nZEOzWFvodClltx8G0xtcNGqzNrrcfW589Rb9T82hE8= +github.com/1password/onepassword-sdk-go v0.1.4 h1:WLSc3d8BTI0+ltlzMA5i726IxUrujnQvCjdKM2GkQO0= +github.com/1password/onepassword-sdk-go v0.1.4/go.mod h1:Wb3xGWJSzazA699hlAULC/kK5gvjxyTEP5uZNyP21Ro= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 h1:JZg6HRh6W6U4OLl6lk7BZ7BLisIzM9dG1R50zUk9C/M= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0/go.mod h1:YL1xnZ6QejvQHWJrX/AvhFl4WW4rqHVoKspWNVwFk0M= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0 h1:B/dfvscEQtew9dVuoxqxrUKKv8Ih2f55PydknDamU+g= @@ -38,16 +38,16 @@ github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.1.0 h1:eXnN9 github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.1.0/go.mod h1:XIpam8wumeZ5rVMuhdDQLMfIPDf1WO3IzrCRO3e3e3o= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= -github.com/AzureAD/microsoft-authentication-library-for-go v1.3.1 h1:gUDtaZk8heteyfdmv+pcfHvhR9llnh7c7GMwZ8RVG04= -github.com/AzureAD/microsoft-authentication-library-for-go v1.3.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2 h1:kYRSnvJju5gYVyhkij+RTJ/VR6QIUaCfWeaFm2ycsjQ= +github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/BobuSumisu/aho-corasick v1.0.3 h1:uuf+JHwU9CHP2Vx+wAy6jcksJThhJS9ehR8a+4nPE9g= github.com/BobuSumisu/aho-corasick v1.0.3/go.mod h1:hm4jLcvZKI2vRF2WDU1N4p/jpWtpOzp3nLmi9AzX/XE= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0= -github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= +github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4= +github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs= github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= @@ -71,32 +71,32 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= -github.com/aws/aws-sdk-go-v2 v1.32.4 h1:S13INUiTxgrPueTmrm5DZ+MiAo99zYzHEFh1UNkOxNE= -github.com/aws/aws-sdk-go-v2 v1.32.4/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo= -github.com/aws/aws-sdk-go-v2/config v1.28.4 h1:qgD0MKmkIzZR2DrAjWJcI9UkndjR+8f6sjUQvXh0mb0= -github.com/aws/aws-sdk-go-v2/config v1.28.4/go.mod h1:LgnWnNzHZw4MLplSyEGia0WgJ/kCGD86zGCjvNpehJs= -github.com/aws/aws-sdk-go-v2/credentials v1.17.45 h1:DUgm5lFso57E7150RBgu1JpVQoF8fAPretiDStIuVjg= -github.com/aws/aws-sdk-go-v2/credentials v1.17.45/go.mod h1:dnBpENcPC1ekZrGpSWspX+ZRGzhkvqngT2Qp5xBR1dY= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.19 h1:woXadbf0c7enQ2UGCi8gW/WuKmE0xIzxBF/eD94jMKQ= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.19/go.mod h1:zminj5ucw7w0r65bP6nhyOd3xL6veAUMc3ElGMoLVb4= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.23 h1:A2w6m6Tmr+BNXjDsr7M90zkWjsu4JXHwrzPg235STs4= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.23/go.mod h1:35EVp9wyeANdujZruvHiQUAo9E3vbhnIO1mTCAxMlY0= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.23 h1:pgYW9FCabt2M25MoHYCfMrVY2ghiiBKYWUVXfwZs+sU= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.23/go.mod h1:c48kLgzO19wAu3CPkDWC28JbaJ+hfQlsdl7I2+oqIbk= +github.com/aws/aws-sdk-go-v2 v1.32.5 h1:U8vdWJuY7ruAkzaOdD7guwJjD06YSKmnKCJs7s3IkIo= +github.com/aws/aws-sdk-go-v2 v1.32.5/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U= +github.com/aws/aws-sdk-go-v2/config v1.28.5 h1:Za41twdCXbuyyWv9LndXxZZv3QhTG1DinqlFsSuvtI0= +github.com/aws/aws-sdk-go-v2/config v1.28.5/go.mod h1:4VsPbHP8JdcdUDmbTVgNL/8w9SqOkM5jyY8ljIxLO3o= +github.com/aws/aws-sdk-go-v2/credentials v1.17.46 h1:AU7RcriIo2lXjUfHFnFKYsLCwgbz1E7Mm95ieIRDNUg= +github.com/aws/aws-sdk-go-v2/credentials v1.17.46/go.mod h1:1FmYyLGL08KQXQ6mcTlifyFXfJVCNJTVGuQP4m0d/UA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20 h1:sDSXIrlsFSFJtWKLQS4PUWRvrT580rrnuLydJrCQ/yA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20/go.mod h1:WZ/c+w0ofps+/OUqMwWgnfrgzZH1DZO1RIkktICsqnY= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 h1:4usbeaes3yJnCFC7kfeyhkdkPtoRYPa/hTmCqMpKpLI= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24/go.mod h1:5CI1JemjVwde8m2WG3cz23qHKPOxbpkq0HaoreEgLIY= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24 h1:N1zsICrQglfzaBnrfM0Ys00860C+QFwu6u/5+LomP+o= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24/go.mod h1:dCn9HbJ8+K31i8IQ8EWmWj0EiIk0+vKiHNMxTTYveAg= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 h1:TToQNkvGguu209puTojY/ozlqy2d/SFNcoLIqTFi42g= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0/go.mod h1:0jp+ltwkf+SwG2fm/PKo8t4y8pJSgOCO4D8Lz3k0aHQ= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.4 h1:tHxQi/XHPK0ctd/wdOw0t7Xrc2OxcRCnVzv8lwWPu0c= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.4/go.mod h1:4GQbF1vJzG60poZqWatZlhP31y8PGCCVTvIGPdaaYJ0= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.5 h1:gqj99GNYzuY0jMekToqvOW1VaSupY0Qn0oj1JGSolpE= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.5/go.mod h1:FTCjaQxTVVQqLQ4ktBsLNZPnJ9pVLkJ6F0qVwtALaxk= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.5 h1:HJwZwRt2Z2Tdec+m+fPjvdmkq2s9Ra+VR0hjF7V2o40= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.5/go.mod h1:wrMCEwjFPms+V86TCQQeOxQF/If4vT44FGIOFiMC2ck= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4 h1:zcx9LiGWZ6i6pjdcoE9oXAB6mUdeyC36Ia/QEiIvYdg= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4/go.mod h1:Tp/ly1cTjRLGBBmNccFumbZ8oqpZlpdhFf80SrRh4is= -github.com/aws/aws-sdk-go-v2/service/sts v1.33.0 h1:s7LRgBqhwLaxcocnAniBJp7gaAB+4I4vHzqUqjH18yc= -github.com/aws/aws-sdk-go-v2/service/sts v1.33.0/go.mod h1:9XEUty5v5UAsMiFOBJrNibZgwCeOma73jgGwwhgffa8= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 h1:iXtILhvDxB6kPvEXgsDhGaZCSC6LQET5ZHSdJozeI0Y= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1/go.mod h1:9nu0fVANtYiAePIBh2/pFUSwtJ402hLnp854CNoDOeE= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5 h1:wtpJ4zcwrSbwhECWQoI/g6WM9zqCcSpHDJIWSbMLOu4= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5/go.mod h1:qu/W9HXQbbQ4+1+JcZp0ZNPV31ym537ZJN+fiS7Ti8E= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.6 h1:1KDMKvOKNrpD667ORbZ/+4OgvUoaok1gg/MLzrHF9fw= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.6/go.mod h1:DmtyfCfONhOyVAJ6ZMTrDSFIeyCBlEO93Qkfhxwbxu0= +github.com/aws/aws-sdk-go-v2/service/sso v1.24.6 h1:3zu537oLmsPfDMyjnUS2g+F2vITgy5pB74tHI+JBNoM= +github.com/aws/aws-sdk-go-v2/service/sso v1.24.6/go.mod h1:WJSZH2ZvepM6t6jwu4w/Z45Eoi75lPN7DcydSRtJg6Y= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5 h1:K0OQAsDywb0ltlFrZm0JHPY3yZp/S9OaoLU33S7vPS8= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5/go.mod h1:ORITg+fyuMoeiQFiVGoqB3OydVTLkClw/ljbblMq6Cc= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 h1:6SZUVRQNvExYlMLbHdlKB48x0fLbc2iVROyaNEwBHbU= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.1/go.mod h1:GqWyYCwLXnlUB1lOAXQyNSPqPLQJvmo8J0DWBzp9mtg= github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= @@ -119,16 +119,16 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/bubbletea v1.2.2 h1:EMz//Ky/aFS2uLcKqpCst5UOE6z5CFDGRsUpyXz0chs= -github.com/charmbracelet/bubbletea v1.2.2/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM= +github.com/charmbracelet/bubbletea v1.2.3 h1:d9MdMsANIYZB5pE1KkRqaUV6GfsiWm+/9z4fTuGVm9I= +github.com/charmbracelet/bubbletea v1.2.3/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ= github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao= github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg= github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= -github.com/charmbracelet/x/ansi v0.4.5 h1:LqK4vwBNaXw2AyGIICa5/29Sbdq58GbGdFngSexTdRM= -github.com/charmbracelet/x/ansi v0.4.5/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/ansi v0.5.2 h1:dEa1x2qdOZXD/6439s+wF7xjV+kZLu/iN00GuXXrU9E= +github.com/charmbracelet/x/ansi v0.5.2/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
chore
Update dependencies
d3e3fa3ffe458c46373ca44b31912e33e6fe3158
2023-03-22 16:38:51
Tom Payne
docs: Add link to article
false
diff --git a/assets/chezmoi.io/docs/links/links.yaml b/assets/chezmoi.io/docs/links/links.yaml index 9a3051053b5..d6e6eaa3362 100644 --- a/assets/chezmoi.io/docs/links/links.yaml +++ b/assets/chezmoi.io/docs/links/links.yaml @@ -396,3 +396,7 @@ articles: title: 'AWS CLI のプロファイルを chezmoi とBitwarden で管理する' lang: JP url: https://zenn.dev/nh8939/articles/8a6a4f5eb967a9 +- date: '2023-03-17' + version: 2.32.0 + title: 'Automating the Setup of a New Mac With All Your Apps, Preferences, and Development Tools' + url: https://www.moncefbelyamani.com/automating-the-setup-of-a-new-mac-with-all-your-apps-preferences-and-development-tools/
docs
Add link to article
8f364250fe8e80a37d423f646ac466ef6f832083
2023-09-27 05:16:08
Tom Payne
chore: Tidy up regexp
false
diff --git a/internal/cmds/lint-whitespace/main.go b/internal/cmds/lint-whitespace/main.go index cee41e1e560..4977c9b2f40 100644 --- a/internal/cmds/lint-whitespace/main.go +++ b/internal/cmds/lint-whitespace/main.go @@ -18,9 +18,9 @@ var ( regexp.MustCompile(`\A\.git\z`), regexp.MustCompile(`\A\.idea\z`), regexp.MustCompile(`\A\.vagrant\z`), + regexp.MustCompile(`\A\.venv\z`), regexp.MustCompile(`\A\.vscode\z`), regexp.MustCompile(`\Aassets/chezmoi\.io/site\z`), - regexp.MustCompile(`/.venv\z`), regexp.MustCompile(`\Aassets/scripts/install\.ps1\z`), regexp.MustCompile(`\Acompletions/chezmoi\.ps1\z`), regexp.MustCompile(`\Adist\z`),
chore
Tidy up regexp
9f5908f1968c3a134af86a49755bb7db23dd585d
2021-11-11 02:33:49
Tom Payne
chore: Bump gofumpt to v0.2.0
false
diff --git a/.gitignore b/.gitignore index 6a14a5e3bca..8331ce175e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ -*.exe /.vagrant -/bin/chezmoi -/bin/gofumports +/bin/gofumpt /bin/golangci-lint /chezmoi /chezmoi.exe diff --git a/Makefile b/Makefile index a1d4a687412..b074407bf27 100644 --- a/Makefile +++ b/Makefile @@ -74,17 +74,17 @@ lint: ensure-golangci-lint ${GO} run ./internal/cmds/lint-whitespace .PHONY: format -format: ensure-gofumports - find . -name \*.go | xargs ./bin/gofumports -local github.com/twpayne/chezmoi -w +format: ensure-gofumpt + find . -name \*.go | xargs ./bin/gofumpt -w .PHONY: ensure-tools ensure-tools: ensure-gofumports ensure-golangci-lint -.PHONY: ensure-gofumports +.PHONY: ensure-gofumpt ensure-gofumports: - if [ ! -x bin/gofumports ] ; then \ + if [ ! -x bin/gofumpt ] ; then \ mkdir -p bin ; \ - GOBIN=$(shell pwd)/bin ${GO} install mvdan.cc/gofumpt/gofumports@latest ; \ + GOBIN=$(shell pwd)/bin ${GO} install mvdan.cc/[email protected] ; \ fi .PHONY: ensure-golangci-lint
chore
Bump gofumpt to v0.2.0
c7a567a08105fcccddc9a7fd5384c6307cbec172
2025-03-07 06:11:07
Tom Payne
chore: Update GitHub Actions
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e4e99d7afb2..7b6b8acf05e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -70,10 +70,10 @@ jobs: with: go-version: ${{ env.GO_VERSION }} upload-cache: false - - uses: github/codeql-action/init@1bb15d06a6fbb5d9d9ffd228746bf8ee208caec8 + - uses: github/codeql-action/init@80f993039571a6de66594ecaa432875a6942e8e0 with: languages: go - - uses: github/codeql-action/analyze@1bb15d06a6fbb5d9d9ffd228746bf8ee208caec8 + - uses: github/codeql-action/analyze@80f993039571a6de66594ecaa432875a6942e8e0 misspell: runs-on: ubuntu-22.04 permissions:
chore
Update GitHub Actions
9b1b5fba025af2705b24dc341030b5f2dcdff40e
2022-04-04 00:34:04
Tom Payne
docs: Document that the ioreg template function is deprecated
false
diff --git a/assets/chezmoi.io/docs/reference/templates/functions/ioreg.md b/assets/chezmoi.io/docs/reference/templates/functions/ioreg.md index c8fbb573d78..bafaa98bbe7 100644 --- a/assets/chezmoi.io/docs/reference/templates/functions/ioreg.md +++ b/assets/chezmoi.io/docs/reference/templates/functions/ioreg.md @@ -15,3 +15,8 @@ will only execute the `ioreg -a -l` command once. {{ $serialNumber := index ioreg "IORegistryEntryChildren" 0 "IOPlatformSerialNumber" }} {{ end }} ``` + +!!! warning + + The `ioreg` function can be very slow and should not be used. It will be + removed in a later version of chezmoi.
docs
Document that the ioreg template function is deprecated
42ccba6456a1fb4e9ba1abdab0c9d8470eac5a57
2021-10-15 22:27:27
Felipe Santos
docs: simplify config file example
false
diff --git a/docs/HOWTO.md b/docs/HOWTO.md index f98072f816a..b82470bb30f 100644 --- a/docs/HOWTO.md +++ b/docs/HOWTO.md @@ -779,8 +779,9 @@ you will be prompted again. However, you can avoid this with the following example template logic: ``` -{{- $email := get . "email" -}} -{{- if not $email -}} +{{- if (hasKey . "email") -}} +{{- $email = .email -}} +{{- else -}} {{- $email = promptString "email" -}} {{- end -}} @@ -791,18 +792,6 @@ example template logic: This will cause chezmoi to first try to re-use the existing `$email` variable and fallback to `promptString` only if it is not set. -For boolean variables you can use: - -``` -{{- $var := false -}} -{{- if (hasKey . "var") -}} -{{- $var = get . "var" -}} -{{- end -}} - -[data] - var = {{ $var }} -``` - --- ### Handle different file locations on different systems with the same contents
docs
simplify config file example
64b9c1fa7346526c17d5073827fe055dc46f6c09
2022-09-03 17:27:36
Tom Payne
fix: Fix handling of newlines in comment template function
false
diff --git a/pkg/cmd/templatefuncs.go b/pkg/cmd/templatefuncs.go index 710b53da13f..e026dbfd6e6 100644 --- a/pkg/cmd/templatefuncs.go +++ b/pkg/cmd/templatefuncs.go @@ -30,15 +30,41 @@ type ioregData struct { value map[string]any } -var ( - // needsQuoteRx matches any string that contains non-printable characters, - // double quotes, or a backslash. - needsQuoteRx = regexp.MustCompile(`[^\x21\x23-\x5b\x5d-\x7e]`) - startOfLineRx = regexp.MustCompile(`(?m)^`) -) +// needsQuoteRx matches any string that contains non-printable characters, +// double quotes, or a backslash. +var needsQuoteRx = regexp.MustCompile(`[^\x21\x23-\x5b\x5d-\x7e]`) func (c *Config) commentTemplateFunc(prefix, s string) string { - return startOfLineRx.ReplaceAllString(s, prefix) + type stateType int + const ( + startOfLine stateType = iota + inLine + ) + + state := startOfLine + var builder strings.Builder + for _, r := range s { + switch state { + case startOfLine: + if _, err := builder.WriteString(prefix); err != nil { + panic(err) + } + if _, err := builder.WriteRune(r); err != nil { + panic(err) + } + if r != '\n' { + state = inLine + } + case inLine: + if _, err := builder.WriteRune(r); err != nil { + panic(err) + } + if r == '\n' { + state = startOfLine + } + } + } + return builder.String() } func (c *Config) fromIniTemplateFunc(s string) map[string]any { diff --git a/pkg/cmd/templatefuncs_test.go b/pkg/cmd/templatefuncs_test.go index 40854fa74ba..12268661435 100644 --- a/pkg/cmd/templatefuncs_test.go +++ b/pkg/cmd/templatefuncs_test.go @@ -12,6 +12,48 @@ import ( "github.com/twpayne/chezmoi/v2/pkg/chezmoitest" ) +func TestCommentTemplateFunc(t *testing.T) { + prefix := "# " + for i, tc := range []struct { + s string + expected string + }{ + { + s: "", + expected: "", + }, + { + s: "line", + expected: "# line", + }, + { + s: "\n", + expected: "# \n", + }, + { + s: "\n\n", + expected: "# \n# \n", + }, + { + s: "line1\nline2", + expected: "# line1\n# line2", + }, + { + s: "line1\nline2\n", + expected: "# line1\n# line2\n", + }, + { + s: "line1\n\nline3\n", + expected: "# line1\n# \n# line3\n", + }, + } { + t.Run(strconv.Itoa(i), func(t *testing.T) { + c := &Config{} + assert.Equal(t, tc.expected, c.commentTemplateFunc(prefix, tc.s)) + }) + } +} + func TestFromIniTemplateFunc(t *testing.T) { for i, tc := range []struct { text string
fix
Fix handling of newlines in comment template function
01eef459e9fd7cbc2f174a0c8a3e8e74d7b57d76
2024-11-27 04:57:49
Tom Payne
feat: Warn if the user is using the Helix editor with chezmoi edit
false
diff --git a/internal/cmd/config.go b/internal/cmd/config.go index fe3e0986801..aaa4319808b 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -2495,6 +2495,9 @@ func (c *Config) runEditor(args []string) error { if err != nil { return err } + if c.Edit.Hardlink && filepath.Base(editor) == "hx" { + c.errorf("warning: helix editor cannot edit hardlinks, see https://github.com/helix-editor/helix/issues/11279 and https://github.com/twpayne/chezmoi/issues/3971") + } start := time.Now() err = c.run(chezmoi.EmptyAbsPath, editor, editorArgs) if runtime.GOOS != "windows" && c.Edit.MinDuration != 0 { diff --git a/internal/cmd/testdata/scripts/issue4107.txtar b/internal/cmd/testdata/scripts/issue4107.txtar new file mode 100644 index 00000000000..caf8d2de4d9 --- /dev/null +++ b/internal/cmd/testdata/scripts/issue4107.txtar @@ -0,0 +1,18 @@ +[windows] skip + +chmod 777 bin/hx + +# test that chezmoi edit prints a warning if the editor is hx (helix) with hardlinks enabled +exec chezmoi edit $HOME${/}.file +stderr 'warning: helix editor cannot edit hardlinks' + +-- bin/hx -- +#!/bin/sh + +echo "helix 24.7 (079f5442)" +-- home/user/.config/chezmoi/chezmoi.toml -- +[edit] + command = "hx" + hardlink = true +-- home/user/.local/share/chezmoi/dot_file -- +# contents of .file
feat
Warn if the user is using the Helix editor with chezmoi edit
f08542694d268bc3d20128035b69a6f2d37ccad3
2022-10-18 01:50:59
dependabot[bot]
chore(deps): bump github/codeql-action from 2.1.26 to 2.1.27
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d6d042d37b3..d66f119e18d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,10 +46,10 @@ jobs: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b with: fetch-depth: 1 - - uses: github/codeql-action/init@e0e5ded33cabb451ae0a9768fc7b0410bad9ad44 + - uses: github/codeql-action/init@807578363a7869ca324a79039e6db9c843e0e100 with: languages: go - - uses: github/codeql-action/analyze@e0e5ded33cabb451ae0a9768fc7b0410bad9ad44 + - uses: github/codeql-action/analyze@807578363a7869ca324a79039e6db9c843e0e100 test-alpine: needs: changes if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
chore
bump github/codeql-action from 2.1.26 to 2.1.27
774d053d28894e301e4433539481dd7a1830a642
2023-12-27 05:06:46
Tom Payne
docs: Add upcoming changes to release history
false
diff --git a/assets/chezmoi.io/docs/reference/release-history.md.tmpl b/assets/chezmoi.io/docs/reference/release-history.md.tmpl index c78f85605cc..fdf80eaa676 100644 --- a/assets/chezmoi.io/docs/reference/release-history.md.tmpl +++ b/assets/chezmoi.io/docs/reference/release-history.md.tmpl @@ -1,6 +1,9 @@ # Release history {{- $releases := gitHubListReleases "twpayne/chezmoi" }} + +[Upcoming changes](https://github.com/twpayne/chezmoi/compare/{{ $releases | index 0 | .Name }}...master) + {{- $lastReleaseIndex := sub (len $releases) 1 }} {{- range $index, $release := $releases }}
docs
Add upcoming changes to release history
731a77ff02ce436113dfbd619e18819e4883be30
2023-03-01 13:31:40
dependabot[bot]
chore(deps): bump github/codeql-action from 2.2.1 to 2.2.5
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 10af94ec428..4b0263f98b7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,10 +47,10 @@ jobs: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c with: fetch-depth: 1 - - uses: github/codeql-action/init@3ebbd71c74ef574dbc558c82f70e52732c8b44fe + - uses: github/codeql-action/init@32dc499307d133bb5085bae78498c0ac2cf762d5 with: languages: go - - uses: github/codeql-action/analyze@3ebbd71c74ef574dbc558c82f70e52732c8b44fe + - uses: github/codeql-action/analyze@32dc499307d133bb5085bae78498c0ac2cf762d5 misspell: runs-on: ubuntu-22.04 steps:
chore
bump github/codeql-action from 2.2.1 to 2.2.5
fc96285835f2b7e97698441fe8cbcdbd54dde993
2022-11-02 04:07:32
Tom Payne
feat: Add setValueAtPath template function
false
diff --git a/assets/chezmoi.io/docs/reference/templates/functions/setValueAtPath.md b/assets/chezmoi.io/docs/reference/templates/functions/setValueAtPath.md new file mode 100644 index 00000000000..49a25c4abf0 --- /dev/null +++ b/assets/chezmoi.io/docs/reference/templates/functions/setValueAtPath.md @@ -0,0 +1,17 @@ +# `setValueAtPath` *path* *value* *dict* + +`setValueAtPath` modifies *dict* to set the value at *path* to *value* and +returns *dict*. *path* can be either a string containing a `.`-separated list of +keys or a list of keys. The function will create new key/value pairs in *dict* +if needed. + +This is an alternative to [sprig's `set` +function](http://masterminds.github.io/sprig/dicts.html) with a different +argument order that supports pipelining. + +!!! example + + ``` + {{ dict | setValueAtPath "key1" "value1" | setValueAtPath "key2.nestedKey" "value2" | toJson }} + {{ dict | setValueAtPath (list "key2" "nestedKey") "value2" | toJson }} + ``` diff --git a/assets/chezmoi.io/docs/user-guide/manage-different-types-of-file.md b/assets/chezmoi.io/docs/user-guide/manage-different-types-of-file.md index cb444550d01..ba48b1e38fa 100644 --- a/assets/chezmoi.io/docs/user-guide/manage-different-types-of-file.md +++ b/assets/chezmoi.io/docs/user-guide/manage-different-types-of-file.md @@ -86,6 +86,14 @@ contents of the file. {{- .chezmoi.stdin | replaceAllRegex "old" "new" }} ``` + To set individual values in JSON, TOML, and YAML files you can use the + `setValueAtPath` template function, for example: + + ``` + {{- /* chezmoi:modify-template */ -}} + {{ fromJson .chezmoi.stdin | setValueAtPath "key.nestedKey" "value" | toPrettyJson }} + ``` + Secondly, if only a small part of the file changes then consider using a template to re-generate the full contents of the file from the current state. For example, Kubernetes configurations include a current context that can be diff --git a/assets/chezmoi.io/mkdocs.yml b/assets/chezmoi.io/mkdocs.yml index fa5feb0c6e8..376522e653a 100644 --- a/assets/chezmoi.io/mkdocs.yml +++ b/assets/chezmoi.io/mkdocs.yml @@ -188,6 +188,7 @@ nav: - output: reference/templates/functions/output.md - quoteList: reference/templates/functions/quoteList.md - replaceAllRegex: reference/templates/functions/replaceAllRegex.md + - setValueAtPath: reference/templates/functions/setValueAtPath.md - stat: reference/templates/functions/stat.md - toIni: reference/templates/functions/toIni.md - toToml: reference/templates/functions/toToml.md diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index ea7ce339ba7..cafc37ad2a3 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -382,6 +382,7 @@ func newConfig(options ...configOption) (*Config, error) { "replaceAllRegex": c.replaceAllRegexTemplateFunc, "secret": c.secretTemplateFunc, "secretJSON": c.secretJSONTemplateFunc, + "setValueAtPath": c.setValueAtPathTemplateFunc, "stat": c.statTemplateFunc, "toIni": c.toIniTemplateFunc, "toToml": c.toTomlTemplateFunc, diff --git a/pkg/cmd/templatefuncs.go b/pkg/cmd/templatefuncs.go index 812ba7ba4c1..0a8e853bbf9 100644 --- a/pkg/cmd/templatefuncs.go +++ b/pkg/cmd/templatefuncs.go @@ -280,6 +280,52 @@ func (c *Config) replaceAllRegexTemplateFunc(expr, repl, s string) string { return regexp.MustCompile(expr).ReplaceAllString(s, repl) } +func (c *Config) setValueAtPathTemplateFunc(path, value, dict any) any { + var keys []string + switch path := path.(type) { + case string: + keys = strings.Split(path, ".") + case []any: + keys = make([]string, 0, len(path)) + for _, element := range path { + elementStr, ok := element.(string) + if !ok { + panic(fmt.Sprintf("%v: invalid path element type %T", element, element)) + } + keys = append(keys, elementStr) + } + case []string: + keys = path + default: + panic(fmt.Sprintf("%v: invalid path type %T", path, path)) + } + + result, ok := dict.(map[string]any) + if !ok { + result = make(map[string]any) + } + + currentMap := result + for _, key := range keys[:len(keys)-1] { + if value, ok := currentMap[key]; ok { + if nestedMap, ok := value.(map[string]any); ok { + currentMap = nestedMap + } else { + nestedMap := make(map[string]any) + currentMap[key] = nestedMap + currentMap = nestedMap + } + } else { + nestedMap := make(map[string]any) + currentMap[key] = nestedMap + currentMap = nestedMap + } + } + currentMap[keys[len(keys)-1]] = value + + return result +} + func (c *Config) statTemplateFunc(name string) any { switch fileInfo, err := c.fileSystem.Stat(name); { case err == nil: diff --git a/pkg/cmd/templatefuncs_test.go b/pkg/cmd/templatefuncs_test.go index 10b951c6247..76c62bccca6 100644 --- a/pkg/cmd/templatefuncs_test.go +++ b/pkg/cmd/templatefuncs_test.go @@ -54,6 +54,173 @@ func TestCommentTemplateFunc(t *testing.T) { } } +func TestSetValueAtPathTemplateFunc(t *testing.T) { + for _, tc := range []struct { + name string + path any + value any + dict any + expected any + expectedErr string + }{ + { + name: "simple", + path: "key", + value: "value", + dict: make(map[string]any), + expected: map[string]any{ + "key": "value", + }, + }, + { + name: "create_map", + path: "key", + value: "value", + expected: map[string]any{ + "key": "value", + }, + }, + { + name: "modify_map", + path: "key2", + value: "value2", + dict: map[string]any{ + "key1": "value1", + }, + expected: map[string]any{ + "key1": "value1", + "key2": "value2", + }, + }, + { + name: "create_nested_map", + path: "key1.key2", + value: "value", + expected: map[string]any{ + "key1": map[string]any{ + "key2": "value", + }, + }, + }, + { + name: "modify_nested_map", + path: "key1.key2", + value: "value", + dict: map[string]any{ + "key1": map[string]any{ + "key2": "value2", + "key3": "value3", + }, + "key2": "value2", + }, + expected: map[string]any{ + "key1": map[string]any{ + "key2": "value", + "key3": "value3", + }, + "key2": "value2", + }, + }, + { + name: "replace_map", + path: "key1", + value: "value1", + dict: map[string]any{ + "key1": map[string]any{ + "key2": "value2", + }, + }, + expected: map[string]any{ + "key1": "value1", + }, + }, + { + name: "replace_nested_map", + path: "key1.key2", + value: "value2", + dict: map[string]any{ + "key1": map[string]any{ + "key2": map[string]any{ + "key3": "value3", + }, + }, + }, + expected: map[string]any{ + "key1": map[string]any{ + "key2": "value2", + }, + }, + }, + { + name: "replace_nested_value", + path: "key1.key2.key3", + value: "value3", + dict: map[string]any{ + "key1": map[string]any{ + "key2": "value2", + }, + }, + expected: map[string]any{ + "key1": map[string]any{ + "key2": map[string]any{ + "key3": "value3", + }, + }, + }, + }, + { + name: "string_list_path", + path: []string{ + "key1", + "key2", + }, + value: "value2", + expected: map[string]any{ + "key1": map[string]any{ + "key2": "value2", + }, + }, + }, + { + name: "any_list_path", + path: []any{ + "key1", + "key2", + }, + value: "value2", + expected: map[string]any{ + "key1": map[string]any{ + "key2": "value2", + }, + }, + }, + { + name: "invalid_path", + path: 0, + expectedErr: "0: invalid path type int", + }, + { + name: "invalid_path_element", + path: []any{ + 0, + }, + expectedErr: "0: invalid path element type int", + }, + } { + t.Run(tc.name, func(t *testing.T) { + var c Config + if tc.expectedErr == "" { + actual := c.setValueAtPathTemplateFunc(tc.path, tc.value, tc.dict) + assert.Equal(t, tc.expected, actual) + } else { + assert.PanicsWithValue(t, tc.expectedErr, func() { + c.setValueAtPathTemplateFunc(tc.path, tc.value, tc.dict) + }) + } + }) + } +} + func TestFromIniTemplateFunc(t *testing.T) { for i, tc := range []struct { text string diff --git a/pkg/cmd/testdata/scripts/modify_unix.txtar b/pkg/cmd/testdata/scripts/modify_unix.txtar index d100deca2e8..fc6cc752fad 100644 --- a/pkg/cmd/testdata/scripts/modify_unix.txtar +++ b/pkg/cmd/testdata/scripts/modify_unix.txtar @@ -62,6 +62,12 @@ chhome home5/user exec chezmoi cat $HOME${/}.modify cmp stdout golden/.modified +chhome home6/user + +# test that modify scripts can use modify-templates to modify JSON fields +exec chezmoi apply --force +cmp $HOME/.modify.json golden/.modified.json + -- golden/.edited-and-modified -- beginning modified-middle @@ -71,6 +77,8 @@ end beginning modified-middle end +-- golden/.modified.json -- +{"key1":{"key2":"value","key3":"value3"}} -- golden/.modify -- beginning middle @@ -123,3 +131,8 @@ end beginning middle end +-- home6/user/.local/share/chezmoi/modify_dot_modify.json -- +{{- /* chezmoi:modify-template */ -}} +{{ fromJson .chezmoi.stdin | setValueAtPath "key1.key2" "value" | toJson }} +-- home6/user/.modify.json -- +{"key1":{"key2":"value2","key3":"value3"}} diff --git a/pkg/cmd/testdata/scripts/templatefuncs.txtar b/pkg/cmd/testdata/scripts/templatefuncs.txtar index d831e8cefaf..f32a6fff616 100644 --- a/pkg/cmd/testdata/scripts/templatefuncs.txtar +++ b/pkg/cmd/testdata/scripts/templatefuncs.txtar @@ -65,6 +65,11 @@ stdout 2656FF1E876E9973 exec chezmoi execute-template '{{ "foo bar baz" | replaceAllRegex "ba" "BA" }}' stdout 'foo BAr BAz' +# test setValueAtPath template function +exec chezmoi execute-template '{{ dict | setValueAtPath "key1.key2" "value2" | toJson }}' +rmfinalnewline golden/setValueAtPath +cmp stdout golden/setValueAtPath + # test toIni template function exec chezmoi execute-template '{{ dict "key" "value" "section" (dict "subkey" "subvalue") | toIni }}' cmp stdout golden/toIni @@ -161,6 +166,8 @@ file2.txt # contents of .include -- golden/include-relpath -- # contents of .local/share/chezmoi/.include +-- golden/setValueAtPath -- +{"key1":{"key2":"value2"}} -- golden/toIni -- key = value
feat
Add setValueAtPath template function
be6e90307f9b5c8fa5d356183418a16d7bba69bf
2023-07-28 23:29:29
Tom Payne
feat: Add mackup command
false
diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index 4bc2c2e2c03..56d5e5dae61 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -1558,6 +1558,7 @@ func (c *Config) newRootCmd() (*cobra.Command, error) { c.newInitCmd(), c.newInternalTestCmd(), c.newLicenseCmd(), + c.newMackupCmd(), c.newManagedCmd(), c.newMergeCmd(), c.newMergeAllCmd(), diff --git a/pkg/cmd/mackupcmd_darwin.go b/pkg/cmd/mackupcmd_darwin.go new file mode 100644 index 00000000000..221e6d54e33 --- /dev/null +++ b/pkg/cmd/mackupcmd_darwin.go @@ -0,0 +1,205 @@ +package cmd + +// FIXME add documentation if we decide to keep this command + +import ( + "bufio" + "bytes" + "fmt" + "os/exec" + "regexp" + "strings" + + "github.com/spf13/cobra" + + "github.com/twpayne/chezmoi/v2/pkg/chezmoi" +) + +var ( + mackupCommentRx = regexp.MustCompile(`\A#.*\z`) + mackupKeyValueRx = regexp.MustCompile(`\A(\w+)\s*=\s*(.*)\z`) + mackupSectionRx = regexp.MustCompile(`\A\[(.*)\]\z`) + mackupVersionRx = regexp.MustCompile(`\AMackup\s+(\d+\.\d+\.\d+)\s*\z`) + pythonMajorMinorVersionRx = regexp.MustCompile(`\APython\s+(\d+\.\d+)\.\d+\s*\z`) +) + +type mackupApplicationApplicationConfig struct { + Name string +} + +type mackupApplicationConfig struct { + Application mackupApplicationApplicationConfig + ConfigurationFiles []chezmoi.RelPath + XDGConfigurationFiles []chezmoi.RelPath +} + +func (c *Config) newMackupCmd() *cobra.Command { + mackupCmd := &cobra.Command{ + Use: "mackup", + Short: "Interact with Mackup", + Hidden: true, + } + + mackupAddCmd := &cobra.Command{ + Use: "add application...", + Short: "Add an application's configuration from its Mackup configuration", + Args: cobra.MinimumNArgs(1), + RunE: c.makeRunEWithSourceState(c.runMackupAddCmd), + Annotations: newAnnotations( + createSourceDirectoryIfNeeded, + modifiesSourceDirectory, + persistentStateModeReadWrite, + requiresSourceDirectory, + ), + } + mackupCmd.AddCommand(mackupAddCmd) + + // FIXME add other subcommands like + // mackup list + // mackup forget + + return mackupCmd +} + +func (c *Config) runMackupAddCmd( + cmd *cobra.Command, + args []string, + sourceState *chezmoi.SourceState, +) error { + mackupApplicationsDir, err := c.mackupApplicationsDir() + if err != nil { + return err + } + + var addArgs []string + for _, arg := range args { + data, err := c.baseSystem.ReadFile( + mackupApplicationsDir.Join(chezmoi.NewRelPath(arg + ".cfg")), + ) + if err != nil { + return err + } + config, err := parseMackupApplication(data) + if err != nil { + return err + } + for _, filename := range config.ConfigurationFiles { + addArg := c.DestDirAbsPath.Join(filename) + addArgs = append(addArgs, addArg.String()) + } + configHomeAbsPath := chezmoi.NewAbsPath(c.bds.ConfigHome) + for _, filename := range config.XDGConfigurationFiles { + addArg := configHomeAbsPath.Join(filename) + addArgs = append(addArgs, addArg.String()) + } + } + + destAbsPathInfos, err := c.destAbsPathInfos(sourceState, addArgs, destAbsPathInfosOptions{ + follow: c.Add.follow, + ignoreNotExist: true, + recursive: c.Add.recursive, + }) + if err != nil { + return err + } + + return sourceState.Add( + c.sourceSystem, + c.persistentState, + c.destSystem, + destAbsPathInfos, + &chezmoi.AddOptions{ + Filter: chezmoi.NewEntryTypeFilter(chezmoi.EntryTypesAll, chezmoi.EntryTypesNone), + OnIgnoreFunc: c.defaultOnIgnoreFunc, + PreAddFunc: c.defaultPreAddFunc, + ReplaceFunc: c.defaultReplaceFunc, + }, + ) +} + +func (c *Config) mackupApplicationsDir() (chezmoi.AbsPath, error) { + brewPrefixCmd := exec.Command("brew", "--prefix") + brewPrefixData, err := brewPrefixCmd.Output() + if err != nil { + return chezmoi.EmptyAbsPath, err + } + brewPrefix := chezmoi.NewAbsPath(strings.TrimRight(string(brewPrefixData), "\n")) + + mackupVersionCmd := exec.Command("mackup", "--version") + mackupVersionData, err := mackupVersionCmd.Output() + if err != nil { + return chezmoi.EmptyAbsPath, err + } + mackupVersionMatch := mackupVersionRx.FindSubmatch(mackupVersionData) + if mackupVersionMatch == nil { + return chezmoi.EmptyAbsPath, fmt.Errorf( + "%q: cannot determine Mackup version", + mackupVersionData, + ) + } + mackupVersion := string(mackupVersionMatch[1]) + + pythonVersionCmd := exec.Command("python3", "--version") + pythonVersionData, err := pythonVersionCmd.Output() + if err != nil { + return chezmoi.EmptyAbsPath, err + } + pythonMajorMinorVersionMatch := pythonMajorMinorVersionRx.FindSubmatch(pythonVersionData) + if pythonMajorMinorVersionMatch == nil { + return chezmoi.EmptyAbsPath, fmt.Errorf( + "%q: cannot determine Python version", + pythonVersionData, + ) + } + pythonMajorMinorVersion := string(pythonMajorMinorVersionMatch[1]) + + return brewPrefix.JoinString( + "Cellar", + "mackup", + mackupVersion, + "libexec", + "lib", + "python"+pythonMajorMinorVersion, + "site-packages", + "mackup", + "applications", + ), nil +} + +func parseMackupApplication(data []byte) (mackupApplicationConfig, error) { + var config mackupApplicationConfig + var section string + s := bufio.NewScanner(bytes.NewReader(data)) + for s.Scan() { + text := s.Text() + if mackupCommentRx.MatchString(text) { + continue + } + if m := mackupSectionRx.FindStringSubmatch(s.Text()); m != nil { + section = m[1] + continue + } + text = strings.TrimSpace(text) + if text == "" { + continue + } + //nolint:gocritic + switch section { + case "application": + if m := mackupKeyValueRx.FindStringSubmatch(text); m != nil { + switch m[1] { + case "name": + config.Application.Name = m[2] + } + } + case "configuration_files": + config.ConfigurationFiles = append(config.ConfigurationFiles, chezmoi.NewRelPath(text)) + case "xdg_configuration_files": + config.XDGConfigurationFiles = append( + config.XDGConfigurationFiles, + chezmoi.NewRelPath(text), + ) + } + } + return config, s.Err() +} diff --git a/pkg/cmd/mackupcmd_nodarwin.go b/pkg/cmd/mackupcmd_nodarwin.go new file mode 100644 index 00000000000..7cb6ebec4d4 --- /dev/null +++ b/pkg/cmd/mackupcmd_nodarwin.go @@ -0,0 +1,11 @@ +//go:build !darwin + +package cmd + +import ( + "github.com/spf13/cobra" +) + +func (c *Config) newMackupCmd() *cobra.Command { + return nil +} diff --git a/pkg/cmd/mackupcmd_test_darwin.go b/pkg/cmd/mackupcmd_test_darwin.go new file mode 100644 index 00000000000..01d9e9a7a72 --- /dev/null +++ b/pkg/cmd/mackupcmd_test_darwin.go @@ -0,0 +1,77 @@ +package cmd + +import ( + "testing" + + "github.com/alecthomas/assert/v2" + + "github.com/twpayne/chezmoi/v2/pkg/chezmoi" + "github.com/twpayne/chezmoi/v2/pkg/chezmoitest" +) + +func TestParseMackupApplication(t *testing.T) { + for _, tc := range []struct { + name string + lines []string + expected mackupApplicationConfig + }{ + { + name: "curl.cfg", + lines: []string{ + "[application]", + "name = Curl", + "", + "[configuration_files]", + ".netrc", + ".curlrc", + }, + expected: mackupApplicationConfig{ + Application: mackupApplicationApplicationConfig{ + Name: "Curl", + }, + ConfigurationFiles: []chezmoi.RelPath{ + chezmoi.NewRelPath(".netrc"), + chezmoi.NewRelPath(".curlrc"), + }, + }, + }, + { + name: "vscode.cfg", + lines: []string{ + "[application]", + "name = Visual Studio Code", + "", + "[configuration_files]", + "Library/Application Support/Code/User/snippets", + "Library/Application Support/Code/User/keybindings.json", + "Library/Application Support/Code/User/settings.json", + "", + "[xdg_configuration_files]", + "Code/User/snippets", + "Code/User/keybindings.json", + "Code/User/settings.json", + }, + expected: mackupApplicationConfig{ + Application: mackupApplicationApplicationConfig{ + Name: "Visual Studio Code", + }, + ConfigurationFiles: []chezmoi.RelPath{ + chezmoi.NewRelPath("Library/Application Support/Code/User/snippets"), + chezmoi.NewRelPath("Library/Application Support/Code/User/keybindings.json"), + chezmoi.NewRelPath("Library/Application Support/Code/User/settings.json"), + }, + XDGConfigurationFiles: []chezmoi.RelPath{ + chezmoi.NewRelPath("Code/User/snippets"), + chezmoi.NewRelPath("Code/User/keybindings.json"), + chezmoi.NewRelPath("Code/User/settings.json"), + }, + }, + }, + } { + t.Run(tc.name, func(t *testing.T) { + actual, err := parseMackupApplication([]byte(chezmoitest.JoinLines(tc.lines...))) + assert.NoError(t, err) + assert.Equal(t, tc.expected, actual) + }) + } +} diff --git a/pkg/cmd/testdata/scripts/mackup_darwin.txt b/pkg/cmd/testdata/scripts/mackup_darwin.txt new file mode 100644 index 00000000000..c9579db1959 --- /dev/null +++ b/pkg/cmd/testdata/scripts/mackup_darwin.txt @@ -0,0 +1,75 @@ +[!darwin] skip 'Darwin only' + +chmod 755 bin/brew +chmod 755 bin/mackup +chmod 755 bin/python3 + +# test that chezmoi mackup add adds normal dotfiles +exec chezmoi mackup add curl +cmp $CHEZMOISOURCEDIR/dot_curlrc golden/dot_curlrc + +# test that chezmoi +exec chezmoi mackup add vscode +cmp $CHEZMOISOURCEDIR/dot_config/Code/User/settings.json golden/settings.json + +-- bin/brew -- +#!/bin/sh + +case "$*" in +"--prefix") + echo "opt/homebrew" + ;; +*) + echo "Error: Unknown command $*" + ;; +esac +-- bin/mackup -- +#!/bin/sh + +case "$*" in +"--version") + echo "Mackup 0.8.32" + ;; +*) + echo "Usage:" + ;; +esac +-- bin/python3 -- +#!/bin/sh + +case "$*" in +"--version") + echo "Python 3.9.0" + ;; +*) + echo "Usage:" + ;; +esac +-- golden/dot_curlrc -- +# contents of .curlrc +-- golden/settings.json -- +# contents of .config/Code/User/settings.json +-- home/user/.config/Code/User/settings.json -- +# contents of .config/Code/User/settings.json +-- home/user/.curlrc -- +# contents of .curlrc +-- opt/homebrew/Cellar/mackup/0.8.32/libexec/lib/python3.9/site-packages/mackup/applications/curl.cfg -- +[application] +name = Curl + +[configuration_files] +.netrc +.curlrc +-- opt/homebrew/Cellar/mackup/0.8.32/libexec/lib/python3.9/site-packages/mackup/applications/vscode.cfg -- +[application] +name = Visual Studio Code + +[configuration_files] +Library/Application Support/Code/User/snippets +Library/Application Support/Code/User/keybindings.json +Library/Application Support/Code/User/settings.json + +[xdg_configuration_files] +Code/User/snippets +Code/User/keybindings.json +Code/User/settings.json
feat
Add mackup command
d86a9d2eadba1485fdcffca0510572c45e83f14d
2021-10-09 21:01:22
Tom Payne
chore: Improve logging infrastructure
false
diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go index ae09f215a4e..5a49f57a867 100644 --- a/internal/chezmoi/sourcestate.go +++ b/internal/chezmoi/sourcestate.go @@ -24,6 +24,7 @@ import ( "time" "github.com/coreos/go-semver/semver" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" vfs "github.com/twpayne/go-vfs/v4" "go.uber.org/multierr" @@ -75,6 +76,7 @@ type SourceState struct { encryption Encryption ignore *patternSet interpreters map[string]*Interpreter + logger *zerolog.Logger minVersion semver.Version mode Mode defaultTemplateDataFunc func() map[string]interface{} @@ -126,6 +128,13 @@ func WithInterpreters(interpreters map[string]*Interpreter) SourceStateOption { } } +// WithLogger sets the logger. +func WithLogger(logger *zerolog.Logger) SourceStateOption { + return func(s *SourceState) { + s.logger = logger + } +} + // WithMode sets the mode. func WithMode(mode Mode) SourceStateOption { return func(s *SourceState) { @@ -193,6 +202,7 @@ func NewSourceState(options ...SourceStateOption) *SourceState { umask: Umask, encryption: NoEncryption{}, ignore: newPatternSet(), + logger: &log.Logger, readTemplateData: true, priorityTemplateData: make(map[string]interface{}), userTemplateData: make(map[string]interface{}), @@ -1104,7 +1114,7 @@ func (s *SourceState) getExternalDataRaw(ctx context.Context, externalRelPath Re return nil, err } resp, err := http.DefaultClient.Do(req) - log.Err(err). + s.logger.Err(err). Str("method", req.Method). Int("statusCode", resp.StatusCode). Str("status", resp.Status). diff --git a/internal/cmd/config.go b/internal/cmd/config.go index ad4bc4a8308..1bd7c8c1e3d 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -49,6 +49,7 @@ const ( logComponentKey = "component" logComponentValueEncryption = "encryption" logComponentValuePersistentState = "persistentState" + logComponentValueSourceState = "sourceState" logComponentValueSystem = "system" ) @@ -155,6 +156,7 @@ type Config struct { sourceSystem chezmoi.System destSystem chezmoi.System persistentState chezmoi.PersistentState + logger *zerolog.Logger // Computed configuration. homeDirAbsPath chezmoi.AbsPath @@ -561,7 +563,7 @@ func (c *Config) close() error { var err error for _, tempDirAbsPath := range c.tempDirs { err2 := os.RemoveAll(tempDirAbsPath.String()) - log.Err(err2). + c.logger.Err(err2). Stringer("tempDir", tempDirAbsPath). Msg("RemoveAll") err = multierr.Append(err, err2) @@ -718,7 +720,7 @@ func (c *Config) defaultConfigFile(fileSystem vfs.Stater, bds *xdg.BaseDirectory // has changed since chezmoi last wrote it then it prompts the user for the // action to take. func (c *Config) defaultPreApplyFunc(targetRelPath chezmoi.RelPath, targetEntryState, lastWrittenEntryState, actualEntryState *chezmoi.EntryState) error { - log.Info(). + c.logger.Info(). Stringer("targetRelPath", targetRelPath). Object("targetEntryState", targetEntryState). Object("lastWrittenEntryState", lastWrittenEntryState). @@ -825,20 +827,20 @@ func (c *Config) defaultTemplateData() map[string]interface{} { if rawGroup, err := user.LookupGroupId(currentUser.Gid); err == nil { group = rawGroup.Name } else { - log.Info(). + c.logger.Info(). Str("gid", currentUser.Gid). Err(err). Msg("user.LookupGroupId") } } } else { - log.Info(). + c.logger.Info(). Err(err). Msg("user.Current") var ok bool username, ok = os.LookupEnv("USER") if !ok { - log.Info(). + c.logger.Info(). Str("key", "USER"). Bool("ok", ok). Msg("os.LookupEnv") @@ -851,14 +853,14 @@ func (c *Config) defaultTemplateData() map[string]interface{} { if rawHostname, err := os.Hostname(); err == nil { hostname = strings.SplitN(rawHostname, ".", 2)[0] } else { - log.Info(). + c.logger.Info(). Err(err). Msg("os.Hostname") } kernel, err := chezmoi.Kernel(c.fileSystem) if err != nil { - log.Info(). + c.logger.Info(). Err(err). Msg("chezmoi.Kernel") } @@ -867,7 +869,7 @@ func (c *Config) defaultTemplateData() map[string]interface{} { if rawOSRelease, err := chezmoi.OSRelease(c.baseSystem); err == nil { osRelease = upperSnakeCaseToCamelCaseMap(rawOSRelease) } else { - log.Info(). + c.logger.Info(). Err(err). Msg("chezmoi.OSRelease") } @@ -1322,6 +1324,7 @@ func (c *Config) newRootCmd() (*cobra.Command, error) { // newSourceState returns a new SourceState with options. func (c *Config) newSourceState(ctx context.Context, options ...chezmoi.SourceStateOption) (*chezmoi.SourceState, error) { + sourceStateLogger := c.logger.With().Str(logComponentKey, logComponentValueSourceState).Logger() s := chezmoi.NewSourceState(append([]chezmoi.SourceStateOption{ chezmoi.WithBaseSystem(c.baseSystem), chezmoi.WithCacheDir(c.CacheDirAbsPath), @@ -1329,6 +1332,7 @@ func (c *Config) newSourceState(ctx context.Context, options ...chezmoi.SourceSt chezmoi.WithDestDir(c.DestDirAbsPath), chezmoi.WithEncryption(c.encryption), chezmoi.WithInterpreters(c.Interpreters), + chezmoi.WithLogger(&sourceStateLogger), chezmoi.WithMode(c.Mode), chezmoi.WithPriorityTemplateData(c.Data), chezmoi.WithSourceDir(c.SourceDirAbsPath), @@ -1466,9 +1470,10 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error } else { zerolog.SetGlobalLevel(zerolog.Disabled) } + c.logger = &log.Logger // Log basic information. - log.Info(). + c.logger.Info(). Object("version", c.versionInfo). Strs("args", args). Str("goVersion", runtime.Version()). @@ -1478,7 +1483,7 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error chezmoi.RealSystemWithSafe(c.Safe), ) if c.debug { - systemLogger := log.With().Str(logComponentKey, logComponentValueSystem).Logger() + systemLogger := c.logger.With().Str(logComponentKey, logComponentValueSystem).Logger() c.baseSystem = chezmoi.NewDebugSystem(c.baseSystem, &systemLogger) } @@ -1527,7 +1532,7 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error c.persistentState = chezmoi.NullPersistentState{} } if c.debug && c.persistentState != nil { - persistentStateLogger := log.With().Str(logComponentKey, logComponentValuePersistentState).Logger() + persistentStateLogger := c.logger.With().Str(logComponentKey, logComponentValuePersistentState).Logger() c.persistentState = chezmoi.NewDebugPersistentState(c.persistentState, &persistentStateLogger) } @@ -1576,7 +1581,7 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error return fmt.Errorf("%s: unknown encryption", c.Encryption) } if c.debug { - encryptionLogger := log.With().Str(logComponentKey, logComponentValueEncryption).Logger() + encryptionLogger := c.logger.With().Str(logComponentKey, logComponentValueEncryption).Logger() c.encryption = chezmoi.NewDebugEncryption(c.encryption, &encryptionLogger) } @@ -1844,7 +1849,7 @@ func (c *Config) tempDir(key string) (chezmoi.AbsPath, error) { return tempDirAbsPath, nil } tempDir, err := os.MkdirTemp("", key) - log.Err(err). + c.logger.Err(err). Str("tempDir", tempDir). Msg("MkdirTemp") if err != nil { diff --git a/internal/cmd/initcmd.go b/internal/cmd/initcmd.go index 23488f1a3da..da3c094d3d9 100644 --- a/internal/cmd/initcmd.go +++ b/internal/cmd/initcmd.go @@ -13,7 +13,6 @@ import ( "github.com/go-git/go-git/v5/plumbing/transport" "github.com/go-git/go-git/v5/plumbing/transport/http" "github.com/rs/zerolog" - "github.com/rs/zerolog/log" "github.com/spf13/cobra" "github.com/twpayne/chezmoi/v2/internal/chezmoi" @@ -233,7 +232,7 @@ func (c *Config) builtinGitClone(username, url string, workingTreeRawPath chezmo for { _, err := git.PlainClone(workingTreeRawPath.String(), isBare, &cloneOptions) - log.Err(err). + c.logger.Err(err). Stringer("path", workingTreeRawPath). Bool("isBare", isBare). Object("o", loggableGitCloneOptions(cloneOptions)). @@ -263,7 +262,7 @@ func (c *Config) builtinGitClone(username, url string, workingTreeRawPath chezmo func (c *Config) builtinGitInit(workingTreeRawPath chezmoi.AbsPath) error { isBare := false _, err := git.PlainInit(workingTreeRawPath.String(), isBare) - log.Err(err). + c.logger.Err(err). Stringer("path", workingTreeRawPath). Bool("isBare", isBare). Msg("PlainInit") diff --git a/internal/cmd/statuscmd.go b/internal/cmd/statuscmd.go index b6dcbaf6b95..92b3ec0ceb7 100644 --- a/internal/cmd/statuscmd.go +++ b/internal/cmd/statuscmd.go @@ -4,7 +4,6 @@ import ( "fmt" "strings" - "github.com/rs/zerolog/log" "github.com/spf13/cobra" "github.com/twpayne/chezmoi/v2/internal/chezmoi" @@ -43,7 +42,7 @@ func (c *Config) runStatusCmd(cmd *cobra.Command, args []string, sourceState *ch builder := strings.Builder{} dryRunSystem := chezmoi.NewDryRunSystem(c.destSystem) statusCmdPreApplyFunc := func(targetRelPath chezmoi.RelPath, targetEntryState, lastWrittenEntryState, actualEntryState *chezmoi.EntryState) error { - log.Info(). + c.logger.Info(). Stringer("targetRelPath", targetRelPath). Object("targetEntryState", targetEntryState). Object("lastWrittenEntryState", lastWrittenEntryState). diff --git a/internal/cmd/testdata/scripts/debug.txt b/internal/cmd/testdata/scripts/debug.txt new file mode 100644 index 00000000000..23dee7cba2f --- /dev/null +++ b/internal/cmd/testdata/scripts/debug.txt @@ -0,0 +1,23 @@ +[!exec:age] skip 'age not found in $PATH' + +mkageconfig +mksourcedir + +httpd www + +# test that chezmoi apply --debug writes logs +chezmoi encrypt --output=$CHEZMOISOURCEDIR/encrypted_dot_encrypted.asc +chezmoi apply --debug +stderr component=encryption +stderr component=persistentState +stderr component=sourceState +stderr component=system + +-- golden/.encrypted -- +# contents of .encrypted +-- home/user/.local/share/chezmoi/.chezmoiexternal.yaml -- +.external: + type: file + url: {{ env "HTTPD_URL" }}/.external +-- www/.external -- +# contents of .external diff --git a/internal/cmd/upgradecmd.go b/internal/cmd/upgradecmd.go index 02c110f7701..904ed4061f3 100644 --- a/internal/cmd/upgradecmd.go +++ b/internal/cmd/upgradecmd.go @@ -24,7 +24,6 @@ import ( "github.com/coreos/go-semver/semver" "github.com/google/go-github/v39/github" - "github.com/rs/zerolog/log" "github.com/spf13/cobra" vfs "github.com/twpayne/go-vfs/v4" "golang.org/x/sys/unix" @@ -189,7 +188,7 @@ func (c *Config) runUpgradeCmd(cmd *cobra.Command, args []string) error { // Execute the new version. arg0 := path argv := []string{arg0, "--version"} - log.Info(). + c.logger.Info(). Str("arg0", arg0). Strs("argv", argv). Msg("exec") @@ -230,7 +229,7 @@ func (c *Config) downloadURL(ctx context.Context, url string) ([]byte, error) { return nil, err } resp, err := http.DefaultClient.Do(req) - log.Err(err). + c.logger.Err(err). Str("method", req.Method). Int("statusCode", resp.StatusCode). Str("status", resp.Status).
chore
Improve logging infrastructure
45c294d0819b35a2762f1b180e9ea8bca7cdc51c
2022-08-23 17:54:01
Tom Payne
chore: Generate configuration variables page from template and data
false
diff --git a/assets/chezmoi.io/.gitignore b/assets/chezmoi.io/.gitignore index b3c4a477d01..a9b0e1bb413 100644 --- a/assets/chezmoi.io/.gitignore +++ b/assets/chezmoi.io/.gitignore @@ -1,6 +1,7 @@ __pycache__ /docs/install.md /docs/links/articles-podcasts-and-videos.md +/docs/reference/configuration-file/variables.md /site /.venv diff --git a/assets/chezmoi.io/docs/hooks.py b/assets/chezmoi.io/docs/hooks.py index dd960156f0b..d021f7aea77 100644 --- a/assets/chezmoi.io/docs/hooks.py +++ b/assets/chezmoi.io/docs/hooks.py @@ -15,6 +15,7 @@ templates = [ "install.md", "links/articles-podcasts-and-videos.md", + "reference/configuration-file/variables.md", ] def on_pre_build(config, **kwargs): diff --git a/assets/chezmoi.io/docs/reference/configuration-file/variables.md b/assets/chezmoi.io/docs/reference/configuration-file/variables.md deleted file mode 100644 index 5d66f55e189..00000000000 --- a/assets/chezmoi.io/docs/reference/configuration-file/variables.md +++ /dev/null @@ -1,83 +0,0 @@ -# Variables - -The following configuration variables are available: - -| Section | Variable | Type | Default value | Description | -|---------------------|-----------------------|----------|--------------------------|--------------------------------------------------------| -| Top level | `color` | string | `auto` | Colorize output | -| | `data` | any | *none* | Template data | -| | `destDir` | string | `~` | Destination directory | -| | `encryption` | string | *none* | Encryption tool, either `age` or `gpg` | -| | `format` | string | `json` | Format for data output, either `json` or `yaml` | -| | `mode` | string | `file` | Mode in target dir, either `file` or `symlink` | -| | `scriptTempDir` | string | *none* | Temporary directory for scripts | -| | `sourceDir` | string | `~/.local/share/chezmoi` | Source directory | -| | `pager` | string | `$PAGER` | Default pager | -| | `umask` | int | *from system* | Umask | -| | `useBuiltinAge` | string | `auto` | Use builtin age if `age` command is not found in $PATH | -| | `useBuiltinGit` | string | `auto` | Use builtin git if `git` command is not found in $PATH | -| | `verbose` | bool | `false` | Make output more verbose | -| | `workingTree` | string | *source directory* | git working tree directory | -| `add` | `templateSymlinks` | bool | `false` | Template symlinks to source and home dirs | -| `age` | `args` | []string | *none* | Extra args to age CLI command | -| | `command` | string | `age` | age CLI command | -| | `identity` | string | *none* | age identity file | -| | `identities` | []string | *none* | age identity files | -| | `passphrase` | bool | `false` | Use age passphrase instead of identity | -| | `recipient` | string | *none* | age recipient | -| | `recipients` | []string | *none* | age recipients | -| | `recipientsFile` | []string | *none* | age recipients file | -| | `recipientsFiles` | []string | *none* | age recipients files | -| | `suffix` | string | `.age` | Suffix appended to age-encrypted files | -| | `symmetric` | bool | `false` | Use age symmetric encryption | -| `awsSecretsManager` | `profile` | string | *none* | The AWS shared profile name | -| | `region` | string | *none* | The AWS region | -| `bitwarden` | `command` | string | `bw` | Bitwarden CLI command | -| `cd` | `args` | []string | *none* | Extra args to shell in `cd` command | -| | `command` | string | *none* | Shell to run in `cd` command | -| `completion` | `custom` | bool | `false` | Enable custom shell completions | -| `diff` | `args` | []string | *see `diff` below* | Extra args to external diff command | -| | `command` | string | *none* | External diff command | -| | `exclude` | []string | *none* | Entry types to exclude from diffs | -| | `pager` | string | *none* | Diff-specific pager | -| | `reverse` | bool | `false` | Reverse order of arguments to diff | -| `edit` | `args` | []string | *none* | Extra args to edit command | -| | `command` | string | `$EDITOR` / `$VISUAL` | Edit command | -| | `hardlink` | bool | `true` | Invoke editor with a hardlink to the source file | -| | `minDuration` | duration | `1s` | Minimum duration for edit command | -| | `watch` | bool | `false` | Automatically apply changes when files are saved | -| `git` | `autoAdd ` | bool | `false` | Add changes to the source state after any change | -| | `autoCommit` | bool | `false` | Commit changes to the source state after any change | -| | `autoPush` | bool | `false` | Push changes to the source state after any change | -| | `command` | string | `git` | Source version control system | -| `gopass` | `command` | string | `gopass` | gopass CLI command | -| `gpg` | `args` | []string | *none* | Extra args to GPG CLI command | -| | `command` | string | `gpg` | GPG CLI command | -| | `recipient` | string | *none* | GPG recipient | -| | `recipients` | []string | *none* | GPG recipients | -| | `suffix` | string | `.asc` | Suffix appended to GPG-encrypted files | -| | `symmetric` | bool | `false` | Use symmetric GPG encryption | -| `interpreters` | *extension*`.args` | []string | *none* | See section on "Scripts on Windows" | -| | *extension*`.command` | string | *special* | See section on "Scripts on Windows" | -| `keepassxc` | `args` | []string | *none* | Extra args to KeePassXC CLI command | -| | `command` | string | `keepassxc-cli` | KeePassXC CLI command | -| | `database` | string | *none* | KeePassXC database | -| `keeper` | `args` | []string | *none* | Extra args to Keeper CLI command | -| | `command` | string | `keeper` | Keeper CLI command | -| `lastpass` | `command` | string | `lpass` | Lastpass CLI command | -| `merge` | `args` | []string | *see `merge` below* | Args to 3-way merge command | -| | `command` | string | `vimdiff` | 3-way merge command | -| `onepassword` | `cache` | bool | `true` | Enable optional caching provided by `op` | -| | `command` | string | `op` | 1Password CLI command | -| | `prompt` | bool | `true` | Prompt for sign-in when no valid session is available | -| `pass` | `command` | string | `pass` | Pass CLI command | -| `pinentry` | `args` | []string | *none* | Extra args to the pinentry command | -| | `command` | string | *none* | pinentry command | -| | `options` | []string | *see `pinentry` below* | Extra options for pinentry | -| `secret` | `command` | string | *none* | Generic secret command | -| `status` | `exclude` | []string | *none* | Entry types to exclude from status | -| `template` | `options` | []string | `["missingkey=error"]` | Template options | -| `textconv` | | []object | *none* | See section on "textconv" | -| `vault` | `command` | string | `vault` | Vault CLI command | -| `verify` | `exclude` | []string | *none* | Entry types to exclude from verify | - diff --git a/assets/chezmoi.io/docs/reference/configuration-file/variables.md.tmpl b/assets/chezmoi.io/docs/reference/configuration-file/variables.md.tmpl new file mode 100644 index 00000000000..0592db14319 --- /dev/null +++ b/assets/chezmoi.io/docs/reference/configuration-file/variables.md.tmpl @@ -0,0 +1,33 @@ +# Variables + +The following configuration variables are available: + +| Section | Variable | Type | Default value | Description | +| ------- | -------- | ---- | ------------- | ----------- | +{{ $lastSectionValue := "" -}} +{{ range $sectionName, $variables := .sections -}} +{{ $sectionValue := "" -}} +{{ if $sectionName -}} +{{ $sectionValue = printf "`%s`" $sectionName -}} +{{ else -}} +{{ $sectionValue = "Top level" -}} +{{ end -}} +{{ range $variableName, $variable := $variables -}} +{{ if eq $sectionValue $lastSectionValue -}} +{{ $sectionValue = "" -}} +{{ else -}} +{{ $lastSectionValue = $sectionValue -}} +{{ end -}} +{{ with $variable -}} +{{ $nameValue := $variableName -}} +{{ if regexMatch "\\A\\w+\\z" $nameValue -}} +{{ $nameValue = printf "`%s`" $nameValue -}} +{{ end -}} +{{ $defaultValue := "*none*" -}} +{{ if eq .type "bool" -}} +{{ $defaultValue = "`false`" -}} +{{ end -}} +| {{ $sectionValue }} | {{ $nameValue }} | {{ .type | default "string" }} | {{ .default | default $defaultValue }} | {{ .description }} | +{{ end -}} +{{ end -}} +{{ end }} diff --git a/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml b/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml new file mode 100644 index 00000000000..0d88886d074 --- /dev/null +++ b/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml @@ -0,0 +1,249 @@ +sections: + "": + color: + default: "`auto`" + description: "Colorize output" + data: + type: "any" + description: "Template data" + destDir: + default: "`~`" + description: "Destination directory" + encryption: + description: "Encryption type, either `age` or `gpg`" + format: + default: "`json`" + description: "Format for data output, either `json` or `yaml`" + mode: + default: "`file`" + description: "Mode in target dir, either `file` or `symlink`" + pager: + default: "`$PAGER`" + description: "Default pager CLI command" + scriptTempDir: + description: "Temporary directory for scripts" + sourceDir: + default: "`~/.local/share/chezmoi`" + description: "Source directory" + umask: + type: "int" + default: "*from system*" + description: "Umask" + useBuiltinAge: + default: "`auto`" + description: "Use builtin age if `age` command is not found in `$PATH`" + useBuiltinGit: + default: "`auto`" + description: "Use builtin git if `git` command is not found in `$PATH`" + verbose: + type: "bool" + description: "Make output more verbose" + workingTree: + default: "*source directory*" + description: "git working tree directory" + add: + templateSymlinks: + type: "bool" + description: "Template symlinks to source and home dirs" + age: + args: + type: "[]string" + description: "Extra args to age CLI command" + command: + default: "`age`" + description: "age CLI command" + identity: + description: "age identity file" + identities: + type: "[]string" + description: "age identity files" + passphrase: + type: "bool" + description: "Use age passphrase instead of identity" + recipient: + description: "age recipient" + recipients: + type: "[]string" + description: "age recipients" + recipientFile: + description: "age recipient file" + recipientFiles: + type: "[]string" + description: "age recipient files" + suffix: + default: "`.age`" + description: "Suffix appended to age-encrypted files" + symmetric: + type: "bool" + description: "Use age symmetric encryption" + awsSecretsManager: + profile: + description: "AWS shared profile name" + region: + description: "AWS region" + bitwarden: + command: + default: "`bw`" + description: "Bitwarden CLI command" + cd: + args: + type: "[]string" + description: "Extra args to shell in `cd` command" + command: + description: "Shell to run in `cd` command" + completion: + custom: + type: "bool" + description: "Enable custom shell completions" + diff: + args: + type: "[]string" + default: "*see `diff` below*" + description: "Extra args to external diff command" + command: + description: "External diff command" + exclude: + type: "[]string" + description: "Entry types to exclude from diffs" + pager: + description: "Diff-specific pager" + reverse: + type: "bool" + description: "Reverse order of arguments to diff" + edit: + args: + type: "[]string" + description: "Extra args to edit command" + command: + default: "`$EDITOR` / `$VISUAL`" + description: "Edit command" + hardlink: + type: "bool" + default: "`true`" + description: "Invoke editor with a hardlink to the source file" + minDuration: + type: "duration" + default: "`1s`" + description: "Minimum duration for edit command" + watch: + type: "bool" + description: "Automatically apply changes when files are saved" + git: + autoAdd: + type: "bool" + description: "Add changes to the source state after any change" + autoCommit: + type: "bool" + description: "Commit changes to the source state after any change" + autoPush: + type: "bool" + description: "Push changes to the source state after any change" + command: + default: "`git`" + description: "git CLI command" + gopass: + command: + default: "`gopass`" + description: "gopass CLI command" + gpg: + args: + type: "[]string" + description: "Extra args to GPG CLI command" + command: + default: "`gpg`" + description: "GPG CLI command" + recipient: + description: "GPG recipient" + recipients: + type: "[]string" + description: "GPG recipients" + suffix: + default: "`.asc`" + description: "Suffix appended to GPG-encrypted files" + symmetric: + type: "bool" + description: "Use symmetric GPG encryption" + interpreters: + "*extension*.`args`": + type: "[]string" + description: "See section on \"Scripts on Windows\"" + "*extension*.`command`": + default: "*special*" + description: "See section on \"Scripts on Windows\"" + keepassxc: + args: + type: "[]string" + description: "Extra args to KeePassXC CLI command" + command: + default: "`keepassxc-cli`" + description: "KeePassXC CLI command" + database: + description: "KeePassXC database" + keeper: + args: + type: "[]string" + description: "Extra args to Keeper CLI command" + command: + default: "`keeper`" + description: "Keeper CLI command" + lastpass: + command: + default: "`lpass`" + description: "LastPass CLI command" + merge: + args: + type: "[]string" + default: "*see `merge` below*" + description: "Extra args to three-way merge CLI command" + command: + description: "Three-way merge CLI command" + onepassword: + cache: + type: "bool" + default: "`true`" + description: "Enable optional caching provided by `op`" + command: + default: "`op`" + description: "1Password CLI command" + prompt: + type: "bool" + default: "`true`" + description: "Prompt for sign-in when no valid session is available" + pass: + command: + default: "`pass`" + description: "Pass CLI command" + pinentry: + args: + type: "[]string" + description: "Extra args to pinentry CLI command" + command: + description: "pinentry CLI command" + options: + type: "[]string" + default: "*see `pinentry` below*" + description: "Extra options for pinentry" + secret: + command: + description: "Generic secret CLI command" + status: + exclude: + type: "[]string" + description: "Entry types to exclude from status" + template: + options: + type: "[]string" + default: "`[\"missingkey=error\"]`" + description: "Template options" + textconv: + "": + type: "[]object" + description: "See section on \"textconv\"" + vault: + command: + default: "`vault`" + description: "Vault CLI command" + verify: + exclude: + type: "[]string" + description: "Entry types to exclude from verify" diff --git a/assets/chezmoi.io/docs/user-guide/password-managers/lastpass.md b/assets/chezmoi.io/docs/user-guide/password-managers/lastpass.md index a37bb0bcbb9..b33cb19020d 100644 --- a/assets/chezmoi.io/docs/user-guide/password-managers/lastpass.md +++ b/assets/chezmoi.io/docs/user-guide/password-managers/lastpass.md @@ -29,7 +29,7 @@ the field you want. For example, to extract the `password` field from first the githubPassword = {{ (index (lastpass "GitHub") 0).password | quote }} ``` -chezmoi automatically parses the `note` value of the Lastpass entry as +chezmoi automatically parses the `note` value of the LastPass entry as colon-separated key-value pairs, so, for example, you can extract a private SSH key like this:
chore
Generate configuration variables page from template and data
9e4629f932b45a6cfbd88f2dc91aca20e1f239a6
2022-08-07 02:47:11
Tom Payne
feat: Add --interactive flag
false
diff --git a/assets/chezmoi.io/docs/reference/command-line-flags/common.md b/assets/chezmoi.io/docs/reference/command-line-flags/common.md index 68e70f4dd23..a4bf77d3a52 100644 --- a/assets/chezmoi.io/docs/reference/command-line-flags/common.md +++ b/assets/chezmoi.io/docs/reference/command-line-flags/common.md @@ -23,6 +23,10 @@ with a `no`. Regenerate and reread the config file from the config file template before computing the target state. +## `--interactive` + +Prompt before applying each target. + ## `-r`, `--recursive` Recurse into subdirectories, `true` by default. diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index 1cc28b9fbd3..615b38a8f92 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -131,6 +131,7 @@ type Config struct { force bool gops bool homeDir string + interactive bool keepGoing bool noPager bool noTTY bool @@ -846,13 +847,54 @@ func (c *Config) defaultPreApplyFunc( Object("actualEntryState", actualEntryState). Msg("defaultPreApplyFunc") + switch { + case c.force: + return nil + case targetEntryState.Equivalent(actualEntryState): + return nil + } + + if c.interactive { + prompt := fmt.Sprintf("Apply %s", targetRelPath) + actualContents := actualEntryState.Contents() + var choices []string + targetContents := targetEntryState.Contents() + if actualContents != nil || targetContents != nil { + choices = append(choices, "diff") + } + choices = append(choices, choicesYesNoAllQuit...) + for { + switch choice, err := c.promptChoice(prompt, choices); { + case err != nil: + return err + case choice == "diff": + if err := c.diffFile( + targetRelPath, + actualContents, actualEntryState.Mode, + targetContents, targetEntryState.Mode, + ); err != nil { + return err + } + case choice == "yes": + return nil + case choice == "no": + return chezmoi.Skip + case choice == "all": + c.interactive = false + return nil + case choice == "quit": + return chezmoi.ExitCodeError(0) + default: + panic(fmt.Sprintf("%s: unexpected choice", choice)) + } + } + } + switch { case targetEntryState.Overwrite(): return nil case targetEntryState.Type == chezmoi.EntryStateTypeScript: return nil - case c.force: - return nil case lastWrittenEntryState == nil: return nil case lastWrittenEntryState.Equivalent(actualEntryState): @@ -1353,6 +1395,7 @@ func (c *Config) newRootCmd() (*cobra.Command, error) { persistentFlags.BoolVarP(&c.dryRun, "dry-run", "n", c.dryRun, "Do not make any modifications to the destination directory") //nolint:lll persistentFlags.BoolVar(&c.force, "force", c.force, "Make all changes without prompting") persistentFlags.BoolVar(&c.gops, "gops", c.gops, "Enable gops agent") + persistentFlags.BoolVar(&c.interactive, "interactive", c.interactive, "Prompt for all changes") persistentFlags.BoolVarP(&c.keepGoing, "keep-going", "k", c.keepGoing, "Keep going as far as possible after an error") persistentFlags.BoolVar(&c.noPager, "no-pager", c.noPager, "Do not use the pager") persistentFlags.BoolVar(&c.noTTY, "no-tty", c.noTTY, "Do not attempt to get a TTY for reading passwords")
feat
Add --interactive flag
2920b169b8d3eba5b913515172ceccc64232b452
2022-09-08 06:23:09
Tom Payne
chore: Clean up ageencryption.go
false
diff --git a/pkg/chezmoi/ageencryption.go b/pkg/chezmoi/ageencryption.go index c0e19727cd5..78c46bdafa8 100644 --- a/pkg/chezmoi/ageencryption.go +++ b/pkg/chezmoi/ageencryption.go @@ -110,10 +110,10 @@ func (e *AgeEncryption) builtinDecrypt(ciphertext []byte) ([]byte, error) { return nil, err } buffer := &bytes.Buffer{} - if _, err = io.Copy(buffer, r); err != nil { + if _, err := io.Copy(buffer, r); err != nil { return nil, err } - return buffer.Bytes(), err + return buffer.Bytes(), nil } // builtinEncrypt encrypts ciphertext using the builtin age. @@ -124,14 +124,14 @@ func (e *AgeEncryption) builtinEncrypt(plaintext []byte) ([]byte, error) { } output := &bytes.Buffer{} armorWriter := armor.NewWriter(output) - writer, err := age.Encrypt(armorWriter, recipients...) + writeCloser, err := age.Encrypt(armorWriter, recipients...) if err != nil { return nil, err } - if _, err := io.Copy(writer, bytes.NewReader(plaintext)); err != nil { + if _, err := io.Copy(writeCloser, bytes.NewReader(plaintext)); err != nil { return nil, err } - if err := writer.Close(); err != nil { + if err := writeCloser.Close(); err != nil { return nil, err } if err := armorWriter.Close(); err != nil {
chore
Clean up ageencryption.go
adfacfe902a1af1126476fafbe0645e23567e5b9
2021-11-15 03:16:06
Tom Payne
chore: Update dependencies
false
diff --git a/go.mod b/go.mod index 0b0ba33f28a..b3fbc5c1cc5 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.16 require ( filippo.io/age v1.0.0 github.com/Masterminds/sprig/v3 v3.2.2 - github.com/ProtonMail/go-crypto v0.0.0-20210920160938-87db9fbc61c7 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20211112122917-428f8eabeeb3 // indirect github.com/alecthomas/chroma v0.9.4 // indirect github.com/bmatcuk/doublestar/v4 v4.0.2 github.com/bradenhilton/mozillainstallhash v1.0.0 @@ -36,14 +36,14 @@ require ( github.com/twpayne/go-vfs/v4 v4.1.0 github.com/twpayne/go-xdg/v6 v6.0.0 github.com/xanzy/ssh-agent v0.3.1 // indirect - github.com/yuin/goldmark v1.4.2 // indirect + github.com/yuin/goldmark v1.4.4 // indirect github.com/zalando/go-keyring v0.1.1 go.etcd.io/bbolt v1.3.6 go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.7.0 - golang.org/x/net v0.0.0-20211105192438-b53810dc28af // indirect + golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 - golang.org/x/sys v0.0.0-20211107104306-e0b2ad06fe42 + golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b @@ -53,13 +53,15 @@ require ( require ( github.com/Microsoft/go-winio v0.5.1 // indirect github.com/godbus/dbus/v5 v5.0.6 // indirect + github.com/google/go-github/v40 v40.0.0 // indirect github.com/google/gops v0.3.22 github.com/mattn/go-isatty v0.0.14 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/stretchr/objx v0.3.0 // indirect github.com/twpayne/go-pinentry v0.0.2 - golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect + golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa // indirect golang.org/x/text v0.3.7 // indirect + gopkg.in/ini.v1 v1.64.0 // indirect ) exclude github.com/sergi/go-diff v1.2.0 // Produces incorrect diffs diff --git a/go.sum b/go.sum index d6656dc3a5d..061e1dc2702 100644 --- a/go.sum +++ b/go.sum @@ -74,6 +74,8 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= github.com/ProtonMail/go-crypto v0.0.0-20210920160938-87db9fbc61c7 h1:DSqTh6nEes/uO8BlNcGk8PzZsxY2sN9ZL//veWBdTRI= github.com/ProtonMail/go-crypto v0.0.0-20210920160938-87db9fbc61c7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= +github.com/ProtonMail/go-crypto v0.0.0-20211112122917-428f8eabeeb3 h1:XcF0cTDJeiuZ5NU8w7WUDge0HRwwNRmxj/GGk6KSA6g= +github.com/ProtonMail/go-crypto v0.0.0-20211112122917-428f8eabeeb3/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= @@ -256,6 +258,8 @@ github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-github/v39 v39.2.0 h1:rNNM311XtPOz5rDdsJXAp2o8F67X9FnROXTvto3aSnQ= github.com/google/go-github/v39 v39.2.0/go.mod h1:C1s8C5aCC9L+JXIYpJM5GYytdX52vC1bLvHEF1IhBrE= +github.com/google/go-github/v40 v40.0.0 h1:oBPVDaIhdUmwDWRRH8XJ/dZG+Rn755i08+Hp1uJHlR0= +github.com/google/go-github/v40 v40.0.0/go.mod h1:G8wWKTEjUCL0zdbaQvpwDk0hqf6KZgPQH+ssJa+/NVc= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= @@ -583,6 +587,8 @@ github.com/yuin/goldmark v1.4.1 h1:/vn0k+RBvwlxEmP5E7SZMqNxPhfMVFEJiykr15/0XKM= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.2 h1:5qVKCqCRBaGz8EepBTi7pbIw8gGCFnB1Mi6kXU4dYv8= github.com/yuin/goldmark v1.4.2/go.mod h1:rmuwmfZ0+bvzB24eSC//bk1R1Zp3hM0OXYv/G2LIilg= +github.com/yuin/goldmark v1.4.4 h1:zNWRjYUW32G9KirMXYHQHVNFkXvMI7LpgNW2AgYAoIs= +github.com/yuin/goldmark v1.4.4/go.mod h1:rmuwmfZ0+bvzB24eSC//bk1R1Zp3hM0OXYv/G2LIilg= github.com/yuin/goldmark-emoji v1.0.1 h1:ctuWEyzGBwiucEqxzwe0SOYDXPAucOrE9NQC18Wa1os= github.com/yuin/goldmark-emoji v1.0.1/go.mod h1:2w1E6FEWLcDQkoTE+7HU6QF1F6SLlNGjRIBbIZQFqkQ= github.com/zalando/go-keyring v0.1.1 h1:w2V9lcx/Uj4l+dzAf1m9s+DJ1O8ROkEHnynonHjTcYE= @@ -629,6 +635,8 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa h1:idItI2DDfCokpg0N51B2VtiLdJ4vAuXC9fnCb2gACo4= +golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -717,6 +725,8 @@ golang.org/x/net v0.0.0-20211029224645-99673261e6eb h1:pirldcYWx7rx7kE5r+9WsOXPX golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211105192438-b53810dc28af h1:SMeNJG/vclJ5wyBBd4xupMsSJIHTd1coW9g7q6KOjmY= golang.org/x/net v0.0.0-20211105192438-b53810dc28af/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -828,6 +838,8 @@ golang.org/x/sys v0.0.0-20211031064116-611d5d643895 h1:iaNpwpnrgL5jzWS0vCNnfa8Hq golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211107104306-e0b2ad06fe42 h1:G2DDmludOQZoWbpCr7OKDxnl478ZBGMcOhrv+ooX/Q4= golang.org/x/sys v0.0.0-20211107104306-e0b2ad06fe42/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02 h1:7NCfEGl0sfUojmX78nK9pBJuUlSZWEJA/TwASvfiPLo= +golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= @@ -1053,6 +1065,8 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c= gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.64.0 h1:Mj2zXEXcNb5joEiSA0zc3HZpTst/iyjNiR4CN8tDzOg= +gopkg.in/ini.v1 v1.64.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/cmd/githubtemplatefuncs.go b/internal/cmd/githubtemplatefuncs.go index b0f1b1a23bd..da35518c42e 100644 --- a/internal/cmd/githubtemplatefuncs.go +++ b/internal/cmd/githubtemplatefuncs.go @@ -3,7 +3,7 @@ package cmd import ( "context" - "github.com/google/go-github/v39/github" + "github.com/google/go-github/v40/github" ) type gitHubData struct { diff --git a/internal/cmd/upgradecmd.go b/internal/cmd/upgradecmd.go index 24ae83ff940..282f4f4f225 100644 --- a/internal/cmd/upgradecmd.go +++ b/internal/cmd/upgradecmd.go @@ -23,7 +23,7 @@ import ( "syscall" "github.com/coreos/go-semver/semver" - "github.com/google/go-github/v39/github" + "github.com/google/go-github/v40/github" "github.com/spf13/cobra" vfs "github.com/twpayne/go-vfs/v4" "go.uber.org/multierr" diff --git a/internal/cmd/util.go b/internal/cmd/util.go index c4bddbe93d6..15657a51597 100644 --- a/internal/cmd/util.go +++ b/internal/cmd/util.go @@ -10,7 +10,7 @@ import ( "strings" "unicode" - "github.com/google/go-github/v39/github" + "github.com/google/go-github/v40/github" "golang.org/x/oauth2" )
chore
Update dependencies
322ec3aef73868171b2e21ec74810ead987ec8ae
2021-11-04 05:38:44
Tom Payne
chore: Refine caching of VirtualBox images
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ed11335bee1..9a789d0cbae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,6 +29,8 @@ jobs: - '**/*.go' - '.github/workflows/**' - 'go.*' + - 'assets/docker/**' + - 'assets/vagrant/**' - 'internal/**' codeql: needs: changes @@ -70,7 +72,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.vagrant.d - key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/*.Vagrantfile') }} + key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/debian11-i386.Vagrantfile') }} restore-keys: | ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}- - name: Test @@ -99,7 +101,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.vagrant.d - key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/*.Vagrantfile') }} + key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/freebsd13.Vagrantfile') }} restore-keys: | ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}- - name: Test @@ -151,7 +153,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.vagrant.d - key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/*.Vagrantfile') }} + key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/openbsd6.Vagrantfile') }} restore-keys: | ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}- - name: Test @@ -170,7 +172,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.vagrant.d - key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/*.Vagrantfile') }} + key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/openindiana.Vagrantfile') }} restore-keys: | ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}- - name: Test
chore
Refine caching of VirtualBox images
3073efc375a940b84b710d708de11a3fdc33a537
2023-02-26 05:04:40
Tom Payne
chore: Update dependencies
false
diff --git a/go.mod b/go.mod index 090ee7be40c..cb66c9ec84f 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/coreos/go-semver v0.3.1 github.com/fsnotify/fsnotify v1.6.0 github.com/go-git/go-git/v5 v5.5.2 - github.com/google/go-github/v50 v50.0.0 + github.com/google/go-github/v50 v50.1.0 github.com/google/renameio/v2 v2.0.0 github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 github.com/klauspost/compress v1.15.15 @@ -31,15 +31,15 @@ require ( github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.1 github.com/twpayne/go-pinentry v0.2.0 - github.com/twpayne/go-vfs/v4 v4.1.0 - github.com/twpayne/go-xdg/v6 v6.1.0 + github.com/twpayne/go-vfs/v4 v4.2.0 + github.com/twpayne/go-xdg/v6 v6.1.1 github.com/ulikunitz/xz v0.5.11 github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1 github.com/zalando/go-keyring v0.2.2 go.etcd.io/bbolt v1.3.7 go.uber.org/multierr v1.9.0 golang.org/x/crypto v0.6.0 - golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb + golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 golang.org/x/oauth2 v0.5.0 golang.org/x/sync v0.1.0 golang.org/x/sys v0.5.0 @@ -55,7 +55,7 @@ require ( github.com/Masterminds/semver/v3 v3.2.0 // indirect github.com/Microsoft/go-winio v0.6.0 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect - github.com/acomagu/bufpipe v1.0.3 // indirect + github.com/acomagu/bufpipe v1.0.4 // indirect github.com/alecthomas/chroma v0.10.0 // indirect github.com/alessio/shellescape v1.4.1 // indirect github.com/atotto/clipboard v0.1.4 // indirect diff --git a/go.sum b/go.sum index 9e89c35c3ee..b959ac8397c 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,9 @@ github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2B github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4/go.mod h1:UBYPn8k0D56RtnR8RFQMjmh4KrZzWJ5o7Z9SYjossQ8= github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA= github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= -github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= +github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= +github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek= github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s= github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0= @@ -129,8 +130,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-github/v50 v50.0.0 h1:gdO1AeuSZZK4iYWwVbjni7zg8PIQhp7QfmPunr016Jk= -github.com/google/go-github/v50 v50.0.0/go.mod h1:Ev4Tre8QoKiolvbpOSG3FIi4Mlon3S2Nt9W5JYqKiwA= +github.com/google/go-github/v50 v50.1.0 h1:hMUpkZjklC5GJ+c3GquSqOP/T4BNsB7XohaPhtMOzRk= +github.com/google/go-github/v50 v50.1.0/go.mod h1:Ev4Tre8QoKiolvbpOSG3FIi4Mlon3S2Nt9W5JYqKiwA= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg= @@ -278,10 +279,10 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/twpayne/go-pinentry v0.2.0 h1:hS5NEJiilop9xP9pBX/1NYduzDlGGMdg1KamTBTrOWw= github.com/twpayne/go-pinentry v0.2.0/go.mod h1:r6buhMwARxnnL0VRBqfd1tE6Fadk1kfP00GRMutEspY= -github.com/twpayne/go-vfs/v4 v4.1.0 h1:58tmzvh3AEKgqXlRZvlKn9HD6g1Q9T9bYdob0GhARrs= -github.com/twpayne/go-vfs/v4 v4.1.0/go.mod h1:05bOnh2SNnRsIp/ensn6WLeHSttxklPlQzi4JtTGofc= -github.com/twpayne/go-xdg/v6 v6.1.0 h1:wVrjilk/sBafdn4le6m3xPqmPYgiFHuTPJJCFemcxwY= -github.com/twpayne/go-xdg/v6 v6.1.0/go.mod h1:7fSwQVnjit0VWjeKqQax8FQkaF0+A/XR4dV6cYRVUyU= +github.com/twpayne/go-vfs/v4 v4.2.0 h1:cIjUwaKSCq0y6dT+ev6uLSmKjGTbHCR4xaocROqHFsE= +github.com/twpayne/go-vfs/v4 v4.2.0/go.mod h1:zEoSYKpoOQmqu2Rrjclu2TlDEK+I5ydlh58sGdPKNYI= +github.com/twpayne/go-xdg/v6 v6.1.1 h1:OzoxnDWEaqO1b32F8zZaDj3aJWgWyTsL8zOiun7UK3w= +github.com/twpayne/go-xdg/v6 v6.1.1/go.mod h1:+0KSJ4Dx+xaZeDXWZITF84BcNc1UiHDm0DP8txprfD8= github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1 h1:+dBg5k7nuTE38VVdoroRsT0Z88fmvdYrI2EjzJst35I= @@ -312,8 +313,8 @@ golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w= -golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 h1:Jvc7gsqn21cJHCmAWx0LiimpP18LZmUxkT5Mp7EZ1mI= +golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= @@ -342,7 +343,6 @@ golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
chore
Update dependencies
d70de7aee493aac5929f279eb3d6518656997119
2021-11-30 04:35:59
Tom Payne
feat: Extend upgrade command to work on more operating systems
false
diff --git a/internal/chezmoi/abspath.go b/internal/chezmoi/abspath.go index f09604917dc..30e863c484a 100644 --- a/internal/chezmoi/abspath.go +++ b/internal/chezmoi/abspath.go @@ -36,6 +36,11 @@ func NewAbsPath(absPath string) AbsPath { } } +// Append appends s to p. +func (p AbsPath) Append(s string) AbsPath { + return NewAbsPath(p.absPath + s) +} + // Base returns p's basename. func (p AbsPath) Base() string { return path.Base(p.absPath) diff --git a/internal/cmd/noupgradecmd.go b/internal/cmd/noupgradecmd.go index 2a0b8dde39a..e36d3ab3520 100644 --- a/internal/cmd/noupgradecmd.go +++ b/internal/cmd/noupgradecmd.go @@ -1,5 +1,5 @@ -//go:build noupgrade || windows -// +build noupgrade windows +//go:build noupgrade +// +build noupgrade package cmd diff --git a/internal/cmd/testdata/scripts/upgrade.txt b/internal/cmd/testdata/scripts/upgrade.txt new file mode 100644 index 00000000000..438c00e13f9 --- /dev/null +++ b/internal/cmd/testdata/scripts/upgrade.txt @@ -0,0 +1,8 @@ +[!env:CHEZMOI_GITHUB_TOKEN] skip '$CHEZMOI_GITHUB_TOKEN not set' + +# test that chezmoi upgrade succeeds +chezmoi upgrade --executable=$WORK${/}chezmoi$exe --method=replace-executable +exec $WORK/chezmoi$exe --version + +-- chezmoi -- +-- chezmoi.exe -- diff --git a/internal/cmd/upgradecmd.go b/internal/cmd/upgradecmd.go index ffb67740268..a9e968d144d 100644 --- a/internal/cmd/upgradecmd.go +++ b/internal/cmd/upgradecmd.go @@ -1,33 +1,29 @@ -//go:build !noupgrade && !windows -// +build !noupgrade,!windows +//go:build !noupgrade +// +build !noupgrade package cmd import ( - "archive/tar" "bufio" "bytes" - "compress/gzip" "context" "crypto/sha256" "encoding/hex" "errors" "fmt" "io" + "io/fs" "net/http" "os" "os/exec" "regexp" "runtime" "strings" - "syscall" "github.com/coreos/go-semver/semver" "github.com/google/go-github/v40/github" "github.com/spf13/cobra" vfs "github.com/twpayne/go-vfs/v4" - "go.uber.org/multierr" - "golang.org/x/sys/unix" "github.com/twpayne/chezmoi/v2/internal/chezmoi" ) @@ -82,9 +78,10 @@ var ( ) type upgradeCmdConfig struct { - method string - owner string - repo string + executable string + method string + owner string + repo string } func (c *Config) newUpgradeCmd() *cobra.Command { @@ -101,6 +98,7 @@ func (c *Config) newUpgradeCmd() *cobra.Command { } flags := upgradeCmd.Flags() + flags.StringVar(&c.upgrade.executable, "executable", c.upgrade.method, "Set executable to replace") flags.StringVar(&c.upgrade.method, "method", c.upgrade.method, "Set upgrade method") flags.StringVar(&c.upgrade.owner, "owner", c.upgrade.owner, "Set owner") flags.StringVar(&c.upgrade.repo, "repo", c.upgrade.repo, "Set repo") @@ -140,11 +138,15 @@ func (c *Config) runUpgradeCmd(cmd *cobra.Command, args []string) error { } // Determine the upgrade method to use. - executable, err := os.Executable() - if err != nil { - return err + if c.upgrade.executable == "" { + executable, err := os.Executable() + if err != nil { + return err + } + c.upgrade.executable = executable } - executableAbsPath := chezmoi.NewAbsPath(executable) + + executableAbsPath := chezmoi.NewAbsPath(c.upgrade.executable) method := c.upgrade.method if method == "" { switch method, err = getUpgradeMethod(c.fileSystem, executableAbsPath); { @@ -155,7 +157,7 @@ func (c *Config) runUpgradeCmd(cmd *cobra.Command, args []string) error { } } c.logger.Info(). - Str("executable", executable). + Str("executable", c.upgrade.executable). Str("method", method). Msg("upgradeMethod") @@ -189,7 +191,7 @@ func (c *Config) runUpgradeCmd(cmd *cobra.Command, args []string) error { // Find the executable. If we replaced the executable directly, then use // that, otherwise look in $PATH. - path := executable + path := c.upgrade.executable if method != upgradeMethodReplaceExecutable { path, err = exec.LookPath(c.upgrade.repo) if err != nil { @@ -198,17 +200,11 @@ func (c *Config) runUpgradeCmd(cmd *cobra.Command, args []string) error { } // Execute the new version. - arg0 := path - argv := []string{arg0, "--version"} - c.logger.Info(). - Str("arg0", arg0). - Strs("argv", argv). - Msg("exec") - err = unix.EINTR - for errors.Is(err, unix.EINTR) { - err = unix.Exec(arg0, argv, os.Environ()) - } - return err + chezmoiVersionCmd := exec.Command(path, "--version") + chezmoiVersionCmd.Stdin = os.Stdin + chezmoiVersionCmd.Stdout = os.Stdout + chezmoiVersionCmd.Stderr = os.Stderr + return c.baseSystem.RunIdempotentCmd(chezmoiVersionCmd) } func (c *Config) brewUpgrade() error { @@ -294,10 +290,8 @@ func (c *Config) getLibc() (string, error) { // Second, try getconf GNU_LIBC_VERSION. getconfCmd := exec.Command("getconf", "GNU_LIBC_VERSION") - if output, err := c.baseSystem.IdempotentCmdOutput(getconfCmd); err != nil { - if libcTypeGlibcRx.Match(output) { - return libcTypeGlibc, nil - } + if output, _ := c.baseSystem.IdempotentCmdOutput(getconfCmd); libcTypeGlibcRx.Match(output) { + return libcTypeGlibc, nil } return "", errors.New("unable to determine libc") @@ -323,55 +317,73 @@ func (c *Config) replaceExecutable( ctx context.Context, executableFilenameAbsPath chezmoi.AbsPath, releaseVersion *semver.Version, rr *github.RepositoryRelease, ) (err error) { - goos := runtime.GOOS - if goos == "linux" && runtime.GOARCH == "amd64" { + var archiveFormat chezmoi.ArchiveFormat + var archiveName string + switch { + case runtime.GOOS == "windows": + archiveFormat = chezmoi.ArchiveFormatZip + archiveName = fmt.Sprintf("%s_%s_%s_%s.zip", c.upgrade.repo, releaseVersion, runtime.GOOS, runtime.GOARCH) + case runtime.GOOS == "linux" && runtime.GOARCH == "amd64": + archiveFormat = chezmoi.ArchiveFormatTarGz var libc string if libc, err = c.getLibc(); err != nil { return } - goos += "-" + libc + archiveName = fmt.Sprintf("%s_%s_%s-%s_%s.tar.gz", c.upgrade.repo, releaseVersion, runtime.GOOS, libc, runtime.GOARCH) + case runtime.GOOS == "linux" && runtime.GOARCH == "386": + archiveFormat = chezmoi.ArchiveFormatTarGz + archiveName = fmt.Sprintf("%s_%s_%s_i386.tar.gz", c.upgrade.repo, releaseVersion, runtime.GOOS) + default: + archiveFormat = chezmoi.ArchiveFormatTarGz + archiveName = fmt.Sprintf("%s_%s_%s_%s.tar.gz", c.upgrade.repo, releaseVersion, runtime.GOOS, runtime.GOARCH) } - name := fmt.Sprintf("%s_%s_%s_%s.tar.gz", c.upgrade.repo, releaseVersion, goos, runtime.GOARCH) - releaseAsset := getReleaseAssetByName(rr, name) + releaseAsset := getReleaseAssetByName(rr, archiveName) if releaseAsset == nil { - err = fmt.Errorf("%s: cannot find release asset", name) + err = fmt.Errorf("%s: cannot find release asset", archiveName) return } - var data []byte - if data, err = c.downloadURL(ctx, releaseAsset.GetBrowserDownloadURL()); err != nil { - return err + var archiveData []byte + if archiveData, err = c.downloadURL(ctx, releaseAsset.GetBrowserDownloadURL()); err != nil { + return } - if err = c.verifyChecksum(ctx, rr, releaseAsset.GetName(), data); err != nil { - return err + if err = c.verifyChecksum(ctx, rr, releaseAsset.GetName(), archiveData); err != nil { + return } // Extract the executable from the archive. - var gzipReader *gzip.Reader - if gzipReader, err = gzip.NewReader(bytes.NewReader(data)); err != nil { - return err - } - defer func() { - err = multierr.Append(err, gzipReader.Close()) - }() - tarReader := tar.NewReader(gzipReader) var executableData []byte -FOR: - for { - var header *tar.Header - switch header, err = tarReader.Next(); { - case err == nil && header.Name == c.upgrade.repo: - if executableData, err = io.ReadAll(tarReader); err != nil { - return + walkArchiveFunc := func(name string, info fs.FileInfo, r io.Reader, linkname string) error { + switch { + case runtime.GOOS != "windows" && name == c.upgrade.repo: + fallthrough + case runtime.GOOS == "windows" && name == c.upgrade.repo+".exe": + var err error + executableData, err = io.ReadAll(r) + if err != nil { + return err } - break FOR - case errors.Is(err, io.EOF): - err = fmt.Errorf("%s: could not find header", c.upgrade.repo) - return + return chezmoi.Break + default: + return nil } } + if err = chezmoi.WalkArchive(archiveData, archiveFormat, walkArchiveFunc); err != nil { + return + } + if executableData == nil { + err = fmt.Errorf("%s: cannot find executable in archive", archiveName) + return + } + // Replace the executable. + if runtime.GOOS == "windows" { + if err = c.baseSystem.Rename(executableFilenameAbsPath, executableFilenameAbsPath.Append(".old")); err != nil { + return + } + } err = c.baseSystem.WriteFile(executableFilenameAbsPath, executableData, 0o755) + return } @@ -479,14 +491,18 @@ func getUpgradeMethod(fileSystem vfs.Stater, executableAbsPath chezmoi.AbsPath) // If the executable is in the user's home directory, then always use // replace-executable. - userHomeDir, err := os.UserHomeDir() - if err != nil { + switch userHomeDir, err := os.UserHomeDir(); { + case errors.Is(err, fs.ErrNotExist): + case err != nil: return "", err - } - if executableInUserHomeDir, err := vfs.Contains(fileSystem, executableAbsPath.String(), userHomeDir); err != nil { - return "", err - } else if executableInUserHomeDir { - return upgradeMethodReplaceExecutable, nil + default: + switch executableInUserHomeDir, err := vfs.Contains(fileSystem, executableAbsPath.String(), userHomeDir); { + case errors.Is(err, fs.ErrNotExist): + case err != nil: + return "", err + case executableInUserHomeDir: + return upgradeMethodReplaceExecutable, nil + } } // If the executable is in the system's temporary directory, then always use @@ -506,15 +522,12 @@ func getUpgradeMethod(fileSystem vfs.Stater, executableAbsPath chezmoi.AbsPath) if ok, _ := vfs.Contains(fileSystem, executableAbsPath.String(), "/snap"); ok { return upgradeMethodSnapRefresh, nil } - fileInfo, err := fileSystem.Stat(executableAbsPath.String()) if err != nil { return "", err } - //nolint:forcetypeassert - executableStat := fileInfo.Sys().(*syscall.Stat_t) uid := os.Getuid() - switch int(executableStat.Uid) { + switch fileInfoUID(fileInfo) { case 0: method := upgradeMethodUpgradePackage if uid != 0 { diff --git a/internal/cmd/util_unix.go b/internal/cmd/util_unix.go index 1124ef2437d..67b9bb92fc1 100644 --- a/internal/cmd/util_unix.go +++ b/internal/cmd/util_unix.go @@ -5,6 +5,8 @@ package cmd import ( "io" + "io/fs" + "syscall" "github.com/twpayne/chezmoi/v2/internal/chezmoi" ) @@ -17,3 +19,7 @@ var defaultInterpreters = make(map[string]*chezmoi.Interpreter) func enableVirtualTerminalProcessing(w io.Writer) error { return nil } + +func fileInfoUID(info fs.FileInfo) int { + return int(info.Sys().(*syscall.Stat_t).Uid) +} diff --git a/internal/cmd/util_windows.go b/internal/cmd/util_windows.go index 4db388573d8..aade8ba64d6 100644 --- a/internal/cmd/util_windows.go +++ b/internal/cmd/util_windows.go @@ -2,6 +2,7 @@ package cmd import ( "io" + "io/fs" "os" "golang.org/x/sys/windows" @@ -44,3 +45,7 @@ func enableVirtualTerminalProcessing(w io.Writer) error { } return windows.SetConsoleMode(windows.Handle(file.Fd()), dwMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING) } + +func fileInfoUID(fs.FileInfo) int { + return 0 +}
feat
Extend upgrade command to work on more operating systems
efcf32d79da5c354cd24dcacfe4747bdcc0a6737
2024-01-24 14:44:35
Tom Payne
feat: Support rage as an alternative age encryption command
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e1acf74cbb..7cc2a8f8b8b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,12 +13,13 @@ env: AGE_VERSION: 1.1.1 CHOCOLATEY_VERSION: 2.2.2 EDITORCONFIG_CHECKER_VERSION: 2.7.2 + FIND_TYPOS_VERSION: 0.0.3 GO_VERSION: 1.21.6 GOFUMPT_VERSION: 0.5.0 GOLANGCI_LINT_VERSION: 1.55.2 GOLINES_VERSION: 0.11.0 GOVERSIONINFO_VERSION: 1.4.0 - FIND_TYPOS_VERSION: 0.0.3 + RAGE_VERSION: 0.9.2 jobs: changes: runs-on: ubuntu-20.04 @@ -102,10 +103,13 @@ jobs: go run . --version - name: install-age run: | - cd "$(mktemp -d)" - curl -fsSL "https://github.com/FiloSottile/age/releases/download/v${AGE_VERSION}/age-v${AGE_VERSION}-darwin-amd64.tar.gz" | tar xzf - - sudo install -m 755 age/age /usr/local/bin - sudo install -m 755 age/age-keygen /usr/local/bin + brew install age + age --version + - name: install-rage + run: | + brew tap str4d.xyz/rage https://str4d.xyz/rage + brew install rage + rage --version - name: install-keepassxc run: | brew install keepassxc @@ -140,6 +144,12 @@ jobs: curl -fsSL "https://github.com/FiloSottile/age/releases/download/v${AGE_VERSION}/age-v${AGE_VERSION}-linux-amd64.tar.gz" | tar xzf - sudo install -m 755 age/age /usr/local/bin sudo install -m 755 age/age-keygen /usr/local/bin + - name: install-rage + run: | + cd "$(mktemp -d)" + curl -fsSL "https://github.com/str4d/rage/releases/download/v${RAGE_VERSION}/rage-v${RAGE_VERSION}-x86_64-linux.tar.gz" | tar xzf - + sudo install -m 755 rage/rage /usr/local/bin + sudo install -m 755 rage/rage-keygen /usr/local/bin - name: test env: CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} @@ -225,6 +235,12 @@ jobs: curl -fsSL "https://github.com/FiloSottile/age/releases/download/v${AGE_VERSION}/age-v${AGE_VERSION}-linux-amd64.tar.gz" | tar xzf - sudo install -m 755 age/age /usr/local/bin sudo install -m 755 age/age-keygen /usr/local/bin + - name: install-rage + run: | + cd "$(mktemp -d)" + curl -fsSL "https://github.com/str4d/rage/releases/download/v${RAGE_VERSION}/rage-v${RAGE_VERSION}-x86_64-linux.tar.gz" | tar xzf - + sudo install -m 755 rage/rage /usr/local/bin + sudo install -m 755 rage/rage-keygen /usr/local/bin - name: build run: | go build ./... diff --git a/assets/chezmoi.io/docs/developer/developing-locally.md b/assets/chezmoi.io/docs/developer/developing-locally.md index 1ac0b9858ba..bc6c550f02e 100644 --- a/assets/chezmoi.io/docs/developer/developing-locally.md +++ b/assets/chezmoi.io/docs/developer/developing-locally.md @@ -33,8 +33,8 @@ $ go test ./... ``` chezmoi's tests include integration tests with other software. If the other -software is not found in `$PATH` the tests will be skipped. Running the full -set of tests requires `age`, `base64`, `bash`, `gpg`, `perl`, `python3`, +software is not found in `$PATH` the tests will be skipped. Running the full set +of tests requires `age`, `base64`, `bash`, `gpg`, `perl`, `python3`, `rage`, `ruby`, `sed`, `sha256sum`, `unzip`, `xz`, `zip`, and `zstd`. Run chezmoi: diff --git a/assets/chezmoi.io/docs/user-guide/encryption/rage.md b/assets/chezmoi.io/docs/user-guide/encryption/rage.md new file mode 100644 index 00000000000..09599de28e6 --- /dev/null +++ b/assets/chezmoi.io/docs/user-guide/encryption/rage.md @@ -0,0 +1,13 @@ +# rage + +chezmoi supports encrypting files with [rage](https://str4d.xyz/rage). + +To use rage, set `age.command` to `rage` in your configuration file, for example: + +```toml title="~/.config/chezmoi/chezmoi.toml" +encryption = "age" +[age] + command = "rage" +``` + +Then, configure chezmoi as you would for [age](age.md). diff --git a/assets/chezmoi.io/mkdocs.yml b/assets/chezmoi.io/mkdocs.yml index 04449f8050a..8c5ae2a64d1 100644 --- a/assets/chezmoi.io/mkdocs.yml +++ b/assets/chezmoi.io/mkdocs.yml @@ -80,6 +80,7 @@ nav: - user-guide/encryption/index.md - age: user-guide/encryption/age.md - gpg: user-guide/encryption/gpg.md + - rage: user-guide/encryption/rage.md - Machines: - General: user-guide/machines/general.md - Linux: user-guide/machines/linux.md diff --git a/internal/chezmoi/ageencryption_test.go b/internal/chezmoi/ageencryption_test.go index 445dc278f98..8bbb9df478a 100644 --- a/internal/chezmoi/ageencryption_test.go +++ b/internal/chezmoi/ageencryption_test.go @@ -11,66 +11,83 @@ import ( "github.com/twpayne/chezmoi/v2/internal/chezmoitest" ) -func TestAgeEncryption(t *testing.T) { - command := lookPathOrSkip(t, "age") - - identityFile := filepath.Join(t.TempDir(), "chezmoi-test-age-key.txt") - recipient, err := chezmoitest.AgeGenerateKey(identityFile) - assert.NoError(t, err) +var ageCommands = []string{ + "age", + "rage", +} - testEncryption(t, &AgeEncryption{ - Command: command, - Identity: NewAbsPath(identityFile), - Recipient: recipient, +func TestAgeEncryption(t *testing.T) { + forEachAgeCommand(t, func(t *testing.T, command string) { + t.Helper() + + identityFile := filepath.Join(t.TempDir(), "chezmoi-test-age-key.txt") + recipient, err := chezmoitest.AgeGenerateKey(command, identityFile) + assert.NoError(t, err) + + testEncryption(t, &AgeEncryption{ + Command: command, + Identity: NewAbsPath(identityFile), + Recipient: recipient, + }) }) } func TestAgeMultipleIdentitiesAndMultipleRecipients(t *testing.T) { - command := lookPathOrSkip(t, "age") - - tempDir := t.TempDir() - identityFile1 := filepath.Join(tempDir, "chezmoi-test-age-key1.txt") - recipient1, err := chezmoitest.AgeGenerateKey(identityFile1) - assert.NoError(t, err) - identityFile2 := filepath.Join(tempDir, "chezmoi-test-age-key2.txt") - recipient2, err := chezmoitest.AgeGenerateKey(identityFile2) - assert.NoError(t, err) - - testEncryption(t, &AgeEncryption{ - Command: command, - Identities: []AbsPath{ - NewAbsPath(identityFile1), - NewAbsPath(identityFile2), - }, - Recipients: []string{ - recipient1, - recipient2, - }, + forEachAgeCommand(t, func(t *testing.T, command string) { + t.Helper() + + tempDir := t.TempDir() + + identityFile1 := filepath.Join(tempDir, "chezmoi-test-age-key1.txt") + recipient1, err := chezmoitest.AgeGenerateKey(command, identityFile1) + assert.NoError(t, err) + + identityFile2 := filepath.Join(tempDir, "chezmoi-test-age-key2.txt") + recipient2, err := chezmoitest.AgeGenerateKey(command, identityFile2) + assert.NoError(t, err) + + testEncryption(t, &AgeEncryption{ + Command: command, + Identities: []AbsPath{ + NewAbsPath(identityFile1), + NewAbsPath(identityFile2), + }, + Recipients: []string{ + recipient1, + recipient2, + }, + }) }) } func TestAgeRecipientsFile(t *testing.T) { - command := lookPathOrSkip(t, "age") + t.Helper() - tempDir := t.TempDir() - identityFile := filepath.Join(tempDir, "chezmoi-test-age-key.txt") - recipient, err := chezmoitest.AgeGenerateKey(identityFile) - assert.NoError(t, err) - recipientsFile := filepath.Join(t.TempDir(), "chezmoi-test-age-recipients.txt") - assert.NoError(t, os.WriteFile(recipientsFile, []byte(recipient), 0o666)) + forEachAgeCommand(t, func(t *testing.T, command string) { + t.Helper() - testEncryption(t, &AgeEncryption{ - Command: command, - Identity: NewAbsPath(identityFile), - RecipientsFile: NewAbsPath(recipientsFile), - }) + tempDir := t.TempDir() - testEncryption(t, &AgeEncryption{ - Command: command, - Identity: NewAbsPath(identityFile), - RecipientsFiles: []AbsPath{ - NewAbsPath(recipientsFile), - }, + identityFile := filepath.Join(tempDir, "chezmoi-test-age-key.txt") + recipient, err := chezmoitest.AgeGenerateKey(command, identityFile) + assert.NoError(t, err) + + recipientsFile := filepath.Join(t.TempDir(), "chezmoi-test-age-recipients.txt") + assert.NoError(t, os.WriteFile(recipientsFile, []byte(recipient), 0o666)) + + testEncryption(t, &AgeEncryption{ + Command: command, + Identity: NewAbsPath(identityFile), + RecipientsFile: NewAbsPath(recipientsFile), + }) + + testEncryption(t, &AgeEncryption{ + Command: command, + Identity: NewAbsPath(identityFile), + RecipientsFiles: []AbsPath{ + NewAbsPath(recipientsFile), + }, + }) }) } @@ -129,3 +146,12 @@ func builtinAgeGenerateKey(t *testing.T) (*age.X25519Recipient, AbsPath) { assert.NoError(t, os.WriteFile(identityFile, []byte(identity.String()), 0o600)) return identity.Recipient(), NewAbsPath(identityFile) } + +func forEachAgeCommand(t *testing.T, f func(*testing.T, string)) { + t.Helper() + for _, command := range ageCommands { + t.Run(command, func(t *testing.T) { + f(t, lookPathOrSkip(t, command)) + }) + } +} diff --git a/internal/chezmoitest/chezmoitest.go b/internal/chezmoitest/chezmoitest.go index c3071a51b1f..e84fecce29b 100644 --- a/internal/chezmoitest/chezmoitest.go +++ b/internal/chezmoitest/chezmoitest.go @@ -23,8 +23,8 @@ var ageRecipientRx = regexp.MustCompile(`(?m)^Public key: ([0-9a-z]+)\s*$`) // AgeGenerateKey generates an identity in identityFile and returns the // recipient. -func AgeGenerateKey(identityFile string) (string, error) { - cmd := exec.Command("age-keygen", "--output", identityFile) +func AgeGenerateKey(command, identityFile string) (string, error) { + cmd := exec.Command(command+"-keygen", "--output", identityFile) //nolint:gosec output, err := chezmoilog.LogCmdCombinedOutput(cmd) if err != nil { return "", err diff --git a/internal/cmd/main_test.go b/internal/cmd/main_test.go index cab3dbabd30..08cbbd860c5 100644 --- a/internal/cmd/main_test.go +++ b/internal/cmd/main_test.go @@ -306,7 +306,7 @@ func cmdMkAgeConfig(ts *testscript.TestScript, neg bool, args []string) { homeDir := ts.Getenv("HOME") ts.Check(os.MkdirAll(homeDir, fs.ModePerm)) identityFile := filepath.Join(homeDir, "key.txt") - recipient, err := chezmoitest.AgeGenerateKey(ts.MkAbs(identityFile)) + recipient, err := chezmoitest.AgeGenerateKey("age", ts.MkAbs(identityFile)) ts.Check(err) configFile := filepath.Join(homeDir, ".config", "chezmoi", "chezmoi.toml") ts.Check(os.MkdirAll(filepath.Dir(configFile), fs.ModePerm))
feat
Support rage as an alternative age encryption command
3f636c1b30686c84c524722dbd0b0ce9a0953fb9
2023-08-13 18:52:49
Tom Payne
chore: Build with Go 1.21.0
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 776953dc70b..93982347a28 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ on: env: ACTIONLINT_VERSION: 1.6.25 AGE_VERSION: 1.1.1 - GO_VERSION: 1.20.7 + GO_VERSION: 1.21.0 GOFUMPT_VERSION: 0.4.0 GOLANGCI_LINT_VERSION: 1.53.3 GOLINES_VERSION: 0.11.0 @@ -281,7 +281,7 @@ jobs: test-windows: needs: changes if: github.event_name == 'push' || needs.changes.outputs.code == 'true' - runs-on: windows-2019 + runs-on: windows-2022 steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 diff --git a/assets/scripts/install-local-bin.sh b/assets/scripts/install-local-bin.sh index e454fcf4639..a59ef0e4201 100644 --- a/assets/scripts/install-local-bin.sh +++ b/assets/scripts/install-local-bin.sh @@ -164,7 +164,6 @@ check_goos_goarch() { openbsd/amd64) return 0 ;; openbsd/arm) return 0 ;; openbsd/arm64) return 0 ;; - openbsd/mips64) return 0 ;; windows/386) return 0 ;; windows/amd64) return 0 ;; windows/arm) return 0 ;; diff --git a/assets/scripts/install.sh b/assets/scripts/install.sh index 623802857c8..5ac467eb9dc 100644 --- a/assets/scripts/install.sh +++ b/assets/scripts/install.sh @@ -164,7 +164,6 @@ check_goos_goarch() { openbsd/amd64) return 0 ;; openbsd/arm) return 0 ;; openbsd/arm64) return 0 ;; - openbsd/mips64) return 0 ;; windows/386) return 0 ;; windows/amd64) return 0 ;; windows/arm) return 0 ;; diff --git a/internal/chezmoi/attr.go b/internal/chezmoi/attr.go index 37acac378b3..960a572ce48 100644 --- a/internal/chezmoi/attr.go +++ b/internal/chezmoi/attr.go @@ -106,10 +106,10 @@ func parseDirAttr(sourceName string) DirAttr { sourceDirType = SourceDirTypeRemove name = name[len(removePrefix):] default: - name, external = CutPrefix(name, externalPrefix) - name, exact = CutPrefix(name, exactPrefix) - name, private = CutPrefix(name, privatePrefix) - name, readOnly = CutPrefix(name, readOnlyPrefix) + name, external = strings.CutPrefix(name, externalPrefix) + name, exact = strings.CutPrefix(name, exactPrefix) + name, private = strings.CutPrefix(name, privatePrefix) + name, readOnly = strings.CutPrefix(name, readOnlyPrefix) } switch { case strings.HasPrefix(name, dotPrefix): @@ -199,11 +199,11 @@ func parseFileAttr(sourceName, encryptedSuffix string) FileAttr { case strings.HasPrefix(name, createPrefix): sourceFileType = SourceFileTypeCreate name = name[len(createPrefix):] - name, encrypted = CutPrefix(name, encryptedPrefix) - name, private = CutPrefix(name, privatePrefix) - name, readOnly = CutPrefix(name, readOnlyPrefix) - name, empty = CutPrefix(name, emptyPrefix) - name, executable = CutPrefix(name, executablePrefix) + name, encrypted = strings.CutPrefix(name, encryptedPrefix) + name, private = strings.CutPrefix(name, privatePrefix) + name, readOnly = strings.CutPrefix(name, readOnlyPrefix) + name, empty = strings.CutPrefix(name, emptyPrefix) + name, executable = strings.CutPrefix(name, executablePrefix) case strings.HasPrefix(name, removePrefix): sourceFileType = SourceFileTypeRemove name = name[len(removePrefix):] @@ -234,16 +234,16 @@ func parseFileAttr(sourceName, encryptedSuffix string) FileAttr { case strings.HasPrefix(name, modifyPrefix): sourceFileType = SourceFileTypeModify name = name[len(modifyPrefix):] - name, encrypted = CutPrefix(name, encryptedPrefix) - name, private = CutPrefix(name, privatePrefix) - name, readOnly = CutPrefix(name, readOnlyPrefix) - name, executable = CutPrefix(name, executablePrefix) + name, encrypted = strings.CutPrefix(name, encryptedPrefix) + name, private = strings.CutPrefix(name, privatePrefix) + name, readOnly = strings.CutPrefix(name, readOnlyPrefix) + name, executable = strings.CutPrefix(name, executablePrefix) default: - name, encrypted = CutPrefix(name, encryptedPrefix) - name, private = CutPrefix(name, privatePrefix) - name, readOnly = CutPrefix(name, readOnlyPrefix) - name, empty = CutPrefix(name, emptyPrefix) - name, executable = CutPrefix(name, executablePrefix) + name, encrypted = strings.CutPrefix(name, encryptedPrefix) + name, private = strings.CutPrefix(name, privatePrefix) + name, readOnly = strings.CutPrefix(name, readOnlyPrefix) + name, empty = strings.CutPrefix(name, emptyPrefix) + name, executable = strings.CutPrefix(name, executablePrefix) } switch { case strings.HasPrefix(name, dotPrefix): @@ -252,7 +252,7 @@ func parseFileAttr(sourceName, encryptedSuffix string) FileAttr { name = name[len(literalPrefix):] } if encrypted { - name, _ = CutSuffix(name, encryptedSuffix) + name, _ = strings.CutSuffix(name, encryptedSuffix) } switch { case strings.HasSuffix(name, literalSuffix): @@ -260,7 +260,7 @@ func parseFileAttr(sourceName, encryptedSuffix string) FileAttr { case strings.HasSuffix(name, TemplateSuffix): name = name[:len(name)-len(TemplateSuffix)] template = true - name, _ = CutSuffix(name, literalSuffix) + name, _ = strings.CutSuffix(name, literalSuffix) } return FileAttr{ TargetName: name, diff --git a/internal/chezmoi/chezmoi_go1.19.go b/internal/chezmoi/chezmoi_go1.19.go deleted file mode 100644 index 9c3f51b26cd..00000000000 --- a/internal/chezmoi/chezmoi_go1.19.go +++ /dev/null @@ -1,19 +0,0 @@ -//go:build !go1.20 - -package chezmoi - -import "strings" - -func CutPrefix(s, prefix string) (string, bool) { - if strings.HasPrefix(s, prefix) { - return s[len(prefix):], true - } - return s, false -} - -func CutSuffix(s, suffix string) (string, bool) { - if strings.HasSuffix(s, suffix) { - return s[:len(s)-len(suffix)], true - } - return s, false -} diff --git a/internal/chezmoi/chezmoi_go1.20.go b/internal/chezmoi/chezmoi_go1.20.go deleted file mode 100644 index a619f84fb77..00000000000 --- a/internal/chezmoi/chezmoi_go1.20.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build go1.20 - -package chezmoi - -import "strings" - -var ( - CutPrefix = strings.CutPrefix - CutSuffix = strings.CutSuffix -) diff --git a/internal/chezmoi/entrytypeset.go b/internal/chezmoi/entrytypeset.go index da631f10bd3..087591dcbb7 100644 --- a/internal/chezmoi/entrytypeset.go +++ b/internal/chezmoi/entrytypeset.go @@ -296,7 +296,7 @@ func (s *EntryTypeSet) SetSlice(ss []string) error { if element == "" { continue } - element, exclude := CutPrefix(element, "no") + element, exclude := strings.CutPrefix(element, "no") bit, ok := entryTypeBits[element] if !ok { return fmt.Errorf("%s: unknown entry type", element) diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go index 4797078a50c..39f16c423c5 100644 --- a/internal/chezmoi/sourcestate.go +++ b/internal/chezmoi/sourcestate.go @@ -1398,7 +1398,7 @@ func (s *SourceState) addPatterns( continue } include := patternSetInclude - text, ok := CutPrefix(text, "!") + text, ok := strings.CutPrefix(text, "!") if ok { include = patternSetExclude } diff --git a/main.go b/main.go index 80a9ca68437..c31b3806bb0 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,4 @@ -//go:build go1.19 +//go:build go1.20 //go:generate go run . completion bash -o completions/chezmoi-completion.bash //go:generate go run . completion fish -o completions/chezmoi.fish
chore
Build with Go 1.21.0
3c77d46769aa5a858b47f8100247edead4c7172d
2022-01-29 04:58:13
Tom Payne
chore: Tidy up doctor command
false
diff --git a/pkg/cmd/doctorcmd.go b/pkg/cmd/doctorcmd.go index bf9765d47c6..472e0018449 100644 --- a/pkg/cmd/doctorcmd.go +++ b/pkg/cmd/doctorcmd.go @@ -140,10 +140,10 @@ func (c *Config) runDoctorCmd(cmd *cobra.Command, args []string) error { versionInfo: c.versionInfo, versionStr: c.versionStr, }, - &osArchCheck{}, - &goVersionCheck{}, - &executableCheck{}, - &upgradeMethodCheck{}, + osArchCheck{}, + goVersionCheck{}, + executableCheck{}, + upgradeMethodCheck{}, &configFileCheck{ basename: chezmoiRelPath, bds: c.bds, @@ -176,7 +176,7 @@ func (c *Config) runDoctorCmd(cmd *cobra.Command, args []string) error { ifNotSet: checkResultWarning, ifNotExist: checkResultWarning, }, - &umaskCheck{}, + umaskCheck{}, &binaryCheck{ name: "git-command", binaryname: c.Git.Command, @@ -420,11 +420,11 @@ func (c *dirCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (c return checkResultOK, fmt.Sprintf("%s is a directory", c.dirname) } -func (c *executableCheck) Name() string { +func (executableCheck) Name() string { return "executable" } -func (c *executableCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) { +func (executableCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) { executable, err := os.Executable() if err != nil { return checkResultError, err.Error() @@ -509,11 +509,11 @@ func (c *suspiciousEntriesCheck) Run(system chezmoi.System, homeDirAbsPath chezm return checkResultOK, "no suspicious entries" } -func (c *umaskCheck) Name() string { - return "umask" +func (upgradeMethodCheck) Name() string { + return "upgrade-method" } -func (c *upgradeMethodCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) { +func (upgradeMethodCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) { executable, err := os.Executable() if err != nil { return checkResultFailed, err.Error() @@ -528,10 +528,6 @@ func (c *upgradeMethodCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.A return checkResultOK, method } -func (c *upgradeMethodCheck) Name() string { - return "upgrade-method" -} - func (c *versionCheck) Name() string { return "version" } diff --git a/pkg/cmd/doctorcmd_unix.go b/pkg/cmd/doctorcmd_unix.go index 4b671369126..a4db9098a97 100644 --- a/pkg/cmd/doctorcmd_unix.go +++ b/pkg/cmd/doctorcmd_unix.go @@ -11,7 +11,11 @@ import ( "github.com/twpayne/chezmoi/v2/pkg/chezmoi" ) -func (c *umaskCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) { +func (umaskCheck) Name() string { + return "umask" +} + +func (umaskCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) { umask := unix.Umask(0) unix.Umask(umask) result := checkResultOK diff --git a/pkg/cmd/doctorcmd_windows.go b/pkg/cmd/doctorcmd_windows.go index 5442bde14e3..aefca591d57 100644 --- a/pkg/cmd/doctorcmd_windows.go +++ b/pkg/cmd/doctorcmd_windows.go @@ -2,6 +2,10 @@ package cmd import "github.com/twpayne/chezmoi/v2/pkg/chezmoi" -func (c *umaskCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) { +func (umaskCheck) Name() string { + return "umask" +} + +func (umaskCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) { return checkResultSkipped, "" }
chore
Tidy up doctor command
63f24f950b3554897b86671e9096b9acad035795
2024-09-17 01:49:24
Alper Cugun
chore: Fix typo
false
diff --git a/assets/chezmoi.io/docs/developer-guide/website.md b/assets/chezmoi.io/docs/developer-guide/website.md index abdd59e4a70..76bcdae6df9 100644 --- a/assets/chezmoi.io/docs/developer-guide/website.md +++ b/assets/chezmoi.io/docs/developer-guide/website.md @@ -2,8 +2,9 @@ The [website](https://chezmoi.io) is generated with [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) from the contents of the -`assets/chezmoi.io/docs/` directory. It hosted by [GitHub pages](https://pages.github.com/) from -the [`gh-pages` branch](https://github.com/twpayne/chezmoi/tree/gh-pages). +`assets/chezmoi.io/docs/` directory. It is hosted by [GitHub +pages](https://pages.github.com/) from the [`gh-pages` +branch](https://github.com/twpayne/chezmoi/tree/gh-pages). Change into the website directory:
chore
Fix typo
6b4741ad892030708f5001eeb0b23219765b9779
2022-06-12 20:05:21
Tom Payne
chore: Give a more explicit error when target is not in dest dir
false
diff --git a/pkg/chezmoi/abspath.go b/pkg/chezmoi/abspath.go index d71a4709d0a..b28a0e7a51e 100644 --- a/pkg/chezmoi/abspath.go +++ b/pkg/chezmoi/abspath.go @@ -151,7 +151,7 @@ func (p AbsPath) TrimDirPrefix(dirPrefixAbsPath AbsPath) (RelPath, error) { dirAbsPath.absPath += "/" } if !strings.HasPrefix(p.absPath, dirAbsPath.absPath) { - return EmptyRelPath, &notInAbsDirError{ + return EmptyRelPath, &NotInAbsDirError{ pathAbsPath: p, dirAbsPath: dirPrefixAbsPath, } diff --git a/pkg/chezmoi/errors.go b/pkg/chezmoi/errors.go index 47a4bcacec7..fa99920cf01 100644 --- a/pkg/chezmoi/errors.go +++ b/pkg/chezmoi/errors.go @@ -36,12 +36,12 @@ func (e *inconsistentStateError) Error() string { return fmt.Sprintf("%s: inconsistent state (%s)", e.targetRelPath, strings.Join(e.origins, ", ")) } -type notInAbsDirError struct { +type NotInAbsDirError struct { pathAbsPath AbsPath dirAbsPath AbsPath } -func (e *notInAbsDirError) Error() string { +func (e *NotInAbsDirError) Error() string { return fmt.Sprintf("%s: not in %s", e.pathAbsPath, e.dirAbsPath) } diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index 57dd8b2edd3..6651b091cb9 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -1023,7 +1023,7 @@ func (c *Config) destAbsPathInfos( if err != nil { return nil, err } - if _, err := destAbsPath.TrimDirPrefix(c.DestDirAbsPath); err != nil { + if _, err := c.targetRelPath(destAbsPath); err != nil { return nil, err } if options.recursive { @@ -1940,6 +1940,15 @@ func (c *Config) sourceDirAbsPath() (chezmoi.AbsPath, error) { } } +func (c *Config) targetRelPath(absPath chezmoi.AbsPath) (chezmoi.RelPath, error) { + relPath, err := absPath.TrimDirPrefix(c.DestDirAbsPath) + var notInAbsDirError *chezmoi.NotInAbsDirError + if errors.As(err, &notInAbsDirError) { + return chezmoi.EmptyRelPath, fmt.Errorf("%s: not in destination directory (%s)", absPath, c.DestDirAbsPath) + } + return relPath, err +} + type targetRelPathsOptions struct { mustBeInSourceState bool recursive bool @@ -1956,7 +1965,7 @@ func (c *Config) targetRelPaths( if err != nil { return nil, err } - targetRelPath, err := argAbsPath.TrimDirPrefix(c.DestDirAbsPath) + targetRelPath, err := c.targetRelPath(argAbsPath) if err != nil { return nil, err } diff --git a/pkg/cmd/testdata/scripts/cat.txt b/pkg/cmd/testdata/scripts/cat.txt index fd2b061d98a..9523d5e3828 100644 --- a/pkg/cmd/testdata/scripts/cat.txt +++ b/pkg/cmd/testdata/scripts/cat.txt @@ -23,7 +23,7 @@ stderr 'not a file, script, or symlink' # test that chezmoi cat does not print files outside the destination directory ! chezmoi cat ${/}etc${/}passwd -stderr 'not in' +stderr 'not in destination directory' # test that chezmoi cat uses relative paths mkdir $HOME/.dir
chore
Give a more explicit error when target is not in dest dir
e3e839ff8760a3661d19d17cd900e5463dfcce2b
2024-09-26 21:46:55
Austin Ziegler
chore: Format YAML with format-yaml
false
diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 25ce53fc22a..1abf74bdd28 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,46 +1,46 @@ version: 2 updates: - - package-ecosystem: gomod - directory: / - schedule: - interval: monthly - labels: - - enhancement +- package-ecosystem: gomod + directory: / + schedule: + interval: monthly + labels: + - enhancement - groups: - go-dev: - dependency-type: development - patterns: - - '*' - update-types: [minor, patch] + groups: + go-dev: + dependency-type: development + patterns: + - '*' + update-types: [minor, patch] - go-prod: - dependency-type: production - patterns: - - '*' - update-types: [minor, patch] + go-prod: + dependency-type: production + patterns: + - '*' + update-types: [minor, patch] - - package-ecosystem: github-actions - directory: / - schedule: - interval: monthly - labels: - - enhancement +- package-ecosystem: github-actions + directory: / + schedule: + interval: monthly + labels: + - enhancement - groups: - actions: - patterns: - - '*' - update-types: [minor, patch] + groups: + actions: + patterns: + - '*' + update-types: [minor, patch] - - package-ecosystem: pip - directory: /assets - schedule: - interval: monthly - labels: - - enhancement - groups: - python: - patterns: - - '*' - update-types: [minor, patch] +- package-ecosystem: pip + directory: /assets + schedule: + interval: monthly + labels: + - enhancement + groups: + python: + patterns: + - '*' + update-types: [minor, patch] diff --git a/.github/workflows/lock-threads.yml b/.github/workflows/lock-threads.yml index 966072b68fd..dc322db9e60 100644 --- a/.github/workflows/lock-threads.yml +++ b/.github/workflows/lock-threads.yml @@ -18,7 +18,7 @@ jobs: steps: - uses: dessant/lock-threads@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771 with: - process-only: 'issues, prs' + process-only: issues, prs issue-lock-reason: resolved issue-inactive-days: 7 pr-lock-reason: resolved diff --git a/assets/chezmoi.io/docs/links/articles.md.yaml b/assets/chezmoi.io/docs/links/articles.md.yaml index 19b359d5eff..a0fed5a32ea 100644 --- a/assets/chezmoi.io/docs/links/articles.md.yaml +++ b/assets/chezmoi.io/docs/links/articles.md.yaml @@ -392,12 +392,12 @@ articles: - date: '2024-03-11' version: 2.47.1 lang: CN - title: 'Chezmoi:優雅管理Linux的dotfile,使用Git儲存庫備份,類似GNU Stow' + title: Chezmoi:優雅管理Linux的dotfile,使用Git儲存庫備份,類似GNU Stow url: https://ivonblog.com/posts/chezmoi-manage-dotfiles/ - date: '2024-03-23' version: 2.47.2 lang: CN - title: '使用 chezmoi & vscode, 管理你的 dotfiles' + title: 使用 chezmoi & vscode, 管理你的 dotfiles url: https://shansan.top/2024/03/23/using-chezmoi-to-manage-dotfiles/ - date: '2024-03-23' version: 2.47.2 @@ -414,12 +414,12 @@ articles: - date: '2024-04-27' version: 2.48.0 lang: CN - title: '使用 chezmoi & vscode, 管理你的 dotfiles' + title: 使用 chezmoi & vscode, 管理你的 dotfiles url: https://juejin.cn/post/7362028633425608754 - date: '2024-05-01' version: 2.48.0 lang: TH - title: 'จัดการ dotfiles ด้วย chezmoi' + title: จัดการ dotfiles ด้วย chezmoi url: https://www.anuwong.com/blog/manage-dotfiles-with-chezmoi/ - date: '2024-05-27' version: 2.48.1 @@ -427,20 +427,20 @@ articles: url: https://1729.org.uk/posts/managing-dotfiles-with-chezmoi/ - date: '2024-06-26' version: 2.49.1 - title: 'Automate Your Dotfiles with Chezmoi' + title: Automate Your Dotfiles with Chezmoi url: https://learn.typecraft.dev/tutorial/our-place-chezmoi/ - date: '2024-07-28' version: 2.51.0 - title: 'Development Environment Setup with Chezmoi' + title: Development Environment Setup with Chezmoi url: https://danielmschmidt.de/posts/dev-env-setup-with-chezmoi/ - date: '2024-07-31' version: 2.51.0 - title: 'Managing dotfiles with chezmoi' + title: Managing dotfiles with chezmoi url: https://wqplease.com/p/managing-dotfiles-with-chezmoi - date: '2024-08-30' version: 2.52.1 lang: JP - title: 'dotfiles管理をchezmoiに移行する' + title: dotfiles管理をchezmoiに移行する url: https://nsakki55.hatenablog.com/entry/2024/08/30/125246 - date: '2024-09-08' version: 2.52.1 diff --git a/assets/chezmoi.io/docs/links/videos.md.yaml b/assets/chezmoi.io/docs/links/videos.md.yaml index f5b28ee961a..936f596b009 100644 --- a/assets/chezmoi.io/docs/links/videos.md.yaml +++ b/assets/chezmoi.io/docs/links/videos.md.yaml @@ -51,9 +51,9 @@ videos: url: https://www.youtube.com/watch?v=fQ3txCIxiiU - date: '2024-02-17' version: 2.47.0 - title: '12 GREAT command line programs YOU recommended!' + title: 12 GREAT command line programs YOU recommended! url: https://www.youtube.com/watch?v=nCS4BtJ34-o&t=324s - date: '2024-06-22' - version: '2.47.1' - title: 'Automating Development Environments with Ansible & Chezmoi' + version: 2.47.1 + title: Automating Development Environments with Ansible & Chezmoi url: https://www.youtube.com/watch?v=P4nI1VhoN2Y
chore
Format YAML with format-yaml
114030cd4578056bcd50b2c80b0aa1cd15290b55
2024-01-16 13:43:25
Tom Payne
feat: Promote HCP Vault Secrets template functions to stable
false
diff --git a/assets/chezmoi.io/docs/reference/templates/hcp-vault-secrets-functions/index.md b/assets/chezmoi.io/docs/reference/templates/hcp-vault-secrets-functions/index.md index 9f0c4cdadf0..675ae8a21e4 100644 --- a/assets/chezmoi.io/docs/reference/templates/hcp-vault-secrets-functions/index.md +++ b/assets/chezmoi.io/docs/reference/templates/hcp-vault-secrets-functions/index.md @@ -4,7 +4,3 @@ chezmoi includes support for [HCP Vault Secrets](https://developer.hashicorp.com/hcp/docs/vault-secrets) using the `vlt` CLI to expose data through the `hcpVaultSecret` and `hcpVaultSecretJson` template functions. - -!!! warning - - HCP Vault Secrets is in beta and chezmoi's interface to it may change. diff --git a/assets/chezmoi.io/docs/user-guide/password-managers/hcp-vault-secrets.md b/assets/chezmoi.io/docs/user-guide/password-managers/hcp-vault-secrets.md index fa30b792183..a2e4f1cc77f 100644 --- a/assets/chezmoi.io/docs/user-guide/password-managers/hcp-vault-secrets.md +++ b/assets/chezmoi.io/docs/user-guide/password-managers/hcp-vault-secrets.md @@ -5,10 +5,6 @@ Secrets](https://developer.hashicorp.com/hcp/docs/vault-secrets) using the `vlt` CLI to expose data through the `hcpVaultSecret` and `hcpVaultSecretJson` template functions. -!!! warning - - HCP Vault Secrets is in beta and chezmoi's interface to it may change. - Log in using: ```console
feat
Promote HCP Vault Secrets template functions to stable
80edd2101d374191f7e46b2f560d15d187cb4a5f
2021-12-23 18:44:22
Tom Payne
chore: Test on Go 1.18beta1
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 96a513137c6..b7c3c0573fa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -337,6 +337,43 @@ jobs: - name: Test run: | go test ./... + test-ubuntu-go1-18: + needs: changes + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' + runs-on: ubuntu-18.04 + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.x + - name: Install Go 1.18beta1 + run: | + go install golang.org/dl/go1.18beta1@latest + go1.18beta1 download + - name: Checkout + uses: actions/checkout@v2 + - name: Cache Go modules + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-ubuntu-go-1-18-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-ubuntu-go-1-18- + - name: Build + run: | + go1.18beta1 build ./... + - name: Run + run: | + go1.18beta1 run . --version + - name: Install age + run: | + cd $(mktemp -d) + curl -fsSL https://github.com/FiloSottile/age/releases/download/v${AGE_VERSION}/age-v${AGE_VERSION}-linux-amd64.tar.gz | tar xzf - + sudo install -m 755 age/age /usr/local/bin + sudo install -m 755 age/age-keygen /usr/local/bin + - name: Test + run: | + go1.18beta1 test ./... test-windows: needs: changes if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
chore
Test on Go 1.18beta1
1ea9003e9abe0e00d782bdb41c6d2483af7ca404
2024-11-30 06:00:12
Tom Payne
chore: Update dependencies
false
diff --git a/go.mod b/go.mod index 3f8a78f7477..b4c30435154 100644 --- a/go.mod +++ b/go.mod @@ -47,7 +47,7 @@ require ( go.etcd.io/bbolt v1.3.11 go.uber.org/automaxprocs v1.6.0 golang.org/x/crypto v0.29.0 - golang.org/x/crypto/x509roots/fallback v0.0.0-20241107225453-6018723c7405 + golang.org/x/crypto/x509roots/fallback v0.0.0-20241127184453-8c4e668694cc golang.org/x/oauth2 v0.24.0 golang.org/x/sync v0.9.0 golang.org/x/sys v0.27.0 @@ -108,8 +108,9 @@ require ( github.com/gobwas/glob v0.2.3 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect github.com/google/btree v1.1.3 // indirect + github.com/google/go-github/v67 v67.0.0 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/css v1.0.1 // indirect diff --git a/go.sum b/go.sum index ff5f3dcf7a8..98f3588858f 100644 --- a/go.sum +++ b/go.sum @@ -208,8 +208,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ= +github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= @@ -221,6 +221,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github/v66 v66.0.0 h1:ADJsaXj9UotwdgK8/iFZtv7MLc8E8WBl62WLd/D/9+M= github.com/google/go-github/v66 v66.0.0/go.mod h1:+4SO9Zkuyf8ytMj0csN1NR/5OTR+MfqPp8P8dVlcvY4= +github.com/google/go-github/v67 v67.0.0 h1:g11NDAmfaBaCO8qYdI9fsmbaRipHNWRIU/2YGvlh4rg= +github.com/google/go-github/v67 v67.0.0/go.mod h1:zH3K7BxjFndr9QSeFibx4lTKkYS3K9nDanoI1NjaOtY= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg= @@ -517,8 +519,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= -golang.org/x/crypto/x509roots/fallback v0.0.0-20241107225453-6018723c7405 h1:VAHMMzTf+Febj933dn5dxsbBHAHHqCv0fJj3UFB7PZM= -golang.org/x/crypto/x509roots/fallback v0.0.0-20241107225453-6018723c7405/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8= +golang.org/x/crypto/x509roots/fallback v0.0.0-20241127184453-8c4e668694cc h1:N2DXFnxni8U4KZ7CcK6kicRat3uowReUjOJxwYTxQv8= +golang.org/x/crypto/x509roots/fallback v0.0.0-20241127184453-8c4e668694cc/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8= golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo= golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= diff --git a/internal/chezmoi/github.go b/internal/chezmoi/github.go index 6d0c56e3c10..bcd051aa612 100644 --- a/internal/chezmoi/github.go +++ b/internal/chezmoi/github.go @@ -5,7 +5,7 @@ import ( "net/http" "os" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v67/github" "golang.org/x/oauth2" ) diff --git a/internal/cmd/doctorcmd.go b/internal/cmd/doctorcmd.go index 410b8b60991..9a78f65e746 100644 --- a/internal/cmd/doctorcmd.go +++ b/internal/cmd/doctorcmd.go @@ -20,7 +20,7 @@ import ( "time" "github.com/coreos/go-semver/semver" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v67/github" "github.com/spf13/cobra" "github.com/twpayne/go-shell" "github.com/twpayne/go-xdg/v6" diff --git a/internal/cmd/githubtemplatefuncs.go b/internal/cmd/githubtemplatefuncs.go index 975f156e6a8..8cfb40c96d6 100644 --- a/internal/cmd/githubtemplatefuncs.go +++ b/internal/cmd/githubtemplatefuncs.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v67/github" "github.com/twpayne/chezmoi/v2/internal/chezmoi" ) diff --git a/internal/cmd/upgradecmd.go b/internal/cmd/upgradecmd.go index da5b194a2d9..dfd6bcd71c8 100644 --- a/internal/cmd/upgradecmd.go +++ b/internal/cmd/upgradecmd.go @@ -21,7 +21,7 @@ import ( "strings" "github.com/coreos/go-semver/semver" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v67/github" "github.com/spf13/cobra" "github.com/twpayne/chezmoi/v2/internal/chezmoi" diff --git a/internal/cmd/upgradecmd_unix.go b/internal/cmd/upgradecmd_unix.go index 913f03ffe49..2e43572114e 100644 --- a/internal/cmd/upgradecmd_unix.go +++ b/internal/cmd/upgradecmd_unix.go @@ -15,7 +15,7 @@ import ( "strings" "github.com/coreos/go-semver/semver" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v67/github" vfs "github.com/twpayne/go-vfs/v5" "github.com/twpayne/chezmoi/v2/internal/chezmoi" diff --git a/internal/cmd/upgradecmd_windows.go b/internal/cmd/upgradecmd_windows.go index d8dfa964561..355a3395f1f 100644 --- a/internal/cmd/upgradecmd_windows.go +++ b/internal/cmd/upgradecmd_windows.go @@ -10,7 +10,7 @@ import ( "path/filepath" "github.com/coreos/go-semver/semver" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v67/github" vfs "github.com/twpayne/go-vfs/v5" "github.com/twpayne/chezmoi/v2/internal/chezmoi" diff --git a/internal/cmds/execute-template/main.go b/internal/cmds/execute-template/main.go index 82810bcd8e8..1b1541fccb3 100644 --- a/internal/cmds/execute-template/main.go +++ b/internal/cmds/execute-template/main.go @@ -16,7 +16,7 @@ import ( "text/template" "github.com/Masterminds/sprig/v3" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v67/github" "github.com/google/renameio/v2/maybe" "gopkg.in/yaml.v3"
chore
Update dependencies
9e3b20456b0a8465a61f53fd10fcb6b4f7268b1c
2023-04-18 02:18:14
Tom Payne
chore: Update dependencies
false
diff --git a/go.mod b/go.mod index 57eae1aabce..e10f17e24c3 100644 --- a/go.mod +++ b/go.mod @@ -7,8 +7,8 @@ require ( github.com/Masterminds/sprig/v3 v3.2.3 github.com/Shopify/ejson v1.3.3 github.com/aws/aws-sdk-go-v2 v1.17.8 - github.com/aws/aws-sdk-go-v2/config v1.18.20 - github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.19.2 + github.com/aws/aws-sdk-go-v2/config v1.18.21 + github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.19.3 github.com/bmatcuk/doublestar/v4 v4.6.0 github.com/bradenhilton/mozillainstallhash v1.0.1 github.com/charmbracelet/bubbles v0.15.0 @@ -21,13 +21,13 @@ require ( github.com/google/renameio/v2 v2.0.0 github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 github.com/itchyny/gojq v0.12.12 - github.com/klauspost/compress v1.16.4 + github.com/klauspost/compress v1.16.5 github.com/mitchellh/mapstructure v1.5.0 github.com/muesli/combinator v0.3.0 github.com/muesli/termenv v0.15.1 github.com/pelletier/go-toml/v2 v2.0.7 github.com/rogpeppe/go-internal v1.10.0 - github.com/rs/zerolog v1.29.0 + github.com/rs/zerolog v1.29.1 github.com/sergi/go-diff v1.1.0 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 @@ -55,22 +55,22 @@ require ( require ( github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.2.0 // indirect - github.com/Microsoft/go-winio v0.6.0 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230331115716-d34776aa93ec // indirect + github.com/Masterminds/semver/v3 v3.2.1 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230417170513-8ee5748c52b5 // indirect github.com/acomagu/bufpipe v1.0.4 // indirect github.com/alecthomas/chroma v0.10.0 // indirect github.com/alessio/shellescape v1.4.1 // indirect github.com/atotto/clipboard v0.1.4 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.13.19 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.13.20 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.2 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.32 // indirect github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.26 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.3.33 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.26 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.12.7 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.7 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.18.8 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.12.8 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.8 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.18.9 // indirect github.com/aws/smithy-go v1.13.5 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect diff --git a/go.sum b/go.sum index 5bd39ad352d..5adf654a972 100644 --- a/go.sum +++ b/go.sum @@ -4,16 +4,17 @@ filippo.io/age v1.1.1/go.mod h1:l03SrzDUrBkdBx8+IILdnn2KZysqQdbEBUQ4p3sqEQE= filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= +github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= -github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= -github.com/ProtonMail/go-crypto v0.0.0-20230331115716-d34776aa93ec h1:eQusauqzE1cAFR5hGnwkuSmFxKoy3+j9/cVaDeYfjjs= -github.com/ProtonMail/go-crypto v0.0.0-20230331115716-d34776aa93ec/go.mod h1:8TI4H3IbrackdNgv+92dI+rhpCaLqM0IfpgCgenFvRE= +github.com/ProtonMail/go-crypto v0.0.0-20230417170513-8ee5748c52b5 h1:QXMwHM/lB4ZQhdEF7JUTNgYOJR/gWoFbgQ/2Aj1h3Dk= +github.com/ProtonMail/go-crypto v0.0.0-20230417170513-8ee5748c52b5/go.mod h1:8TI4H3IbrackdNgv+92dI+rhpCaLqM0IfpgCgenFvRE= github.com/Shopify/ejson v1.3.3 h1:dPzgmvFhUPTJIzwdF5DaqbwW1dWaoR8ADKRdSTy6Mss= github.com/Shopify/ejson v1.3.3/go.mod h1:VZMUtDzvBW/PAXRUF5fzp1ffb1ucT8MztrZXXLYZurw= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= @@ -30,10 +31,10 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aws/aws-sdk-go-v2 v1.17.8 h1:GMupCNNI7FARX27L7GjCJM8NgivWbRgpjNI/hOQjFS8= github.com/aws/aws-sdk-go-v2 v1.17.8/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/config v1.18.20 h1:yYy+onqmLmDVZtx0mkqbx8aJPl+58V6ivLbLDZ2Qztc= -github.com/aws/aws-sdk-go-v2/config v1.18.20/go.mod h1:RWjF39RiDevmHw/+VaD8F0A36OPIPTHQQyRx0eZohnw= -github.com/aws/aws-sdk-go-v2/credentials v1.13.19 h1:FWHJy9uggyQCSEhovtl/6W6rW9P6DSr62GUeY/TS6Eo= -github.com/aws/aws-sdk-go-v2/credentials v1.13.19/go.mod h1:2m4uvLvl5hvQezVkLeBBUGMEDm5GcUNc3016W6d3NGg= +github.com/aws/aws-sdk-go-v2/config v1.18.21 h1:ENTXWKwE8b9YXgQCsruGLhvA9bhg+RqAsL9XEMEsa2c= +github.com/aws/aws-sdk-go-v2/config v1.18.21/go.mod h1:+jPQiVPz1diRnjj6VGqWcLK6EzNmQ42l7J3OqGTLsSY= +github.com/aws/aws-sdk-go-v2/credentials v1.13.20 h1:oZCEFcrMppP/CNiS8myzv9JgOzq2s0d3v3MXYil/mxQ= +github.com/aws/aws-sdk-go-v2/credentials v1.13.20/go.mod h1:xtZnXErtbZ8YGXC3+8WfajpMBn5Ga/3ojZdxHq6iI8o= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.2 h1:jOzQAesnBFDmz93feqKnsTHsXrlwWORNZMFHMV+WLFU= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.2/go.mod h1:cDh1p6XkSGSwSRIArWRc6+UqAQ7x4alQ0QfpVR6f+co= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.32 h1:dpbVNUjczQ8Ae3QKHbpHBpfvaVkRdesxpTOe9pTouhU= @@ -44,14 +45,14 @@ github.com/aws/aws-sdk-go-v2/internal/ini v1.3.33 h1:HbH1VjUgrCdLJ+4lnnuLI4iVNRv github.com/aws/aws-sdk-go-v2/internal/ini v1.3.33/go.mod h1:zG2FcwjQarWaqXSCGpgcr3RSjZ6dHGguZSppUL0XR7Q= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.26 h1:uUt4XctZLhl9wBE1L8lobU3bVN8SNUP7T+olb0bWBO4= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.26/go.mod h1:Bd4C/4PkVGubtNe5iMXu5BNnaBi/9t/UsFspPt4ram8= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.19.2 h1:mRA8bnA0zdTvsGXmoZ6EOmTTmORjEV1uareB4GfzfK0= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.19.2/go.mod h1:QNYziZIPDbKmKRoTHi9wkgqVidknyiGHfig1UNOojqk= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.7 h1:rrYYhsvcvg6CDDoo4GHKtAWBFutS86CpmGvqHJHYL9w= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.7/go.mod h1:GNIveDnP+aE3jujyUSH5aZ/rktsTM5EvtKnCqBZawdw= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.7 h1:Vjpjt3svuJ/u+eKRfycZwqLsLoxyuvvZyHMJSk+3k58= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.7/go.mod h1:44qFP1g7pfd+U+sQHLPalAPKnyfTZjJsYR4xIwsJy5o= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.8 h1:SQ8pPoXfzuz4DImO4KAi9xhO4ANG0Ckb5clZ5GoRAPw= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.8/go.mod h1:yyW88BEPXA2fGFyI2KCcZC3dNpiT0CZAHaF+i656/tQ= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.19.3 h1:bqvkwBuoYZ28Aybq10A9uXh7LkPCh7W4nd3l5bf3v5A= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.19.3/go.mod h1:QNYziZIPDbKmKRoTHi9wkgqVidknyiGHfig1UNOojqk= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.8 h1:5cb3D6xb006bPTqEfCNaEA6PPEfBXxxy4NNeX/44kGk= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.8/go.mod h1:GNIveDnP+aE3jujyUSH5aZ/rktsTM5EvtKnCqBZawdw= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.8 h1:NZaj0ngZMzsubWZbrEFSB4rgSQRbFq38Sd6KBxHuOIU= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.8/go.mod h1:44qFP1g7pfd+U+sQHLPalAPKnyfTZjJsYR4xIwsJy5o= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.9 h1:Qf1aWwnsNkyAoqDqmdM3nHwN78XQjec27LjM6b9vyfI= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.9/go.mod h1:yyW88BEPXA2fGFyI2KCcZC3dNpiT0CZAHaF+i656/tQ= github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aymanbagabas/go-osc52 v1.0.3/go.mod h1:zT8H+Rk4VSabYN90pWyugflM3ZhpTZNC7cASDfUCdT4= @@ -88,8 +89,8 @@ github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARu github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4= github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= -github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534 h1:rtAn27wIbmOGUs7RIbVgPEjb31ehTVniDwPGXyMxm5U= -github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -174,8 +175,8 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= -github.com/klauspost/compress v1.16.4 h1:91KN02FnsOYhuunwU4ssRe8lc2JosWmizWa91B5v1PU= -github.com/klauspost/compress v1.16.4/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= +github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -257,8 +258,8 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= -github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= +github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= +github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI= @@ -269,8 +270,8 @@ github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= -github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/skeema/knownhosts v1.1.0 h1:Wvr9V0MxhjRbl3f9nMnKnFfiWTJmtECJ9Njkea3ysW0= github.com/skeema/knownhosts v1.1.0/go.mod h1:sKFq3RD6/TKZkSWn8boUbDC7Qkgcv+8XXijpFO6roag= github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w=
chore
Update dependencies
1dc0dd30f062e11e704ccf23a6d0355eab187398
2023-03-12 04:23:59
Tom Payne
feat: add rbwFields template function
false
diff --git a/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/rbwFields.md b/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/rbwFields.md new file mode 100644 index 00000000000..7d84c183d55 --- /dev/null +++ b/assets/chezmoi.io/docs/reference/templates/bitwarden-functions/rbwFields.md @@ -0,0 +1,15 @@ +# `rbwFields` *name* + +`rbw` returns structured data retrieved from [Bitwarden](https://bitwarden.com) +using [`rbw`](https://github.com/doy/rbw). *arg*s are passed to `rbw get --raw` +and the output is parsed as JSON, and the elements of `fields` are returned as a dict +indexed by each field's `name`. + +The output from `rbw get --raw` is cached so calling `rbwFields` multiple times with +the same arguments will only invoke `rbwFields` once. + +!!! example + + ``` + {{ (rbwFields "item").name.value }} + ``` diff --git a/assets/chezmoi.io/mkdocs.yml b/assets/chezmoi.io/mkdocs.yml index ac05e99851d..92931c22aef 100644 --- a/assets/chezmoi.io/mkdocs.yml +++ b/assets/chezmoi.io/mkdocs.yml @@ -240,6 +240,7 @@ nav: - bitwardenAttachmentByRef: reference/templates/bitwarden-functions/bitwardenAttachmentByRef.md - bitwardenFields: reference/templates/bitwarden-functions/bitwardenFields.md - rbw: reference/templates/bitwarden-functions/rbw.md + - rbwFields: reference/templates/bitwarden-functions/rbwFields.md - gopass functions: - reference/templates/gopass-functions/index.md - gopass: reference/templates/gopass-functions/gopass.md diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index 4e740a6a14b..700b57cda9b 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -422,6 +422,7 @@ func newConfig(options ...configOption) (*Config, error) { "pruneEmptyDicts": c.pruneEmptyDictsTemplateFunc, "quoteList": c.quoteListTemplateFunc, "rbw": c.rbwTemplateFunc, + "rbwFields": c.rbwFieldsTemplateFunc, "replaceAllRegex": c.replaceAllRegexTemplateFunc, "secret": c.secretTemplateFunc, "secretJSON": c.secretJSONTemplateFunc, diff --git a/pkg/cmd/rbwtemplatefuncs.go b/pkg/cmd/rbwtemplatefuncs.go index 01d33cd64f6..9d3d92c875d 100644 --- a/pkg/cmd/rbwtemplatefuncs.go +++ b/pkg/cmd/rbwtemplatefuncs.go @@ -14,6 +14,27 @@ type rbwConfig struct { outputCache map[string][]byte } +func (c *Config) rbwFieldsTemplateFunc(name string) map[string]any { + args := []string{"get", "--raw", name} + output, err := c.rbwOutput(args) + if err != nil { + panic(err) + } + var data struct { + Fields []map[string]any `json:"fields"` + } + if err := json.Unmarshal(output, &data); err != nil { + panic(newParseCmdOutputError(c.RBW.Command, args, output, err)) + } + result := make(map[string]any) + for _, field := range data.Fields { + if name, ok := field["name"].(string); ok { + result[name] = field + } + } + return result +} + func (c *Config) rbwTemplateFunc(name string) map[string]any { args := []string{"get", "--raw", name} output, err := c.rbwOutput(args) diff --git a/pkg/cmd/testdata/scripts/rbw.txtar b/pkg/cmd/testdata/scripts/rbw.txtar index 1906c43605b..49cc79d0274 100644 --- a/pkg/cmd/testdata/scripts/rbw.txtar +++ b/pkg/cmd/testdata/scripts/rbw.txtar @@ -5,6 +5,10 @@ exec chezmoi execute-template '{{ (rbw "test-entry").data.password }}' stdout ^hunter2$ +# test rbwFields template function +exec chezmoi execute-template '{{ (rbwFields "test-entry").something.value }}' +stdout ^secret$ + -- bin/rbw -- #!/bin/sh
feat
add rbwFields template function
96083d4ce8173eb3edd5f5556f9b184fc460004c
2024-01-13 23:16:57
Tom Payne
chore: Join some long lines
false
diff --git a/internal/chezmoi/chezmoi.go b/internal/chezmoi/chezmoi.go index ccd7e424596..4de928038c1 100644 --- a/internal/chezmoi/chezmoi.go +++ b/internal/chezmoi/chezmoi.go @@ -139,8 +139,7 @@ func FQDNHostname(fileSystem vfs.FS) (string, error) { // Otherwise, if we're on OpenBSD, try /etc/myname. if runtime.GOOS == "openbsd" { - if fqdnHostname, err := etcMynameFQDNHostname(fileSystem); err == nil && - fqdnHostname != "" { + if fqdnHostname, err := etcMynameFQDNHostname(fileSystem); err == nil && fqdnHostname != "" { return fqdnHostname, nil } } diff --git a/internal/chezmoi/entrytypefilter.go b/internal/chezmoi/entrytypefilter.go index a03e8dcd122..d63f9d0f92c 100644 --- a/internal/chezmoi/entrytypefilter.go +++ b/internal/chezmoi/entrytypefilter.go @@ -21,8 +21,7 @@ func NewEntryTypeFilter(includeEntryTypeBits, excludeEntryTypeBits EntryTypeBits // IncludeEntryTypeBits returns if entryTypeBits is included. func (f *EntryTypeFilter) IncludeEntryTypeBits(entryTypeBits EntryTypeBits) bool { - return f.Include.ContainsEntryTypeBits(entryTypeBits) && - !f.Exclude.ContainsEntryTypeBits(entryTypeBits) + return f.Include.ContainsEntryTypeBits(entryTypeBits) && !f.Exclude.ContainsEntryTypeBits(entryTypeBits) } // IncludeFileInfo returns if fileInfo is included. @@ -32,12 +31,10 @@ func (f *EntryTypeFilter) IncludeFileInfo(fileInfo fs.FileInfo) bool { // IncludeSourceStateEntry returns if sourceStateEntry is included. func (f *EntryTypeFilter) IncludeSourceStateEntry(sourceStateEntry SourceStateEntry) bool { - return f.Include.ContainsSourceStateEntry(sourceStateEntry) && - !f.Exclude.ContainsSourceStateEntry(sourceStateEntry) + return f.Include.ContainsSourceStateEntry(sourceStateEntry) && !f.Exclude.ContainsSourceStateEntry(sourceStateEntry) } // IncludeTargetStateEntry returns if targetStateEntry is included. func (f *EntryTypeFilter) IncludeTargetStateEntry(targetStateEntry TargetStateEntry) bool { - return f.Include.ContainsTargetStateEntry(targetStateEntry) && - !f.Exclude.ContainsTargetStateEntry(targetStateEntry) + return f.Include.ContainsTargetStateEntry(targetStateEntry) && !f.Exclude.ContainsTargetStateEntry(targetStateEntry) } diff --git a/internal/chezmoi/externaldiffsystem.go b/internal/chezmoi/externaldiffsystem.go index d50f45b6a59..fdb287c6e15 100644 --- a/internal/chezmoi/externaldiffsystem.go +++ b/internal/chezmoi/externaldiffsystem.go @@ -57,8 +57,7 @@ func NewExternalDiffSystem( // Close frees all resources held by s. func (s *ExternalDiffSystem) Close() error { if !s.tempDirAbsPath.Empty() { - if err := os.RemoveAll(s.tempDirAbsPath.String()); err != nil && - !errors.Is(err, fs.ErrNotExist) { + if err := os.RemoveAll(s.tempDirAbsPath.String()); err != nil && !errors.Is(err, fs.ErrNotExist) { return err } s.tempDirAbsPath = EmptyAbsPath @@ -333,8 +332,7 @@ func (s *ExternalDiffSystem) runDiffCommand(destAbsPath, targetAbsPath AbsPath) // Swallow exit status 1 errors if the files differ as diff commands // traditionally exit with code 1 in this case. - if exitError := (&exec.ExitError{}); errors.As(err, &exitError) && - exitError.ProcessState.ExitCode() == 1 { + if exitError := (&exec.ExitError{}); errors.As(err, &exitError) && exitError.ProcessState.ExitCode() == 1 { destData, err2 := s.ReadFile(destAbsPath) switch { case errors.Is(err2, fs.ErrNotExist): diff --git a/internal/chezmoi/path_windows.go b/internal/chezmoi/path_windows.go index fb6b7eb582e..0b1d5f17079 100644 --- a/internal/chezmoi/path_windows.go +++ b/internal/chezmoi/path_windows.go @@ -64,8 +64,7 @@ func volumeNameLen(path string) int { return 2 } // is it UNC? https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx - if l := len(path); l >= 5 && isSlash(path[0]) && isSlash(path[1]) && - !isSlash(path[2]) && path[2] != '.' { + if l := len(path); l >= 5 && isSlash(path[0]) && isSlash(path[1]) && !isSlash(path[2]) && path[2] != '.' { // first, leading `\\` and next shouldn't be `\`. its server name. for n := 3; n < l-1; n++ { // second, next '\' shouldn't be repeated. diff --git a/internal/chezmoi/realsystem_unix.go b/internal/chezmoi/realsystem_unix.go index b837824d5a7..2c96fb4e69c 100644 --- a/internal/chezmoi/realsystem_unix.go +++ b/internal/chezmoi/realsystem_unix.go @@ -114,8 +114,7 @@ func (s *RealSystem) WriteSymlink(oldname string, newname AbsPath) error { if s.safe && s.fileSystem == vfs.OSFS { return renameio.Symlink(oldname, newname.String()) } - if err := s.fileSystem.RemoveAll(newname.String()); err != nil && - !errors.Is(err, fs.ErrNotExist) { + if err := s.fileSystem.RemoveAll(newname.String()); err != nil && !errors.Is(err, fs.ErrNotExist) { return err } return s.fileSystem.Symlink(oldname, newname.String()) diff --git a/internal/chezmoi/realsystem_windows.go b/internal/chezmoi/realsystem_windows.go index 901f7c71662..57305a68091 100644 --- a/internal/chezmoi/realsystem_windows.go +++ b/internal/chezmoi/realsystem_windows.go @@ -62,8 +62,7 @@ func (s *RealSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) // WriteSymlink implements System.WriteSymlink. func (s *RealSystem) WriteSymlink(oldname string, newname AbsPath) error { - if err := s.fileSystem.RemoveAll(newname.String()); err != nil && - !errors.Is(err, fs.ErrNotExist) { + if err := s.fileSystem.RemoveAll(newname.String()); err != nil && !errors.Is(err, fs.ErrNotExist) { return err } return s.fileSystem.Symlink(filepath.FromSlash(oldname), newname.String()) diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go index 3a0ac34401a..7f5794e6631 100644 --- a/internal/chezmoi/sourcestate.go +++ b/internal/chezmoi/sourcestate.go @@ -55,8 +55,8 @@ var ( templateDirectiveKeyValuePairRx = regexp.MustCompile(`\s*(\S+)=("(?:[^"]|\\")*"|\S+)`) // AppleDouble constants. - appleDoubleMagicCode = []byte{0x00, 0x05, 0x16, 0x07} - appleDoubleVersion = []byte{0x00, 0x02, 0x00, 0x00} + appleDoubleNamePrefix = "._" + appleDoubleContentsPrefix = []byte{0x00, 0x05, 0x16, 0x07, 0x00, 0x02, 0x00, 0x00} ) type externalArchive struct { @@ -697,8 +697,7 @@ func (s *SourceState) Apply( // the source and target states: instead of reporting a diff with // respect to the last written state, we record the effect of the last // apply as the last written state. - if targetEntryState.Equivalent(actualEntryState) && - !lastWrittenEntryState.Equivalent(actualEntryState) { + if targetEntryState.Equivalent(actualEntryState) && !lastWrittenEntryState.Equivalent(actualEntryState) { err := PersistentStateSet(persistentState, EntryStateBucket, targetAbsPath.Bytes(), targetEntryState) if err != nil { return err @@ -894,8 +893,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error { // Some programs (notably emacs) use invalid symlinks as lockfiles. // To avoid following them and getting an ENOENT error, check first // if this is an entry that we will ignore anyway. - if strings.HasPrefix(fileInfo.Name(), ignorePrefix) && - !strings.HasPrefix(fileInfo.Name(), Prefix) { + if strings.HasPrefix(fileInfo.Name(), ignorePrefix) && !strings.HasPrefix(fileInfo.Name(), Prefix) { return nil } fileInfo, err = s.system.Stat(sourceAbsPath) @@ -1512,8 +1510,7 @@ func (s *SourceState) getExternalDataRaw( case RefreshExternalsAuto: // Use the cache, if available and within the refresh period. if fileInfo, err := s.baseSystem.Stat(cachedDataAbsPath); err == nil { - if external.RefreshPeriod == 0 || - fileInfo.ModTime().Add(time.Duration(external.RefreshPeriod)).After(now) { + if external.RefreshPeriod == 0 || fileInfo.ModTime().Add(time.Duration(external.RefreshPeriod)).After(now) { if data, err := s.baseSystem.ReadFile(cachedDataAbsPath); err == nil { return data, nil } @@ -1719,9 +1716,7 @@ func (s *SourceState) newFileTargetStateEntryFunc( sourceLazyContents *lazyContents, ) targetStateEntryFunc { return func(destSystem System, destAbsPath AbsPath) (TargetStateEntry, error) { - if s.mode == ModeSymlink && !fileAttr.Encrypted && !fileAttr.Executable && - !fileAttr.Private && - !fileAttr.Template { + if s.mode == ModeSymlink && !fileAttr.Encrypted && !fileAttr.Executable && !fileAttr.Private && !fileAttr.Template { switch contents, err := sourceLazyContents.Contents(); { case err != nil: return nil, err @@ -2640,8 +2635,7 @@ func (s *SourceState) readScriptsDir(ctx context.Context, scriptsDirAbsPath AbsP // Some programs (notably emacs) use invalid symlinks as lockfiles. // To avoid following them and getting an ENOENT error, check first // if this is an entry that we will ignore anyway. - if strings.HasPrefix(fileInfo.Name(), ignorePrefix) && - !strings.HasPrefix(fileInfo.Name(), Prefix) { + if strings.HasPrefix(fileInfo.Name(), ignorePrefix) && !strings.HasPrefix(fileInfo.Name(), Prefix) { return nil } fileInfo, err = s.system.Stat(sourceAbsPath) @@ -2787,8 +2781,5 @@ func allEquivalentDirs(sourceStateEntries []SourceStateEntry) bool { // isAppleDoubleFile returns true if the file looks like and has the // expected signature of an AppleDouble file. func isAppleDoubleFile(name string, contents []byte) bool { - return strings.HasPrefix(path.Base(name), "._") && - len(contents) >= 8 && - bytes.Equal(appleDoubleMagicCode, contents[0:4]) && - bytes.Equal(appleDoubleVersion, contents[4:8]) + return strings.HasPrefix(path.Base(name), appleDoubleNamePrefix) && bytes.HasPrefix(contents, appleDoubleContentsPrefix) } diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 2cc41cac450..e7d952d39fc 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -109,8 +109,8 @@ func (v VersionInfo) MarshalZerologObject(e *zerolog.Event) { // Main runs chezmoi and returns an exit code. func Main(versionInfo VersionInfo, args []string) int { err := runMain(versionInfo, args) - if err != nil && strings.Contains(err.Error(), "unknown command") && - len(args) > 0 { // FIXME find a better way of detecting unknown commands + // FIXME find a better way of detecting unknown commands + if err != nil && strings.Contains(err.Error(), "unknown command") && len(args) > 0 { if name, err2 := exec.LookPath("chezmoi-" + args[0]); err2 == nil { cmd := exec.Command(name, args[1:]...) cmd.Stdin = os.Stdin diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 574cfe3886d..2442cfca6cd 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -578,8 +578,7 @@ func (c *Config) applyArgs( } previousConfigTemplateContentsSHA256 = []byte(configState.ConfigTemplateContentsSHA256) } - configTemplatesEmpty := currentConfigTemplateContentsSHA256 == nil && - previousConfigTemplateContentsSHA256 == nil + configTemplatesEmpty := currentConfigTemplateContentsSHA256 == nil && previousConfigTemplateContentsSHA256 == nil configTemplateContentsUnchanged := configTemplatesEmpty || bytes.Equal(currentConfigTemplateContentsSHA256, previousConfigTemplateContentsSHA256) if !configTemplateContentsUnchanged { @@ -905,8 +904,7 @@ func (c *Config) decodeConfigFile(configFileAbsPath chezmoi.AbsPath, configFile return fmt.Errorf("%s: %w", configFileAbsPath, err) } - if configFile.Git.CommitMessageTemplate != "" && - configFile.Git.CommitMessageTemplateFile != "" { + if configFile.Git.CommitMessageTemplate != "" && configFile.Git.CommitMessageTemplateFile != "" { return fmt.Errorf( "%s: cannot specify both git.commitMessageTemplate and git.commitMessageTemplateFile", configFileAbsPath, @@ -2000,8 +1998,7 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error c.destSystem = chezmoi.NewDryRunSystem(c.destSystem) } if annotations.hasTag(outputsDiff) || - c.Verbose && - (annotations.hasTag(modifiesDestinationDirectory) || annotations.hasTag(modifiesSourceDirectory)) { + c.Verbose && (annotations.hasTag(modifiesDestinationDirectory) || annotations.hasTag(modifiesSourceDirectory)) { // If the user has configured a diff pager, then start it as a process. // Otherwise, write the diff output directly to stdout. var writer io.Writer diff --git a/internal/cmd/mackupcmd_darwin.go b/internal/cmd/mackupcmd_darwin.go index b40a95fadf6..95ef24acf23 100644 --- a/internal/cmd/mackupcmd_darwin.go +++ b/internal/cmd/mackupcmd_darwin.go @@ -143,8 +143,7 @@ func (c *Config) mackupApplicationsDir() (chezmoi.AbsPath, error) { continue } mackupApplicationsDirAbsPath := libDirAbsPath.JoinString(dirEntry.Name(), "site-packages", "mackup", "applications") - if fileInfo, err := c.baseSystem.Stat(mackupApplicationsDirAbsPath); err == nil && - fileInfo.IsDir() { + if fileInfo, err := c.baseSystem.Stat(mackupApplicationsDirAbsPath); err == nil && fileInfo.IsDir() { return mackupApplicationsDirAbsPath, nil } } diff --git a/internal/cmd/mergeallcmd.go b/internal/cmd/mergeallcmd.go index fb1ed56de09..91079a1b261 100644 --- a/internal/cmd/mergeallcmd.go +++ b/internal/cmd/mergeallcmd.go @@ -43,8 +43,7 @@ func (c *Config) newMergeAllCmd() *cobra.Command { func (c *Config) runMergeAllCmd(cmd *cobra.Command, args []string) error { var targetRelPaths []chezmoi.RelPath preApplyFunc := func(targetRelPath chezmoi.RelPath, targetEntryState, lastWrittenEntryState, actualEntryState *chezmoi.EntryState) error { - if targetEntryState.Type == chezmoi.EntryStateTypeFile && - !targetEntryState.Equivalent(actualEntryState) { + if targetEntryState.Type == chezmoi.EntryStateTypeFile && !targetEntryState.Equivalent(actualEntryState) { targetRelPaths = append(targetRelPaths, targetRelPath) } return fs.SkipDir diff --git a/internal/cmd/removecmd.go b/internal/cmd/removecmd.go index a41bc0964be..2f6efb8ecfe 100644 --- a/internal/cmd/removecmd.go +++ b/internal/cmd/removecmd.go @@ -88,13 +88,11 @@ func (c *Config) runRemoveCmd(cmd *cobra.Command, args []string, sourceState *ch return nil } } - if err := c.destSystem.RemoveAll(destAbsPath); err != nil && - !errors.Is(err, fs.ErrNotExist) { + if err := c.destSystem.RemoveAll(destAbsPath); err != nil && !errors.Is(err, fs.ErrNotExist) { return err } if !sourceAbsPath.Empty() { - if err := c.sourceSystem.RemoveAll(sourceAbsPath); err != nil && - !errors.Is(err, fs.ErrNotExist) { + if err := c.sourceSystem.RemoveAll(sourceAbsPath); err != nil && !errors.Is(err, fs.ErrNotExist) { return err } } diff --git a/internal/cmd/textconv.go b/internal/cmd/textconv.go index 1149ea8de1d..11e691d3009 100644 --- a/internal/cmd/textconv.go +++ b/internal/cmd/textconv.go @@ -28,8 +28,7 @@ func (t textConv) convert(path string, data []byte) ([]byte, error) { if !ok { continue } - if longestPatternElement == nil || - len(command.Pattern) > len(longestPatternElement.Pattern) { + if longestPatternElement == nil || len(command.Pattern) > len(longestPatternElement.Pattern) { longestPatternElement = command } }
chore
Join some long lines