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
ce7ce14fe6cb6b9b71438576c29806b000c4942e
2022-04-01 23:02:51
dependabot[bot]
chore(deps): bump actions/cache from 2 to 3.0.1
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1bf12d5b97e..210296973d5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -88,7 +88,7 @@ jobs: VAGRANT_BOX: debian11-i386 steps: - uses: actions/checkout@v3 - - uses: actions/cache@v2 + - uses: actions/[email protected] with: path: ~/.vagrant.d key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/debian11-i386.Vagrantfile') }} @@ -116,7 +116,7 @@ jobs: VAGRANT_BOX: freebsd13 steps: - uses: actions/checkout@v3 - - uses: actions/cache@v2 + - uses: actions/[email protected] with: path: ~/.vagrant.d key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/freebsd13.Vagrantfile') }} @@ -134,7 +134,7 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - uses: actions/checkout@v3 - - uses: actions/cache@v2 + - uses: actions/[email protected] with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} @@ -170,7 +170,7 @@ jobs: VAGRANT_BOX: openbsd6 steps: - uses: actions/checkout@v3 - - uses: actions/cache@v2 + - uses: actions/[email protected] with: path: ~/.vagrant.d key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/openbsd6.Vagrantfile') }} @@ -187,7 +187,7 @@ jobs: VAGRANT_BOX: openindiana steps: - uses: actions/checkout@v3 - - uses: actions/cache@v2 + - uses: actions/[email protected] with: path: ~/.vagrant.d key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/openindiana.Vagrantfile') }} @@ -213,7 +213,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/cache@v2 + - uses: actions/[email protected] with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} @@ -301,7 +301,7 @@ jobs: with: go-version: 1.16.x - uses: actions/checkout@v3 - - uses: actions/cache@v2 + - uses: actions/[email protected] with: path: ~/go/pkg/mod key: ${{ runner.os }}-ubuntu-go-1-16-${{ hashFiles('**/go.sum') }} @@ -333,7 +333,7 @@ jobs: with: go-version: 1.17.x - uses: actions/checkout@v3 - - uses: actions/cache@v2 + - uses: actions/[email protected] with: path: ~/go/pkg/mod key: ${{ runner.os }}-ubuntu-go-1-17-${{ hashFiles('**/go.sum') }} @@ -365,7 +365,7 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - uses: actions/checkout@v3 - - uses: actions/cache@v2 + - uses: actions/[email protected] with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} @@ -406,7 +406,7 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - uses: actions/checkout@v3 - - uses: actions/cache@v2 + - uses: actions/[email protected] with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} @@ -470,7 +470,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/cache@v2 + - uses: actions/[email protected] with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
chore
bump actions/cache from 2 to 3.0.1
483b8230b6f87e8607f09ccb3c90fa1698f4ded1
2022-10-18 01:51:46
dependabot[bot]
chore(deps): bump dorny/paths-filter from 2.10.2 to 2.11.1
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d66f119e18d..7b20eff0ad8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - id: filter - uses: dorny/paths-filter@b2feaf19c27470162a626bd6fa8438ae5b263721 + uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 with: filters: | code:
chore
bump dorny/paths-filter from 2.10.2 to 2.11.1
b56a6005e871d1ba3abe60bd8b923f1ec2ce42f7
2024-09-10 04:04:21
Tom Payne
docs: Add FAQ entry on literal {{ and }} in templates
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 19e5898ca06..f62aaf49f38 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 @@ -122,6 +122,34 @@ chezmoi will make sure to execute it before templating other files. You can [use `scriptEnv` to inject data into your scripts through environment variables](../../user-guide/use-scripts-to-perform-actions.md#set-environment-variables). +## How do I write a literal `{{` or `}}` in a template? + +`{{` and `}}` are chezmoi's default template delimiters, and so need escaping, for example: + +``` +{{ "{{" }} +{{ "}}" }} +``` + +results in + +``` +{{ +}} +``` + +For longer tokens containing a `{{` and a `}}` you can use a longer literal, for example: + +``` +{{ "{{ .Target }}" }} +``` + +results in + +``` +{{ .Target }} +``` + ## How do I enable shell completions? chezmoi includes shell completions for
docs
Add FAQ entry on literal {{ and }} in templates
2f7b26d2f84c279bca652a11344ce4cd31365f3b
2024-10-10 03:43:30
Tom Payne
chore: Update tools
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c6110037f92..8fcc280a3b3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ on: schedule: - cron: 32 2 * * * env: - ACTIONLINT_VERSION: 1.7.2 # https://github.com/rhysd/actionlint/releases + ACTIONLINT_VERSION: 1.7.3 # https://github.com/rhysd/actionlint/releases AGE_VERSION: 1.2.0 # https://github.com/FiloSottile/age/releases CHOCOLATEY_VERSION: 2.3.0 # https://github.com/chocolatey/choco/releases EDITORCONFIG_CHECKER_VERSION: 3.0.3 # https://github.com/editorconfig-checker/editorconfig-checker/releases @@ -24,7 +24,7 @@ env: GOVERSIONINFO_VERSION: 1.4.1 # https://github.com/josephspurrier/goversioninfo/releases PYTHON_VERSION: '3.10' # https://www.python.org/downloads/ RAGE_VERSION: 0.10.0 # https://github.com/str4d/rage/releases - UV_VERSION: 0.4.17 # https://github.com/astral-sh/uv/releases + UV_VERSION: 0.4.20 # https://github.com/astral-sh/uv/releases jobs: changes: runs-on: ubuntu-22.04
chore
Update tools
59cb471e285bc97bffaf1e2cef0b6895ebcd2267
2022-08-08 02:41:16
Tom Payne
chore: Drop OpenBSD tests
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index efd587ecb98..028bb7c83a4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -175,21 +175,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-12 - steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - - uses: actions/cache@0865c47f36e68161719c5b124609996bb5c40129 - with: - path: ~/.vagrant.d - key: ${{ runner.os }}-vagrant-openbsd7-${{ hashFiles('assets/vagrant/openbsd7.Vagrantfile') }} - restore-keys: | - ${{ runner.os }}-vagrant-openbsd7- - - name: test - run: | - ( cd assets/vagrant && ./test.sh openbsd7 ) test-ubuntu: needs: changes runs-on: ubuntu-18.04 @@ -385,7 +370,6 @@ jobs: - test-freebsd - test-legacy-go - test-macos - - test-openbsd - test-ubuntu - test-website - test-windows
chore
Drop OpenBSD tests
337fd944147a5a4a091a3f1cb0a8c9d828d51400
2021-10-22 01:43:17
Tom Payne
chore: Use more portable pwd in tests
false
diff --git a/internal/cmd/main_test.go b/internal/cmd/main_test.go index b283ede9e01..d20be00a657 100644 --- a/internal/cmd/main_test.go +++ b/internal/cmd/main_test.go @@ -668,7 +668,7 @@ func setup(env *testscript.Env) error { Contents: []byte(chezmoitest.JoinLines( `#!/bin/sh`, ``, - `echo $PWD >> '`+filepath.Join(env.WorkDir, "shell.log")+`'`, + `pwd >> '`+filepath.Join(env.WorkDir, "shell.log")+`'`, )), }, } diff --git a/internal/cmd/testdata/scripts/runscriptdir_unix.txt b/internal/cmd/testdata/scripts/runscriptdir_unix.txt index f1a652b8563..fd4f9c89838 100644 --- a/internal/cmd/testdata/scripts/runscriptdir_unix.txt +++ b/internal/cmd/testdata/scripts/runscriptdir_unix.txt @@ -31,10 +31,10 @@ dir/script "dir/script": { "type": "script", "name": "dir/script", - "contents": "#!/bin/sh\n\necho $PWD\n" + "contents": "#!/bin/sh\n\npwd\n" } } -- home/user/.local/share/chezmoi/dir/run_script -- #!/bin/sh -echo $PWD +pwd diff --git a/internal/cmd/testdata/scripts/script_unix.txt b/internal/cmd/testdata/scripts/script_unix.txt index 82780f93e0f..190a6018bef 100644 --- a/internal/cmd/testdata/scripts/script_unix.txt +++ b/internal/cmd/testdata/scripts/script_unix.txt @@ -41,19 +41,19 @@ cmp stdout golden/archive script -- golden/diff -- diff --git a/script b/script -index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..4a10a731080ff0306ef247ca4557e1902ac3bc5d 100755 +index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f9103e018df1bbc178e66b46d8f133f49c85225d 100755 --- a/script +++ b/script @@ -0,0 +1,3 @@ +#!/bin/sh + -+echo $PWD ++pwd -- golden/dump.json -- { "script": { "type": "script", "name": "script", - "contents": "#!/bin/sh\n\necho $PWD\n" + "contents": "#!/bin/sh\n\npwd\n" } } -- golden/managed -- @@ -61,10 +61,10 @@ script -- golden/script -- #!/bin/sh -echo $PWD +pwd -- golden/status -- R script -- home/user/.local/share/chezmoi/run_script -- #!/bin/sh -echo $PWD +pwd diff --git a/internal/cmd/testdata/scripts/scriptonce_unix.txt b/internal/cmd/testdata/scripts/scriptonce_unix.txt index 1ecdadf35c0..c1957bbe552 100644 --- a/internal/cmd/testdata/scripts/scriptonce_unix.txt +++ b/internal/cmd/testdata/scripts/scriptonce_unix.txt @@ -14,7 +14,7 @@ stdout ${HOME@R} # test that the script is recorded in the state chezmoi state dump -stdout 94d80d5c9f06d747eb874b0a05a356085515b51ac8761a923079db734fe68133 # sha256sum of script contents +stdout bb29fcd5733098d4e391d85d487d84d1d64cf42eae34b53951ae470b98c9ca8d # sha256sum of script contents # test that chezmoi diff no longer includes the script chezmoi diff @@ -40,16 +40,16 @@ stdout ${HOME@R} -- golden/diff -- diff --git a/script b/script -index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..4a10a731080ff0306ef247ca4557e1902ac3bc5d 100755 +index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f9103e018df1bbc178e66b46d8f133f49c85225d 100755 --- a/script +++ b/script @@ -0,0 +1,3 @@ +#!/bin/sh + -+echo $PWD ++pwd -- golden/status -- R script -- home/user/.local/share/chezmoi/run_once_script -- #!/bin/sh -echo $PWD +pwd diff --git a/internal/cmd/testdata/scripts/scriptsubdir_unix.txt b/internal/cmd/testdata/scripts/scriptsubdir_unix.txt index c91e63befad..42ab23b5935 100644 --- a/internal/cmd/testdata/scripts/scriptsubdir_unix.txt +++ b/internal/cmd/testdata/scripts/scriptsubdir_unix.txt @@ -41,7 +41,7 @@ anotherdir/script "anotherdir/script": { "type": "script", "name": "anotherdir/script", - "contents": "#!/bin/sh\n\necho $PWD\n" + "contents": "#!/bin/sh\n\npwd\n" }, "dir": { "type": "dir", @@ -51,7 +51,7 @@ anotherdir/script "dir/script": { "type": "script", "name": "dir/script", - "contents": "#!/bin/sh\n\necho $PWD\n" + "contents": "#!/bin/sh\n\npwd\n" }, "otherdir": { "type": "dir", @@ -61,18 +61,18 @@ anotherdir/script "otherdir/script": { "type": "script", "name": "otherdir/script", - "contents": "#!/bin/sh\n\necho $PWD\n" + "contents": "#!/bin/sh\n\npwd\n" } } -- home/user/.local/share/chezmoi/anotherdir/run_after_script -- #!/bin/sh -echo $PWD +pwd -- home/user/.local/share/chezmoi/dir/run_script -- #!/bin/sh -echo $PWD +pwd -- home/user/.local/share/chezmoi/otherdir/run_before_script -- #!/bin/sh -echo $PWD +pwd
chore
Use more portable pwd in tests
33c4c4bb86cb1c29acbe4ca698fd4220c28c276c
2023-02-25 16:26:10
Tom Payne
chore: Enable most govet linters
false
diff --git a/.golangci.yml b/.golangci.yml index acb2d9ecbbe..883ae4cd54d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -51,7 +51,6 @@ linters: - promlinter - reassign - revive - - sqlclosecheck - staticcheck - stylecheck - tagliatelle @@ -115,6 +114,11 @@ linters-settings: module-path: github.com/twpayne/chezmoi goimports: local-prefixes: github.com/twpayne/chezmoi + govet: + disable: + - fieldalignment + - shadow + enable-all: true ireturn: allow: - anon diff --git a/pkg/cmd/cdcmd.go b/pkg/cmd/cdcmd.go index d3247429fee..caf9a12dc20 100644 --- a/pkg/cmd/cdcmd.go +++ b/pkg/cmd/cdcmd.go @@ -39,23 +39,26 @@ func (c *Config) runCDCmd(cmd *cobra.Command, args []string) error { var dir chezmoi.AbsPath if len(args) == 0 { dir = c.WorkingTreeAbsPath - } else if argAbsPath, err := chezmoi.NewAbsPathFromExtPath(args[0], c.homeDirAbsPath); err != nil { - return err - } else if argAbsPath == c.DestDirAbsPath { - dir, err = c.getSourceDirAbsPath(nil) - if err != nil { - return err - } } else { - sourceState, err := c.getSourceState(cmd.Context()) - if err != nil { - return err - } - sourceAbsPaths, err := c.sourceAbsPaths(sourceState, args) - if err != nil { + switch argAbsPath, err := chezmoi.NewAbsPathFromExtPath(args[0], c.homeDirAbsPath); { + case err != nil: return err + case argAbsPath == c.DestDirAbsPath: + dir, err = c.getSourceDirAbsPath(nil) + if err != nil { + return err + } + default: + sourceState, err := c.getSourceState(cmd.Context()) + if err != nil { + return err + } + sourceAbsPaths, err := c.sourceAbsPaths(sourceState, args) + if err != nil { + return err + } + dir = sourceAbsPaths[0] } - dir = sourceAbsPaths[0] } return c.run(dir, cdCommand, cdArgs) } diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index a049a449153..b2be203dfb2 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -1827,7 +1827,7 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error // Do nothing. case err == nil: return fmt.Errorf("%s: not a directory", c.SourceDirAbsPath) - case err != nil: + default: return err } } @@ -2205,9 +2205,6 @@ func (c *Config) targetRelPaths( if err != nil { return nil, err } - if err != nil { - return nil, err - } if options.mustBeInSourceState { if !sourceState.Contains(targetRelPath) { return nil, fmt.Errorf("%s: not in source state", arg) diff --git a/pkg/cmd/keepassxctemplatefuncs.go b/pkg/cmd/keepassxctemplatefuncs.go index 1528f74b777..b056e5a8d59 100644 --- a/pkg/cmd/keepassxctemplatefuncs.go +++ b/pkg/cmd/keepassxctemplatefuncs.go @@ -165,7 +165,7 @@ func keepassxcParseOutput(output []byte) (map[string]string, error) { case match != nil: key = match[1] data[key] = match[2] - case match == nil && key != "": + case key != "": data[key] += "\n" + s.Text() } } diff --git a/pkg/cmd/updatecmd.go b/pkg/cmd/updatecmd.go index bd7db3f70b0..9c449eaf4f3 100644 --- a/pkg/cmd/updatecmd.go +++ b/pkg/cmd/updatecmd.go @@ -74,17 +74,17 @@ func (c *Config) runUpdateCmd(cmd *cobra.Command, args []string) error { return err } default: - args := []string{ + gitArgs := []string{ "pull", "--autostash", "--rebase", } if c.Update.RecurseSubmodules { - args = append(args, + gitArgs = append(gitArgs, "--recurse-submodules", ) } - if err := c.run(c.WorkingTreeAbsPath, c.Git.Command, args); err != nil { + if err := c.run(c.WorkingTreeAbsPath, c.Git.Command, gitArgs); err != nil { return err } }
chore
Enable most govet linters
31787ed6e0496a8265f717b4e1e9de67186b973a
2023-07-31 22:31:01
Tom Payne
feat: Read personal mackup config files
false
diff --git a/internal/cmd/mackupcmd_darwin.go b/internal/cmd/mackupcmd_darwin.go index 86a412e6c6a..1ce9d91e729 100644 --- a/internal/cmd/mackupcmd_darwin.go +++ b/internal/cmd/mackupcmd_darwin.go @@ -5,7 +5,9 @@ package cmd import ( "bufio" "bytes" + "errors" "fmt" + "os" "os/exec" "regexp" "strings" @@ -70,11 +72,14 @@ func (c *Config) runMackupAddCmd( return err } + mackupDirAbsPath := c.homeDirAbsPath.JoinString(".mackup") var addArgs []string for _, arg := range args { - data, err := c.baseSystem.ReadFile( - mackupApplicationsDir.Join(chezmoi.NewRelPath(arg + ".cfg")), - ) + configRelPath := chezmoi.NewRelPath(arg + ".cfg") + data, err := c.baseSystem.ReadFile(mackupDirAbsPath.Join(configRelPath)) + if errors.Is(err, os.ErrNotExist) { + data, err = c.baseSystem.ReadFile(mackupApplicationsDir.Join(configRelPath)) + } if err != nil { return err } diff --git a/internal/cmd/testdata/scripts/mackup_darwin.txt b/internal/cmd/testdata/scripts/mackup_darwin.txtar similarity index 92% rename from internal/cmd/testdata/scripts/mackup_darwin.txt rename to internal/cmd/testdata/scripts/mackup_darwin.txtar index 54fb6f927b2..20b76841b27 100644 --- a/internal/cmd/testdata/scripts/mackup_darwin.txt +++ b/internal/cmd/testdata/scripts/mackup_darwin.txtar @@ -41,7 +41,7 @@ esac # 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 -- +-- home/user/.mackup/curl.cfg -- [application] name = Curl
feat
Read personal mackup config files
aa9e8662e5dacd1dd9e9f6482a3d17aa9dd5ddcf
2023-11-20 07:08:34
Tom Payne
chore: Update dependencies
false
diff --git a/go.mod b/go.mod index ed81f9fee98..0be0ffd0433 100644 --- a/go.mod +++ b/go.mod @@ -9,9 +9,9 @@ require ( github.com/Masterminds/sprig/v3 v3.2.3 github.com/Shopify/ejson v1.4.1 github.com/alecthomas/assert/v2 v2.4.0 - github.com/aws/aws-sdk-go-v2 v1.22.2 - github.com/aws/aws-sdk-go-v2/config v1.24.0 - github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.23.1 + github.com/aws/aws-sdk-go-v2 v1.23.0 + github.com/aws/aws-sdk-go-v2/config v1.25.3 + github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.23.2 github.com/bmatcuk/doublestar/v4 v4.6.1 github.com/bradenhilton/mozillainstallhash v1.0.1 github.com/charmbracelet/bubbles v0.16.1 @@ -24,7 +24,7 @@ require ( github.com/google/renameio/v2 v2.0.0 github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 github.com/itchyny/gojq v0.12.13 - github.com/klauspost/compress v1.17.2 + github.com/klauspost/compress v1.17.3 github.com/mitchellh/copystructure v1.2.0 github.com/mitchellh/mapstructure v1.5.0 github.com/muesli/combinator v0.3.0 @@ -71,16 +71,17 @@ require ( github.com/alecthomas/repr v0.3.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.15.2 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.3 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.2 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.2 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.7.0 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.2 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.17.1 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.19.1 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.25.1 // indirect - github.com/aws/smithy-go v1.16.0 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.16.2 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.4 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.3 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.3 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.7.1 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.1 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.3 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.17.2 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.20.0 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.25.3 // indirect + github.com/aws/smithy-go v1.17.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 a4313a0fc30..5060797002a 100644 --- a/go.sum +++ b/go.sum @@ -50,32 +50,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.22.2 h1:lV0U8fnhAnPz8YcdmZVV60+tr6CakHzqA6P8T46ExJI= -github.com/aws/aws-sdk-go-v2 v1.22.2/go.mod h1:Kd0OJtkW3Q0M0lUWGszapWjEvrXDzRW+D21JNsroB+c= -github.com/aws/aws-sdk-go-v2/config v1.24.0 h1:4LEk29JO3w+y9dEo/5Tq5QTP7uIEw+KQrKiHOs4xlu4= -github.com/aws/aws-sdk-go-v2/config v1.24.0/go.mod h1:11nNDAuK86kOUHeuEQo8f3CkcV5xuUxvPwFjTZE/PnQ= -github.com/aws/aws-sdk-go-v2/credentials v1.15.2 h1:rKH7khRMxPdD0u3dHecd0Q7NOVw3EUe7AqdkUOkiOGI= -github.com/aws/aws-sdk-go-v2/credentials v1.15.2/go.mod h1:tXM8wmaeAhfC7nZoCxb0FzM/aRaB1m1WQ7x0qlBLq80= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.3 h1:G5KawTAkyHH6WyKQCdHiW4h3PmAXNJpOgwKg3H7sDRE= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.3/go.mod h1:hugKmSFnZB+HgNI1sYGT14BUPZkO6alC/e0AWu+0IAQ= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.2 h1:AaQsr5vvGR7rmeSWBtTCcw16tT9r51mWijuCQhzLnq8= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.2/go.mod h1:o1IiRn7CWocIFTXJjGKJDOwxv1ibL53NpcvcqGWyRBA= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.2 h1:UZx8SXZ0YtzRiALzYAWcjb9Y9hZUR7MBKaBQ5ouOjPs= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.2/go.mod h1:ipuRpcSaklmxR6C39G187TpBAO132gUfleTGccUPs8c= -github.com/aws/aws-sdk-go-v2/internal/ini v1.7.0 h1:usgqiJtamuGIBj+OvYmMq89+Z1hIKkMJToz1WpoeNUY= -github.com/aws/aws-sdk-go-v2/internal/ini v1.7.0/go.mod h1:6fQQgfuGmw8Al/3M2IgIllycxV7ZW7WCdVSqfBeUiCY= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.2 h1:h7j73yuAVVjic8pqswh+L/7r2IHP43QwRyOu6zcCDDE= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.2/go.mod h1:H07AHdK5LSy8F7EJUQhoxyiCNkePoHj2D8P2yGTWafo= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.23.1 h1:xK86ln1cEDa0cUpLaCbFFX/BABPw4ognfzpGfbF4PkY= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.23.1/go.mod h1:eqTdeirkcyBiDviU/N1JMcImS9zEJDn5wOzX3BsU4wU= -github.com/aws/aws-sdk-go-v2/service/sso v1.17.1 h1:km+ZNjtLtpXYf42RdaDZnNHm9s7SYAuDGTafy6nd89A= -github.com/aws/aws-sdk-go-v2/service/sso v1.17.1/go.mod h1:aHBr3pvBSD5MbzOvQtYutyPLLRPbl/y9x86XyJJnUXQ= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.19.1 h1:iRFNqZH4a67IqPvK8xxtyQYnyrlsvwmpHOe9r55ggBA= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.19.1/go.mod h1:pTy5WM+6sNv2tB24JNKFtn6EvciQ5k40ZJ0pq/Iaxj0= -github.com/aws/aws-sdk-go-v2/service/sts v1.25.1 h1:txgVXIXWPXyqdiVn92BV6a/rgtpX31HYdsOYj0sVQQQ= -github.com/aws/aws-sdk-go-v2/service/sts v1.25.1/go.mod h1:VAiJiNaoP1L89STFlEMgmHX1bKixY+FaP+TpRFrmyZ4= -github.com/aws/smithy-go v1.16.0 h1:gJZEH/Fqh+RsvlJ1Zt4tVAtV6bKkp3cC+R6FCZMNzik= -github.com/aws/smithy-go v1.16.0/go.mod h1:NukqUGpCZIILqqiV0NIjeFh24kd/FAa4beRb6nbIUPE= +github.com/aws/aws-sdk-go-v2 v1.23.0 h1:PiHAzmiQQr6JULBUdvR8fKlA+UPKLT/8KbiqpFBWiAo= +github.com/aws/aws-sdk-go-v2 v1.23.0/go.mod h1:i1XDttT4rnf6vxc9AuskLc6s7XBee8rlLilKlc03uAA= +github.com/aws/aws-sdk-go-v2/config v1.25.3 h1:E4m9LbwJOoncDNt3e9MPLbz/saxWcGUlZVBydydD6+8= +github.com/aws/aws-sdk-go-v2/config v1.25.3/go.mod h1:tAByZy03nH5jcq0vZmkcVoo6tRzRHEwSFx3QW4NmDw8= +github.com/aws/aws-sdk-go-v2/credentials v1.16.2 h1:0sdZ5cwfOAipTzZ7eOL0gw4LAhk/RZnTa16cDqIt8tg= +github.com/aws/aws-sdk-go-v2/credentials v1.16.2/go.mod h1:sDdvGhXrSVT5yzBDR7qXz+rhbpiMpUYfF3vJ01QSdrc= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.4 h1:9wKDWEjwSnXZre0/O3+ZwbBl1SmlgWYBbrTV10X/H1s= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.4/go.mod h1:t4i+yGHMCcUNIX1x7YVYa6bH/Do7civ5I6cG/6PMfyA= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.3 h1:DUwbD79T8gyQ23qVXFUthjzVMTviSHi3y4z58KvghhM= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.3/go.mod h1:7sGSz1JCKHWWBHq98m6sMtWQikmYPpxjqOydDemiVoM= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.3 h1:AplLJCtIaUZDCbr6+gLYdsYNxne4iuaboJhVt9d+WXI= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.3/go.mod h1:ify42Rb7nKeDDPkFjKn7q1bPscVPu/+gmHH8d2c+anU= +github.com/aws/aws-sdk-go-v2/internal/ini v1.7.1 h1:uR9lXYjdPX0xY+NhvaJ4dD8rpSRz5VY81ccIIoNG+lw= +github.com/aws/aws-sdk-go-v2/internal/ini v1.7.1/go.mod h1:6fQQgfuGmw8Al/3M2IgIllycxV7ZW7WCdVSqfBeUiCY= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.1 h1:rpkF4n0CyFcrJUG/rNNohoTmhtWlFTRI4BsZOh9PvLs= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.1/go.mod h1:l9ymW25HOqymeU2m1gbUQ3rUIsTwKs8gYHXkqDQUhiI= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.3 h1:kJOolE8xBAD13xTCgOakByZkyP4D/owNmvEiioeUNAg= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.3/go.mod h1:Owv1I59vaghv1Ax8zz8ELY8DN7/Y0rGS+WWAmjgi950= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.23.2 h1:M5NodszNDBfyfFBKoAzJY0flmkkQCg7MGk6+/vBGjCM= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.23.2/go.mod h1:+8dYLQz+I30HIGyhp+6htf3+yyGTqBzzTOG90Ai8lWs= +github.com/aws/aws-sdk-go-v2/service/sso v1.17.2 h1:V47N5eKgVZoRSvx2+RQ0EpAEit/pqOhqeSQFiS4OFEQ= +github.com/aws/aws-sdk-go-v2/service/sso v1.17.2/go.mod h1:/pE21vno3q1h4bbhUOEi+6Zu/aT26UK2WKkDXd+TssQ= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.20.0 h1:/XiEU7VIFcVWRDQLabyrSjBoKIm8UkYgsvWDuFW8Img= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.20.0/go.mod h1:dWqm5G767qwKPuayKfzm4rjzFmVjiBFbOJrpSPnAMDs= +github.com/aws/aws-sdk-go-v2/service/sts v1.25.3 h1:M2w4kiMGJCCM6Ljmmx/l6mmpfa3gPJVpBencfnsgvqs= +github.com/aws/aws-sdk-go-v2/service/sts v1.25.3/go.mod h1:4EqRHDCKP78hq3zOnmFXu5k0j4bXbRFfCh/zQ6KnEfQ= +github.com/aws/smithy-go v1.17.0 h1:wWJD7LX6PBV6etBUwO0zElG0nWN9rUhp0WdYeHSHAaI= +github.com/aws/smithy-go v1.17.0/go.mod h1:NukqUGpCZIILqqiV0NIjeFh24kd/FAa4beRb6nbIUPE= github.com/aymanbagabas/go-osc52 v1.0.3 h1:DTwqENW7X9arYimJrPeGZcV0ln14sGMt3pHZspWD+Mg= github.com/aymanbagabas/go-osc52 v1.0.3/go.mod h1:zT8H+Rk4VSabYN90pWyugflM3ZhpTZNC7cASDfUCdT4= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= @@ -207,8 +209,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.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= -github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.3 h1:qkRjuerhUU1EmXLYGkSH6EZL+vPSxIrYjLNAK4slzwA= +github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
chore
Update dependencies
3e6e26d3b884b766f113b14948fa362a78965c63
2022-09-01 01:51:51
Tom Payne
feat: Add includeTemplate template function
false
diff --git a/assets/chezmoi.io/docs/reference/templates/functions/includeTemplate.md b/assets/chezmoi.io/docs/reference/templates/functions/includeTemplate.md new file mode 100644 index 00000000000..0129a7ac983 --- /dev/null +++ b/assets/chezmoi.io/docs/reference/templates/functions/includeTemplate.md @@ -0,0 +1,5 @@ +# `includeTemplate` *filename* [*data*] + +`includeTemplate` returns the result of executing the contents of *filename* +with the optional *data*. Relative paths are interpreted relative to the source +directory. diff --git a/assets/chezmoi.io/mkdocs.yml b/assets/chezmoi.io/mkdocs.yml index e48a0fe3c14..cdc1ce5f4cb 100644 --- a/assets/chezmoi.io/mkdocs.yml +++ b/assets/chezmoi.io/mkdocs.yml @@ -176,6 +176,7 @@ nav: - fromYaml: reference/templates/functions/fromYaml.md - glob: reference/templates/functions/glob.md - include: reference/templates/functions/include.md + - includeTemplate: reference/templates/functions/includeTemplate.md - ioreg: reference/templates/functions/ioreg.md - joinPath: reference/templates/functions/joinPath.md - lookPath: reference/templates/functions/lookPath.md diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index bfaff8d1dc5..a2fae74b4e5 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -435,6 +435,7 @@ func newConfig(options ...configOption) (*Config, error) { "gopass": c.gopassTemplateFunc, "gopassRaw": c.gopassRawTemplateFunc, "include": c.includeTemplateFunc, + "includeTemplate": c.includeTemplateTemplateFunc, "ioreg": c.ioregTemplateFunc, "joinPath": c.joinPathTemplateFunc, "keepassxc": c.keepassxcTemplateFunc, diff --git a/pkg/cmd/templatefuncs.go b/pkg/cmd/templatefuncs.go index 3b460ccdccd..ccb772a1084 100644 --- a/pkg/cmd/templatefuncs.go +++ b/pkg/cmd/templatefuncs.go @@ -12,6 +12,7 @@ import ( "runtime" "strconv" "strings" + "text/template" "github.com/bmatcuk/doublestar/v4" "github.com/bradenhilton/mozillainstallhash" @@ -87,23 +88,41 @@ func (c *Config) globTemplateFunc(pattern string) []string { } func (c *Config) includeTemplateFunc(filename string) string { - var absPath chezmoi.AbsPath - if filepath.IsAbs(filename) { - var err error - absPath, err = chezmoi.NewAbsPathFromExtPath(filename, c.homeDirAbsPath) - if err != nil { - panic(err) - } - } else { - absPath = c.SourceDirAbsPath.JoinString(filename) - } - contents, err := c.fileSystem.ReadFile(absPath.String()) + contents, err := c.readFile(filename) if err != nil { panic(err) } return string(contents) } +func (c *Config) includeTemplateTemplateFunc(filename string, args ...any) string { + var data any + switch len(args) { + case 0: + // Do nothing. + case 1: + data = args[0] + default: + panic(fmt.Errorf("expected 0 or 1 arguments, got %d", len(args))) + } + + contents, err := c.readFile(filename) + if err != nil { + panic(err) + } + + tmpl, err := template.New(filename).Funcs(c.templateFuncs).Parse(string(contents)) + if err != nil { + panic(err) + } + + var builder strings.Builder + if err := tmpl.Execute(&builder, data); err != nil { + panic(err) + } + return builder.String() +} + func (c *Config) ioregTemplateFunc() map[string]any { if runtime.GOOS != "darwin" { return nil @@ -188,6 +207,20 @@ func (c *Config) quoteListTemplateFunc(list []any) []string { return result } +func (c *Config) readFile(filename string) ([]byte, error) { + var absPath chezmoi.AbsPath + if filepath.IsAbs(filename) { + var err error + absPath, err = chezmoi.NewAbsPathFromExtPath(filename, c.homeDirAbsPath) + if err != nil { + return nil, err + } + } else { + absPath = c.SourceDirAbsPath.JoinString(filename) + } + return c.fileSystem.ReadFile(absPath.String()) +} + func (c *Config) replaceAllRegexTemplateFunc(expr, repl, s string) string { return regexp.MustCompile(expr).ReplaceAllString(s, repl) } diff --git a/pkg/cmd/testdata/scripts/templatefuncs.txtar b/pkg/cmd/testdata/scripts/templatefuncs.txtar index 318c651743b..6af5ff99619 100644 --- a/pkg/cmd/testdata/scripts/templatefuncs.txtar +++ b/pkg/cmd/testdata/scripts/templatefuncs.txtar @@ -24,6 +24,10 @@ cmp stdout golden/include-abspath exec chezmoi execute-template '{{ include ".include" }}' cmp stdout golden/include-relpath +# test includeTemplate template function +exec chezmoi execute-template '{{ includeTemplate ".template" "data" }}' +stdout ^data$ + # test joinPath template function exec chezmoi execute-template '{{ joinPath "a" "b" }}' stdout a${/}b @@ -158,5 +162,7 @@ subkey = "subvalue" # contents of .include -- home/user/.local/share/chezmoi/.include -- # contents of .local/share/chezmoi/.include +-- home/user/.local/share/chezmoi/.template -- +{{ . }} -- home/user/file1.txt -- -- home/user/file2.txt --
feat
Add includeTemplate template function
5b1dbb5f1a3d9752bb4201e64ae6a4ea51754222
2024-10-12 04:47:42
Ruslan Sayfutdinov
docs: Add example for running script on macOS update
false
diff --git a/assets/chezmoi.io/docs/user-guide/machines/macos.md b/assets/chezmoi.io/docs/user-guide/machines/macos.md index 7a39df3c5a6..3e78a85f5e2 100644 --- a/assets/chezmoi.io/docs/user-guide/machines/macos.md +++ b/assets/chezmoi.io/docs/user-guide/machines/macos.md @@ -34,3 +34,12 @@ machine is connected to. For a stable result, use the `scutil` command: ``` {{ $computerName := output "scutil" "--get" "ComputerName" | trim }} ``` + +## Run script after every macOS update + +You can automate a script to run after each macOS update by creating +a `run_onchange_` script and using the `output` template function to run `sw_vers`: + +``` +# MacOS build version: {{ output "sw_vers" "--buildVersion" }} +```
docs
Add example for running script on macOS update
a556b93d19c12b41d46eab1d363131a460290575
2021-12-13 04:00:09
Tom Payne
docs: Make .chezmoi.configFile doc more accurate
false
diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index cdfdda25c33..81bfdb287e5 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -1897,7 +1897,7 @@ chezmoi provides the following automatically-populated variables: | `.chezmoi.arch` | `string` | Architecture, e.g. `amd64`, `arm`, etc. as returned by [runtime.GOARCH](https://pkg.go.dev/runtime?tab=doc#pkg-constants) | | `.chezmoi.args` | `[]string` | The arguments passed to the `chezmoi` command, starting with the program command | | `.chezmoi.cacheDir` | `string` | The cache directory | -| `.chezmoi.configFile` | `string` | The path to the configuration file used by chezmoi, if any | +| `.chezmoi.configFile` | `string` | The path to the configuration file used by chezmoi | | `.chezmoi.executable` | `string` | The path to the `chezmoi` executable, if available | | `.chezmoi.fqdnHostname` | `string` | The fully-qualified domain name hostname of the machine chezmoi is running on | | `.chezmoi.group` | `string` | The group of the user running chezmoi |
docs
Make .chezmoi.configFile doc more accurate
4cabbc2a7ab3e3b69eeeb8ef641de5520db1d053
2022-04-04 00:34:04
Tom Payne
docs: Factor out init template functions into a separate section
false
diff --git a/assets/chezmoi.io/docs/reference/templates/functions/writeToStdout.md b/assets/chezmoi.io/docs/reference/templates/functions/writeToStdout.md deleted file mode 100644 index b3983db0e95..00000000000 --- a/assets/chezmoi.io/docs/reference/templates/functions/writeToStdout.md +++ /dev/null @@ -1,10 +0,0 @@ -# `writeToStdout` *string*... - -`writeToStdout` writes each *string* to stdout. It is only available when -generating the initial config file. - -!!! example - - ``` - {{- writeToStdout "Hello, world\n" -}} - ``` diff --git a/assets/chezmoi.io/docs/reference/templates/functions/exit.md b/assets/chezmoi.io/docs/reference/templates/init-functions/exit.md similarity index 52% rename from assets/chezmoi.io/docs/reference/templates/functions/exit.md rename to assets/chezmoi.io/docs/reference/templates/init-functions/exit.md index 6519f97f773..17fe927a056 100644 --- a/assets/chezmoi.io/docs/reference/templates/functions/exit.md +++ b/assets/chezmoi.io/docs/reference/templates/init-functions/exit.md @@ -1,4 +1,3 @@ # `exit` *code* -`exit` stops template execution and causes chezmoi to exit with *code*. `exit` -is only available when generating the initial config file +`exit` stops template execution and causes chezmoi to exit with *code*. diff --git a/assets/chezmoi.io/docs/reference/templates/init-functions/index.md b/assets/chezmoi.io/docs/reference/templates/init-functions/index.md new file mode 100644 index 00000000000..5c8ff9dd562 --- /dev/null +++ b/assets/chezmoi.io/docs/reference/templates/init-functions/index.md @@ -0,0 +1,5 @@ +# Init functions + +These template functions are only available when generating a config file with +`chezmoi init`. For testing with `chezmoi execute-template`, pass the `--init` +flag to enable them. diff --git a/assets/chezmoi.io/docs/reference/templates/functions/promptBool.md b/assets/chezmoi.io/docs/reference/templates/init-functions/promptBool.md similarity index 68% rename from assets/chezmoi.io/docs/reference/templates/functions/promptBool.md rename to assets/chezmoi.io/docs/reference/templates/init-functions/promptBool.md index 892f3ba97ba..fe0a10a992e 100644 --- a/assets/chezmoi.io/docs/reference/templates/functions/promptBool.md +++ b/assets/chezmoi.io/docs/reference/templates/init-functions/promptBool.md @@ -2,8 +2,8 @@ `promptBool` prompts the user with *prompt* and returns the user's response interpreted as a boolean. If *default* is passed the user's response is empty -then it returns *default*. It is only available when generating the initial -config file. The user's response is interpreted as follows (case insensitive): +then it returns *default*. The user's response is interpreted as follows (case +insensitive): | Response | Result | | ----------------------- | ------- | diff --git a/assets/chezmoi.io/docs/reference/templates/functions/promptInt.md b/assets/chezmoi.io/docs/reference/templates/init-functions/promptInt.md similarity index 66% rename from assets/chezmoi.io/docs/reference/templates/functions/promptInt.md rename to assets/chezmoi.io/docs/reference/templates/init-functions/promptInt.md index ad884dedb6c..cad1e6b9604 100644 --- a/assets/chezmoi.io/docs/reference/templates/functions/promptInt.md +++ b/assets/chezmoi.io/docs/reference/templates/init-functions/promptInt.md @@ -2,5 +2,4 @@ `promptInt` prompts the user with *prompt* and returns the user's response interpreted as an integer. 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. +empty then it returns *default*. diff --git a/assets/chezmoi.io/docs/reference/templates/functions/promptString.md b/assets/chezmoi.io/docs/reference/templates/init-functions/promptString.md similarity index 73% rename from assets/chezmoi.io/docs/reference/templates/functions/promptString.md rename to assets/chezmoi.io/docs/reference/templates/init-functions/promptString.md index 0e346735603..66ceed8d500 100644 --- a/assets/chezmoi.io/docs/reference/templates/functions/promptString.md +++ b/assets/chezmoi.io/docs/reference/templates/init-functions/promptString.md @@ -2,8 +2,7 @@ `promptString` prompts the user with *prompt* and returns the user's response 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. +user's response is empty then it returns *default*. !!! example diff --git a/assets/chezmoi.io/docs/reference/templates/functions/stdinIsATTY.md b/assets/chezmoi.io/docs/reference/templates/init-functions/stdinIsATTY.md similarity index 60% rename from assets/chezmoi.io/docs/reference/templates/functions/stdinIsATTY.md rename to assets/chezmoi.io/docs/reference/templates/init-functions/stdinIsATTY.md index b6f80425bc2..763e6dc27f6 100644 --- a/assets/chezmoi.io/docs/reference/templates/functions/stdinIsATTY.md +++ b/assets/chezmoi.io/docs/reference/templates/init-functions/stdinIsATTY.md @@ -1,9 +1,8 @@ # `stdinIsATTY` -`stdinIsATTY` returns `true` if chezmoi's standard input is a TTY. It is only -available when generating the initial config file. It is primarily useful for -determining whether `prompt*` functions should be called or default values be -used. +`stdinIsATTY` returns `true` if chezmoi's standard input is a TTY. It is +primarily useful for determining whether `prompt*` functions should be called +or default values be used. !!! example diff --git a/assets/chezmoi.io/docs/reference/templates/init-functions/writeToStdout.md b/assets/chezmoi.io/docs/reference/templates/init-functions/writeToStdout.md new file mode 100644 index 00000000000..d16b0d28f45 --- /dev/null +++ b/assets/chezmoi.io/docs/reference/templates/init-functions/writeToStdout.md @@ -0,0 +1,9 @@ +# `writeToStdout` *string*... + +`writeToStdout` writes each *string* to stdout. + +!!! example + + ``` + {{- writeToStdout "Hello, world\n" -}} + ``` diff --git a/assets/chezmoi.io/mkdocs.yml b/assets/chezmoi.io/mkdocs.yml index c4156499281..bb5094f1ce6 100644 --- a/assets/chezmoi.io/mkdocs.yml +++ b/assets/chezmoi.io/mkdocs.yml @@ -153,7 +153,6 @@ nav: - bitwardenFields: reference/templates/functions/bitwardenFields.md - decrypt: reference/templates/functions/decrypt.md - encrypt: reference/templates/functions/encrypt.md - - exit: reference/templates/functions/exit.md - fromYaml: reference/templates/functions/fromYaml.md - gitHubKeys: reference/templates/functions/gitHubKeys.md - gitHubLatestRelease: reference/templates/functions/gitHubLatestRelease.md @@ -178,16 +177,19 @@ nav: - pass: reference/templates/functions/pass.md - passFields: reference/templates/functions/passFields.md - passRaw: reference/templates/functions/passRaw.md - - promptBool: reference/templates/functions/promptBool.md - - promptInt: reference/templates/functions/promptInt.md - - promptString: reference/templates/functions/promptString.md - secret: reference/templates/functions/secret.md - secretJSON: reference/templates/functions/secretJSON.md - stat: reference/templates/functions/stat.md - - stdinIsATTY: reference/templates/functions/stdinIsATTY.md - toYaml: reference/templates/functions/toYaml.md - vault: reference/templates/functions/vault.md - - writeToStdout: reference/templates/functions/writeToStdout.md + - Init Functions: + - reference/templates/init-functions/index.md + - exit: reference/templates/init-functions/exit.md + - promptBool: reference/templates/init-functions/promptBool.md + - promptInt: reference/templates/init-functions/promptInt.md + - promptString: reference/templates/init-functions/promptString.md + - stdinIsATTY: reference/templates/init-functions/stdinIsATTY.md + - writeToStdout: reference/templates/init-functions/writeToStdout.md - Developer: - Developing locally: developer/developing-locally.md - Contributing changes: developer/contributing-changes.md
docs
Factor out init template functions into a separate section
b2378881b6ec7824719bb80ebb8d23f50d7e8040
2025-03-17 05:34:45
Tom Payne
chore: Update Go releaser to v2.8.1
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5c2222e9363..d80ce98f3ba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ env: GOFUMPT_VERSION: 0.7.0 # https://github.com/mvdan/gofumpt/releases GOLANGCI_LINT_VERSION: 1.64.7 # https://github.com/golangci/golangci-lint/releases GOLINES_VERSION: 0.12.2 # https://github.com/segmentio/golines/releases - GORELEASER_VERSION: 2.7.0 # https://github.com/goreleaser/goreleaser/releases + GORELEASER_VERSION: 2.8.1 # https://github.com/goreleaser/goreleaser/releases GOVERSIONINFO_VERSION: 1.4.1 # https://github.com/josephspurrier/goversioninfo/releases PYTHON_VERSION: '3.10' # https://www.python.org/downloads/ RAGE_VERSION: 0.11.1 # https://github.com/str4d/rage/releases diff --git a/.goreleaser.yaml b/.goreleaser.yaml index b3fc29b8983..cfa70e86312 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -85,7 +85,7 @@ builds: goarch: amd64 archives: -- builds: +- ids: - chezmoi-cgo-glibc # Required for chezmoi upgrade for versions <= 2.0.5 - chezmoi-nocgo files: @@ -105,7 +105,7 @@ archives: formats: - zip - id: glibc - builds: + ids: - chezmoi-cgo-glibc files: - LICENSE @@ -113,7 +113,7 @@ archives: - completions/* name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}-glibc_{{ .Arch }}' - id: musl - builds: + ids: - chezmoi-cgo-musl files: - LICENSE @@ -152,7 +152,7 @@ checksum: name_template: chezmoi-windows-amd64.exe nfpms: -- builds: +- ids: - chezmoi-cgo-glibc - chezmoi-nocgo vendor: Tom Payne <[email protected]> @@ -200,7 +200,7 @@ nfpms: - src: completions/chezmoi.zsh dst: /usr/share/zsh/site-functions/_chezmoi - id: apks - builds: + ids: - chezmoi-cgo-musl - chezmoi-nocgo vendor: Tom Payne <[email protected]> @@ -277,7 +277,7 @@ signs: artifacts: checksum snapcrafts: -- builds: +- ids: - chezmoi-cgo-glibc - chezmoi-nocgo summary: Manage your dotfiles across multiple diverse machines, securely.
chore
Update Go releaser to v2.8.1
4fc320350191e7d76cf40d24ce244b0c1c438cd4
2023-08-09 14:03:43
Tom Payne
fix: Fix race condition in concurrent parsing of externals
false
diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go index 21cc440f8e4..53d31a6df38 100644 --- a/internal/chezmoi/sourcestate.go +++ b/internal/chezmoi/sourcestate.go @@ -1280,6 +1280,9 @@ func (s *SourceState) TargetRelPaths() []RelPath { // TemplateData returns a copy of s's template data. func (s *SourceState) TemplateData() map[string]any { + s.Lock() + defer s.Unlock() + if s.templateData == nil { s.templateData = make(map[string]any) if s.defaultTemplateDataFunc != nil {
fix
Fix race condition in concurrent parsing of externals
de05d7026ddedf0dac50e3013a9485e389c9f2ac
2024-12-21 18:46:19
Tom Payne
chore: Require Go 1.23 to build
false
diff --git a/assets/chezmoi.io/docs/developer-guide/index.md b/assets/chezmoi.io/docs/developer-guide/index.md index 4cce1f1e8b3..773f4cdc59f 100644 --- a/assets/chezmoi.io/docs/developer-guide/index.md +++ b/assets/chezmoi.io/docs/developer-guide/index.md @@ -10,7 +10,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.22 or later. +Go tooling. chezmoi requires Go 1.23 or later. Checkout chezmoi: diff --git a/assets/chezmoi.io/docs/developer-guide/website.md b/assets/chezmoi.io/docs/developer-guide/website.md index 4642f1eb1a1..28722f3bc1d 100644 --- a/assets/chezmoi.io/docs/developer-guide/website.md +++ b/assets/chezmoi.io/docs/developer-guide/website.md @@ -6,7 +6,7 @@ contents of the `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). -To build the website locally, Go 1.22 (or later) and +To build the website locally, Go 1.23 (or later) and [uv](https://docs.astral.sh/uv/getting-started/installation/) 0.4.15 (or later) must be installed. Python 3.10 (or later) is required, but may be installed with `uv`: diff --git a/assets/chezmoi.io/docs/install.md.tmpl b/assets/chezmoi.io/docs/install.md.tmpl index f50266f86a1..12d768c436a 100644 --- a/assets/chezmoi.io/docs/install.md.tmpl +++ b/assets/chezmoi.io/docs/install.md.tmpl @@ -256,7 +256,7 @@ pre-built binary and shell completions. ## Install from source -Download, build, and install chezmoi for your system with Go 1.22 or later: +Download, build, and install chezmoi for your system with Go 1.23 or later: ```console $ git clone https://github.com/twpayne/chezmoi.git diff --git a/go.mod b/go.mod index fd97c3cf123..1cb4d2bccc6 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/twpayne/chezmoi/v2 -go 1.22.7 +go 1.23.0 -toolchain go1.23.3 +toolchain go1.23.4 require ( filippo.io/age v1.2.1
chore
Require Go 1.23 to build
938fdfd6c3fc2fba6c82b20d457ee54a6e9b0e9e
2024-11-05 14:09:05
Tom Payne
chore: Cancel in-progress GitHub Actions
false
diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index fb89be2fc1f..8135f615330 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -10,6 +10,9 @@ on: - v* schedule: - cron: 2 2 * * * +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: govulncheck: runs-on: ubuntu-22.04 diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml index 249610aeadf..cb91334cbb6 100644 --- a/.github/workflows/installer.yml +++ b/.github/workflows/installer.yml @@ -6,6 +6,9 @@ on: push: branches: - master +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true env: SHA: ${{ github.event_name == 'push' && github.sha || github.event.pull_request.head.sha }} jobs: diff --git a/.github/workflows/lock-threads.yml b/.github/workflows/lock-threads.yml index dc322db9e60..511131d58d2 100644 --- a/.github/workflows/lock-threads.yml +++ b/.github/workflows/lock-threads.yml @@ -10,7 +10,8 @@ permissions: pull-requests: write concurrency: - group: lock-threads + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: action: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e706577ffef..c62aca558f3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,9 @@ on: - v* schedule: - cron: 32 2 * * * +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true env: ACTIONLINT_VERSION: 1.7.3 # https://github.com/rhysd/actionlint/releases AGE_VERSION: 1.2.0 # https://github.com/FiloSottile/age/releases
chore
Cancel in-progress GitHub Actions
35eb651835ab45e413b0dfdc45c2f336f4119508
2021-10-18 02:07:21
Tom Payne
feat: Add default argument to promptBool template function
false
diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index 2f118b8c69a..832811b9b1e 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -120,7 +120,7 @@ Manage your dotfiles across multiple machines, securely. * [`output` *name* [*arg*...]](#output-name-arg) * [`pass` *pass-name*](#pass-pass-name) * [`passRaw` *pass-name*](#passraw-pass-name) - * [`promptBool` *prompt*](#promptbool-prompt) + * [`promptBool` *prompt* [*default*]](#promptbool-prompt-default) * [`promptInt` *prompt*](#promptint-prompt) * [`promptString` *prompt*](#promptstring-prompt) * [`secret` [*arg*...]](#secret-arg) @@ -2357,10 +2357,11 @@ and the output is returned. The output from `pass` is cached so calling --- -### `promptBool` *prompt* +### `promptBool` *prompt* [*default*] -`promptBool` prompts the user with *prompt* and returns the user's response with -interpreted as a boolean. It is only available when generating the initial +`promptBool` prompts the user with *prompt* and returns the user's response +interpreted as a boolean. If *default* is passed the user's response is empty +then it returns *default*. It is only available when generating the initial config file. The user's response is interpreted as follows (case insensitive): | Response | Result | diff --git a/internal/cmd/executetemplatecmd.go b/internal/cmd/executetemplatecmd.go index 648f97d1f56..1a38eb15de7 100644 --- a/internal/cmd/executetemplatecmd.go +++ b/internal/cmd/executetemplatecmd.go @@ -1,6 +1,7 @@ package cmd import ( + "fmt" "io" "strconv" "strings" @@ -57,8 +58,20 @@ func (c *Config) runExecuteTemplateCmd(cmd *cobra.Command, args []string) error } if c.executeTemplate.init { chezmoi.RecursiveMerge(c.templateFuncs, map[string]interface{}{ - "promptBool": func(prompt string) bool { - return promptBool[prompt] + "promptBool": func(prompt string, args ...bool) bool { + switch len(args) { + case 0: + return promptBool[prompt] + case 1: + if value, ok := promptBool[prompt]; ok { + return value + } + return args[0] + default: + err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1) + returnTemplateError(err) + return false + } }, "promptInt": func(prompt string) int { return c.executeTemplate.promptInt[prompt] diff --git a/internal/cmd/inittemplatefuncs.go b/internal/cmd/inittemplatefuncs.go index 295340dbe50..947095ab905 100644 --- a/internal/cmd/inittemplatefuncs.go +++ b/internal/cmd/inittemplatefuncs.go @@ -9,13 +9,32 @@ import ( "golang.org/x/term" ) -func (c *Config) promptBool(field string) bool { - value, err := parseBool(c.promptString(field)) - if err != nil { +func (c *Config) promptBool(field string, args ...bool) bool { + switch len(args) { + case 0: + value, err := parseBool(c.promptString(field)) + if err != nil { + returnTemplateError(err) + return false + } + return value + case 1: + promptStr := field + " (default " + strconv.FormatBool(args[0]) + ")" + valueStr := c.promptString(promptStr) + if valueStr == "" { + return args[0] + } + value, err := parseBool(valueStr) + if err != nil { + returnTemplateError(err) + return false + } + return value + default: + err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1) returnTemplateError(err) return false } - return value } func (c *Config) promptInt(field string) int64 { diff --git a/internal/cmd/inittemplatefuncs_test.go b/internal/cmd/inittemplatefuncs_test.go new file mode 100644 index 00000000000..e548bb073ff --- /dev/null +++ b/internal/cmd/inittemplatefuncs_test.go @@ -0,0 +1,81 @@ +package cmd + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestPromptBool(t *testing.T) { + for _, tc := range []struct { + name string + prompt string + args []bool + stdinStr string + expectedStdoutStr string + expected bool + expectedErr bool + }{ + { + name: "response_without_default", + prompt: "bool", + stdinStr: "false\n", + expectedStdoutStr: "bool? ", + expected: false, + }, + { + name: "response_with_default", + prompt: "bool", + args: []bool{true}, + stdinStr: "no\n", + expectedStdoutStr: "bool (default true)? ", + expected: false, + }, + { + name: "no_response_with_default", + prompt: "bool", + args: []bool{true}, + stdinStr: "\n", + expectedStdoutStr: "bool (default true)? ", + expected: true, + }, + { + name: "invalid_response", + stdinStr: "invalid\n", + expectedErr: true, + }, + { + name: "invalid_response_with_default", + args: []bool{false}, + stdinStr: "invalid\n", + expectedErr: true, + }, + { + name: "too_many_args", + prompt: "bool", + args: []bool{false, false}, + 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.promptBool(tc.prompt, tc.args...) + }) + } else { + assert.Equal(t, tc.expected, config.promptBool(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 6a674eb509f..178ba579efa 100644 --- a/internal/cmd/testdata/scripts/executetemplate.txt +++ b/internal/cmd/testdata/scripts/executetemplate.txt @@ -46,6 +46,10 @@ stdout true ! chezmoi execute-template --promptBool value=error stderr 'invalid syntax' +# test --init --promptBool with a default value +chezmoi execute-template --init '{{ promptBool "value" true }}' +stdout true + # test --init --promptInt chezmoi execute-template --init --promptInt value=1 '{{ promptInt "value" }}' stdout 1
feat
Add default argument to promptBool template function
d9420346101010baff59b0a16c3ffacc77c29288
2022-02-14 04:35:18
Tom Payne
chore: Fix error when replacing a non-directory with an exact directory
false
diff --git a/pkg/chezmoi/sourcestate.go b/pkg/chezmoi/sourcestate.go index f8d2793dd69..97a2f544142 100644 --- a/pkg/chezmoi/sourcestate.go +++ b/pkg/chezmoi/sourcestate.go @@ -22,6 +22,7 @@ import ( "sort" "strings" "sync" + "syscall" "text/template" "time" @@ -996,6 +997,8 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error { } case errors.Is(err, fs.ErrNotExist): // Do nothing. + case errors.Is(err, syscall.ENOTDIR): + // Do nothing. default: return err } diff --git a/pkg/cmd/main_test.go b/pkg/cmd/main_test.go index 2f3c3571706..a8b861126ab 100644 --- a/pkg/cmd/main_test.go +++ b/pkg/cmd/main_test.go @@ -409,7 +409,7 @@ func cmdMkSourceDir(ts *testscript.TestScript, neg bool, args []string) { "create_dot_create": "# contents of .create\n", "dot_dir": map[string]interface{}{ "file": "# contents of .dir/file\n", - "subdir": map[string]interface{}{ + "exact_subdir": map[string]interface{}{ "file": "# contents of .dir/subdir/file\n", }, }, diff --git a/pkg/cmd/testdata/scripts/add.txt b/pkg/cmd/testdata/scripts/add.txt index deec4ada382..334f4c42072 100644 --- a/pkg/cmd/testdata/scripts/add.txt +++ b/pkg/cmd/testdata/scripts/add.txt @@ -14,8 +14,8 @@ chezmoi add $HOME${/}.dir/file cmp $CHEZMOISOURCEDIR/dot_dir/file golden/dot_dir/file # test adding a subdirectory -chezmoi add $HOME${/}.dir/subdir -cmp $CHEZMOISOURCEDIR/dot_dir/subdir/file golden/dot_dir/subdir/file +chezmoi add --exact $HOME${/}.dir/subdir +cmp $CHEZMOISOURCEDIR/dot_dir/exact_subdir/file golden/dot_dir/exact_subdir/file # test adding an empty file without --empty chezmoi add $HOME${/}.empty diff --git a/pkg/cmd/testdata/scripts/applytype.txt b/pkg/cmd/testdata/scripts/applytype.txt index f9ac8fa5027..b7bad2805af 100644 --- a/pkg/cmd/testdata/scripts/applytype.txt +++ b/pkg/cmd/testdata/scripts/applytype.txt @@ -2,21 +2,28 @@ mkhomedir golden mkhomedir mksourcedir -# test replace directory with file +# test that chezmoi apply replaces a directory with a file rm $HOME/.file mkdir $HOME/.file chezmoi apply --force cmp $HOME/.file golden/.file -# test replace file with directory +# test that chezmoi apply replaces a file with a directory rm $HOME/.dir mkfile $HOME/.dir chezmoi apply --force cmp $HOME/.dir/file golden/.dir/file cmp $HOME/.dir/subdir/file golden/.dir/subdir/file -# test replace file with symlink +# test that chezmoi apply replaces a file with a symlink rm $HOME/.symlink mkfile $HOME/.symlink chezmoi apply --force cmp $HOME/.symlink golden/.symlink + +# test that chezmoi apply replaces a symlink with a directory +rm $HOME/.dir/subdir +symlink $HOME/.dir/subdir -> .file +chezmoi apply --force +cmp $HOME/.dir/file golden/.dir/file +cmp $HOME/.dir/subdir/file golden/.dir/subdir/file diff --git a/pkg/cmd/testdata/scripts/re-add.txt b/pkg/cmd/testdata/scripts/re-add.txt index cff7d127a3b..48d5cb071d8 100644 --- a/pkg/cmd/testdata/scripts/re-add.txt +++ b/pkg/cmd/testdata/scripts/re-add.txt @@ -9,6 +9,6 @@ edit $HOME/.dir/subdir/file chezmoi re-add grep '# edited' $CHEZMOISOURCEDIR/dot_file grep '# edited' $CHEZMOISOURCEDIR/dot_dir/file -grep '# edited' $CHEZMOISOURCEDIR/dot_dir/subdir/file +grep '# edited' $CHEZMOISOURCEDIR/dot_dir/exact_subdir/file chezmoi diff ! stdout .
chore
Fix error when replacing a non-directory with an exact directory
de2f79d7592c4673e9a33b59da982b22af34bbce
2023-08-06 16:48:09
Tom Payne
fix: Avoid concurrent map access when evaluating multiple templates
false
diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go index d2eada8c76d..de514895b5a 100644 --- a/internal/chezmoi/sourcestate.go +++ b/internal/chezmoi/sourcestate.go @@ -27,6 +27,7 @@ import ( "time" "github.com/coreos/go-semver/semver" + "github.com/mitchellh/copystructure" "github.com/rs/zerolog" "github.com/rs/zerolog/log" vfs "github.com/twpayne/go-vfs/v4" @@ -764,11 +765,10 @@ func (s *SourceState) ExecuteTemplateData(options ExecuteTemplateDataOptions) ([ } } - // Temporarily set .chezmoi.sourceFile to the name of the template. + // Set .chezmoi.sourceFile to the name of the template. templateData := s.TemplateData() if chezmoiTemplateData, ok := templateData["chezmoi"].(map[string]any); ok { chezmoiTemplateData["sourceFile"] = options.Name - defer delete(chezmoiTemplateData, "sourceFile") } return tmpl.Execute(templateData) @@ -1278,7 +1278,7 @@ func (s *SourceState) TargetRelPaths() []RelPath { return targetRelPaths } -// TemplateData returns s's template data. +// TemplateData returns a copy of s's template data. func (s *SourceState) TemplateData() map[string]any { if s.templateData == nil { s.templateData = make(map[string]any) @@ -1289,7 +1289,11 @@ func (s *SourceState) TemplateData() map[string]any { RecursiveMerge(s.templateData, s.userTemplateData) RecursiveMerge(s.templateData, s.priorityTemplateData) } - return s.templateData + templateData, err := copystructure.Copy(s.templateData) + if err != nil { + panic(err) + } + return templateData.(map[string]any) //nolint:forcetypeassert } // addExternal adds external source entries to s. @@ -1857,10 +1861,6 @@ func (s *SourceState) newModifyTargetStateEntryFunc( if chezmoiTemplateData, ok := templateData["chezmoi"].(map[string]any); ok { chezmoiTemplateData["stdin"] = string(currentContents) chezmoiTemplateData["sourceFile"] = sourceFile - defer func() { - delete(chezmoiTemplateData, "stdin") - delete(chezmoiTemplateData, "sourceFile") - }() } contents, err = tmpl.Execute(templateData)
fix
Avoid concurrent map access when evaluating multiple templates
62bb0e0e9521e58302ee141042220373e6c40926
2024-11-07 23:06:06
Ruslan Sayfutdinov
chore: Optimize Go caches in Github Actions
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 408194292b1..d5c7b1bdba1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -65,6 +65,14 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: fetch-depth: 1 + - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: setup-go-${{ runner.os }}-x64-ubuntu22-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + setup-go-${{ runner.os }}-x64-ubuntu22-go-${{ env.GO_VERSION }}- - uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd with: languages: go @@ -305,17 +313,15 @@ jobs: runs-on: windows-2022 permissions: contents: read + env: + GOPATH: 'D:\golang\go' + GOCACHE: 'D:\golang\cache' + GOMODCACHE: 'D:\golang\modcache' steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed with: go-version: ${{ env.GO_VERSION }} - - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - name: build run: | go build ./... @@ -387,6 +393,11 @@ jobs: runs-on: ${{ matrix.runs-on }} permissions: contents: read + env: + GOPATH: ${{ startsWith(matrix.runs-on, 'windows') && 'D:\golang\go' || '' }} + GOCACHE: ${{ startsWith(matrix.runs-on, 'windows') && 'D:\golang\cache' || '' }} + GOMODCACHE: ${{ startsWith(matrix.runs-on, 'windows') && 'D:\golang\modcache' || '' }} + USERPROFILE: ${{ startsWith(matrix.runs-on, 'windows') && 'D:\homedir' || '' }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
chore
Optimize Go caches in Github Actions
ad46ae23f3fcc8a18f5fbc58d3cf45eadaca9db2
2023-09-19 00:03:38
Tom Payne
chore: Update dependencies
false
diff --git a/go.mod b/go.mod index a356cff1023..dc21e54d4d1 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/google/renameio/v2 v2.0.0 github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 github.com/itchyny/gojq v0.12.13 - github.com/klauspost/compress v1.16.7 + github.com/klauspost/compress v1.17.0 github.com/mitchellh/copystructure v1.2.0 github.com/mitchellh/mapstructure v1.5.0 github.com/muesli/combinator v0.3.0 diff --git a/go.sum b/go.sum index 902117ba229..1393cb5a8d5 100644 --- a/go.sum +++ b/go.sum @@ -208,8 +208,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.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= -github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= +github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
chore
Update dependencies
cff4329479dc056456fdf7a6c93da794d59c75ce
2025-01-08 18:41:27
Tom Payne
chore: Fix tag in install script help
false
diff --git a/assets/scripts/install-local-bin.sh b/assets/scripts/install-local-bin.sh index dc656a49d63..a1b2f410cf5 100644 --- a/assets/scripts/install-local-bin.sh +++ b/assets/scripts/install-local-bin.sh @@ -23,7 +23,7 @@ ${this}: download chezmoi and optionally run chezmoi Usage: ${this} [-b bindir] [-d] [-t tag] [chezmoi-args] -b sets the installation directory, default is ${BINDIR}. -d enables debug logging. - -t sets the tag, default is ${TAG}. + -t sets the tag, default is ${TAGARG}. If chezmoi-args are given, after install chezmoi is executed with chezmoi-args. EOF exit 2 diff --git a/assets/scripts/install.sh b/assets/scripts/install.sh index 263c712605d..d7c9f7870c7 100644 --- a/assets/scripts/install.sh +++ b/assets/scripts/install.sh @@ -23,7 +23,7 @@ ${this}: download chezmoi and optionally run chezmoi Usage: ${this} [-b bindir] [-d] [-t tag] [chezmoi-args] -b sets the installation directory, default is ${BINDIR}. -d enables debug logging. - -t sets the tag, default is ${TAG}. + -t sets the tag, default is ${TAGARG}. If chezmoi-args are given, after install chezmoi is executed with chezmoi-args. EOF exit 2 diff --git a/internal/cmds/generate-install.sh/install.sh.tmpl b/internal/cmds/generate-install.sh/install.sh.tmpl index e57cdb5c7d5..b8d419f6177 100644 --- a/internal/cmds/generate-install.sh/install.sh.tmpl +++ b/internal/cmds/generate-install.sh/install.sh.tmpl @@ -23,7 +23,7 @@ ${this}: download chezmoi and optionally run chezmoi Usage: ${this} [-b bindir] [-d] [-t tag] [chezmoi-args] -b sets the installation directory, default is ${BINDIR}. -d enables debug logging. - -t sets the tag, default is ${TAG}. + -t sets the tag, default is ${TAGARG}. If chezmoi-args are given, after install chezmoi is executed with chezmoi-args. EOF exit 2
chore
Fix tag in install script help
afb013ccf8a7ad0b6dcdefe409cd495e82ecb61e
2024-10-21 05:40:39
Tom Payne
chore: Fix title of developer guide
false
diff --git a/assets/chezmoi.io/docs/developer-guide/index.md b/assets/chezmoi.io/docs/developer-guide/index.md index b25adca406e..d2660dac557 100644 --- a/assets/chezmoi.io/docs/developer-guide/index.md +++ b/assets/chezmoi.io/docs/developer-guide/index.md @@ -1,4 +1,4 @@ -# Developer +# Developer guide chezmoi is written in [Go](https://golang.org) and development happens on [GitHub](https://github.com). chezmoi is a standard Go project, using standard
chore
Fix title of developer guide
cdac464558896dc4dc558b5ff219e7381d1ee397
2021-12-14 21:41:23
Tom Payne
feat: Add secret keyring delete command
false
diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index 81bfdb287e5..26a48ffc879 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -1680,6 +1680,7 @@ $ chezmoi secret help ```console $ chezmoi secret keyring set --service=service --user=user --value=password $ chezmoi secret keyring get --service=service --user=user +$ chezmoi secret keyring delete --service=service --user=user ``` --- diff --git a/internal/cmd/secretkeyringcmd.go b/internal/cmd/secretkeyringcmd.go index 9d5b5e3ec92..ede95dfda9e 100644 --- a/internal/cmd/secretkeyringcmd.go +++ b/internal/cmd/secretkeyringcmd.go @@ -6,8 +6,14 @@ import ( ) type secretKeyringCmdConfig struct { - get secretKeyringGetCmdConfig - set secretKeyringSetCmdConfig + delete secretKeyringDeleteCmdConfig + get secretKeyringGetCmdConfig + set secretKeyringSetCmdConfig +} + +type secretKeyringDeleteCmdConfig struct { + service string + user string } type secretKeyringGetCmdConfig struct { @@ -28,6 +34,18 @@ func (c *Config) newSecretKeyringCmd() *cobra.Command { Short: "Interact with keyring", } + keyringDeleteCmd := &cobra.Command{ + Use: "delete", + Args: cobra.NoArgs, + Short: "Delete a value from keyring", + RunE: c.runKeyringDeleteCmdE, + } + secretKeyringDeletePersistentFlags := keyringDeleteCmd.PersistentFlags() + secretKeyringDeletePersistentFlags.StringVar(&c.secretKeyring.get.service, "service", "", "service") + secretKeyringDeletePersistentFlags.StringVar(&c.secretKeyring.get.user, "user", "", "user") + markPersistentFlagsRequired(keyringDeleteCmd, "service", "user") + keyringCmd.AddCommand(keyringDeleteCmd) + keyringGetCmd := &cobra.Command{ Use: "get", Args: cobra.NoArgs, @@ -56,6 +74,10 @@ func (c *Config) newSecretKeyringCmd() *cobra.Command { return keyringCmd } +func (c *Config) runKeyringDeleteCmdE(cmd *cobra.Command, args []string) error { + return keyring.Delete(c.secretKeyring.delete.service, c.secretKeyring.delete.user) +} + func (c *Config) runKeyringGetCmdE(cmd *cobra.Command, args []string) error { value, err := keyring.Get(c.secretKeyring.get.service, c.secretKeyring.get.user) if err != nil {
feat
Add secret keyring delete command
f4c150595c0916da16da792f472ebd70a9cf8e66
2022-01-22 00:43:11
Tom Payne
docs: Fix broken links
false
diff --git a/assets/chezmoi.io/docs/index.md b/assets/chezmoi.io/docs/index.md index 40d43537c74..b21ec1af9ae 100644 --- a/assets/chezmoi.io/docs/index.md +++ b/assets/chezmoi.io/docs/index.md @@ -17,8 +17,8 @@ $ chezmoi update ## Getting started [Install chezmoi](/install/) then read the [quick start guide](/quick-start/). -The [user guide](/user-guide/) covers most common tasks. For a full description -of chezmoi, consult the [reference](/reference/). +The [user guide](/user-guide/setup/) covers most common tasks. For a full +description of chezmoi, consult the [reference](/reference/). ## Considering using chezmoi? diff --git a/assets/chezmoi.io/docs/quick-start.md b/assets/chezmoi.io/docs/quick-start.md index 84e6b63b96b..566b9d63cca 100644 --- a/assets/chezmoi.io/docs/quick-start.md +++ b/assets/chezmoi.io/docs/quick-start.md @@ -136,5 +136,5 @@ $ chezmoi help chezmoi has much more functionality. Good starting points are reading [articles about chezmoi](/links/articles-podcasts-and-videos/) adding more dotfiles, and using templates to manage files that vary from machine to machine and retrieve -secrets from your password manager. Read the [user guide](/user-guide/) to -explore. +secrets from your password manager. Read the [user guide](/user-guide/setup/) +to explore.
docs
Fix broken links
9316c5a6853d9f3107654ec6bad85e03b35e6ed7
2022-07-27 00:41:45
Tom Payne
feat: Track source state origins more precisely
false
diff --git a/.golangci.yml b/.golangci.yml index 0dd10a26b89..287572a5ad3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -118,6 +118,7 @@ linters-settings: - github.com/mitchellh/mapstructure\.DecodeHookFunc - github.com/twpayne/chezmoi/v2/pkg/chezmoi\.ActualStateEntry - github.com/twpayne/chezmoi/v2/pkg/chezmoi\.Encryption + - github.com/twpayne/chezmoi/v2/pkg/chezmoi\.SourceStateOrigin - github.com/twpayne/chezmoi/v2/pkg/chezmoi\.SourceStateEntry - github.com/twpayne/chezmoi/v2/pkg/chezmoi\.System - github.com/twpayne/chezmoi/v2/pkg/chezmoi\.TargetStateEntry diff --git a/pkg/chezmoi/actualstateentry.go b/pkg/chezmoi/actualstateentry.go index 4437fb511b2..44e59e345e8 100644 --- a/pkg/chezmoi/actualstateentry.go +++ b/pkg/chezmoi/actualstateentry.go @@ -11,6 +11,7 @@ type ActualStateEntry interface { EntryState() (*EntryState, error) Path() AbsPath Remove(system System) error + OriginString() string } // A ActualStateAbsent represents the absence of an entry in the filesystem. @@ -101,6 +102,11 @@ func (s *ActualStateAbsent) Remove(system System) error { return nil } +// Origin returns s's origin. +func (s *ActualStateAbsent) OriginString() string { + return s.absPath.String() +} + // EntryState returns s's entry state. func (s *ActualStateDir) EntryState() (*EntryState, error) { return &EntryState{ @@ -119,6 +125,11 @@ func (s *ActualStateDir) Remove(system System) error { return system.RemoveAll(s.absPath) } +// Origin returns s's origin. +func (s *ActualStateDir) OriginString() string { + return s.absPath.String() +} + // EntryState returns s's entry state. func (s *ActualStateFile) EntryState() (*EntryState, error) { contents, err := s.Contents() @@ -152,6 +163,11 @@ func (s *ActualStateFile) Remove(system System) error { return system.RemoveAll(s.absPath) } +// Origin returns s's origin. +func (s *ActualStateFile) OriginString() string { + return s.absPath.String() +} + // EntryState returns s's entry state. func (s *ActualStateSymlink) EntryState() (*EntryState, error) { linkname, err := s.Linkname() @@ -178,3 +194,8 @@ func (s *ActualStateSymlink) Path() AbsPath { func (s *ActualStateSymlink) Remove(system System) error { return system.RemoveAll(s.absPath) } + +// Origin returns s's origin. +func (s *ActualStateSymlink) OriginString() string { + return s.absPath.String() +} diff --git a/pkg/chezmoi/sourcestate.go b/pkg/chezmoi/sourcestate.go index b99829b629c..f9cb06b0fef 100644 --- a/pkg/chezmoi/sourcestate.go +++ b/pkg/chezmoi/sourcestate.go @@ -65,7 +65,7 @@ type External struct { RefreshPeriod Duration `json:"refreshPeriod" toml:"refreshPeriod" yaml:"refreshPeriod"` StripComponents int `json:"stripComponents" toml:"stripComponents" yaml:"stripComponents"` URL string `json:"url" toml:"url" yaml:"url"` - origin string + sourceAbsPath AbsPath } // A externalCacheEntry is an external cache entry. @@ -105,7 +105,7 @@ type SourceState struct { templateFuncs template.FuncMap templateOptions []string templates map[string]*template.Template - externals map[RelPath]External + externals map[RelPath]*External ignoredRelPaths map[RelPath]struct{} } @@ -250,7 +250,7 @@ func NewSourceState(options ...SourceStateOption) *SourceState { userTemplateData: make(map[string]interface{}), templateOptions: DefaultTemplateOptions, templates: make(map[string]*template.Template), - externals: make(map[RelPath]External), + externals: make(map[RelPath]*External), ignoredRelPaths: make(map[RelPath]struct{}), } for _, option := range options { @@ -387,7 +387,9 @@ DESTABSPATH: } // Otherwise, remove the old entry. - newSourceStateEntries[oldSourceEntryRelPath] = &SourceStateRemove{} + newSourceStateEntries[oldSourceEntryRelPath] = &SourceStateRemove{ + origin: SourceStateOriginRemove{}, + } update.sourceRelPaths = append(update.sourceRelPaths, oldSourceEntryRelPath) } } @@ -567,8 +569,10 @@ func (s *SourceState) Apply( } } - if !options.Include.IncludeExternals() && sourceStateEntry.External() { - return nil + if !options.Include.IncludeExternals() { + if _, ok := sourceStateEntry.Origin().(*External); ok { + return nil + } } destAbsPath := s.destDirAbsPath.Join(targetRelPath) @@ -914,7 +918,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error { if s.Ignore(targetRelPath) { return vfs.SkipDir } - sourceStateDir := s.newSourceStateDir(sourceRelPath, da) + sourceStateDir := s.newSourceStateDir(sourceAbsPath, sourceRelPath, da) addSourceStateEntries(targetRelPath, sourceStateDir) if sourceStateDir.Attr.Remove { s.Lock() @@ -929,7 +933,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error { return nil } var sourceStateEntry SourceStateEntry - targetRelPath, sourceStateEntry = s.newSourceStateFile(sourceRelPath, fa, targetRelPath) + targetRelPath, sourceStateEntry = s.newSourceStateFile(sourceAbsPath, sourceRelPath, fa, targetRelPath) addSourceStateEntries(targetRelPath, sourceStateEntry) return nil default: @@ -960,7 +964,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error { external := s.externals[externalRelPath] parentRelPath, _ := externalRelPath.Split() var parentSourceRelPath SourceRelPath - switch parentSourceStateEntry, err := s.root.MkdirAll(parentRelPath, external.URL, s.umask); { + switch parentSourceStateEntry, err := s.root.MkdirAll(parentRelPath, external, s.umask); { case err != nil: return err case parentSourceStateEntry != nil: @@ -996,6 +1000,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error { continue } sourceStateEntry := &SourceStateRemove{ + origin: SourceStateOriginRemove{}, sourceRelPath: NewSourceRelPath(".chezmoiremove"), targetRelPath: targetRelPath, } @@ -1031,6 +1036,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error { continue } sourceStateRemove := &SourceStateRemove{ + origin: sourceStateDir.Origin(), sourceRelPath: sourceStateDir.sourceRelPath, targetRelPath: destEntryRelPath, } @@ -1068,8 +1074,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error { cmd.Stderr = os.Stderr sourceStateCommand := &SourceStateCommand{ cmd: cmd, - external: true, - origin: external.origin, + origin: external, forceRefresh: options.RefreshExternals, refreshPeriod: external.RefreshPeriod, } @@ -1087,8 +1092,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error { cmd.Stderr = os.Stderr sourceStateCommand := &SourceStateCommand{ cmd: cmd, - external: true, - origin: external.origin, + origin: external, forceRefresh: options.RefreshExternals, refreshPeriod: external.RefreshPeriod, } @@ -1116,7 +1120,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error { origins := make([]string, 0, len(sourceStateEntries)) for _, sourceStateEntry := range sourceStateEntries { - origins = append(origins, sourceStateEntry.Origin()) + origins = append(origins, sourceStateEntry.Origin().OriginString()) } sort.Strings(origins) err = multierr.Append(err, &inconsistentStateError{ @@ -1191,7 +1195,7 @@ func (s *SourceState) addExternal(sourceAbsPath AbsPath) error { if err != nil { return fmt.Errorf("%s: %w", sourceAbsPath, err) } - externals := make(map[string]External) + externals := make(map[string]*External) if err := format.Unmarshal(data, &externals); err != nil { return fmt.Errorf("%s: %w", sourceAbsPath, err) } @@ -1202,7 +1206,7 @@ func (s *SourceState) addExternal(sourceAbsPath AbsPath) error { if _, ok := s.externals[targetRelPath]; ok { return fmt.Errorf("%s: duplicate externals", targetRelPath) } - external.origin = sourceAbsPath.String() + external.sourceAbsPath = sourceAbsPath s.externals[targetRelPath] = external } return nil @@ -1324,7 +1328,7 @@ func (s *SourceState) executeTemplate(templateAbsPath AbsPath) ([]byte, error) { // getExternalDataRaw returns the raw data for external at externalRelPath, // possibly from the external cache. func (s *SourceState) getExternalDataRaw( - ctx context.Context, externalRelPath RelPath, external External, options *ReadOptions, + ctx context.Context, externalRelPath RelPath, external *External, options *ReadOptions, ) ([]byte, error) { var now time.Time if options != nil && options.TimeNow != nil { @@ -1387,7 +1391,7 @@ func (s *SourceState) getExternalDataRaw( // getExternalDataRaw reads the external data for externalRelPath from // external.URL. func (s *SourceState) getExternalData( - ctx context.Context, externalRelPath RelPath, external External, options *ReadOptions, + ctx context.Context, externalRelPath RelPath, external *External, options *ReadOptions, ) ([]byte, error) { data, err := s.getExternalDataRaw(ctx, externalRelPath, external, options) if err != nil { @@ -1416,12 +1420,12 @@ func (s *SourceState) getExternalData( } // newSourceStateDir returns a new SourceStateDir. -func (s *SourceState) newSourceStateDir(sourceRelPath SourceRelPath, dirAttr DirAttr) *SourceStateDir { +func (s *SourceState) newSourceStateDir(absPath AbsPath, sourceRelPath SourceRelPath, dirAttr DirAttr) *SourceStateDir { targetStateDir := &TargetStateDir{ perm: dirAttr.perm() &^ s.umask, } return &SourceStateDir{ - origin: sourceRelPath.String(), + origin: SourceStateOriginAbsPath(absPath), sourceRelPath: sourceRelPath, Attr: dirAttr, targetStateEntry: targetStateDir, @@ -1639,7 +1643,7 @@ func (s *SourceState) newSymlinkTargetStateEntryFunc( // newSourceStateFile returns a possibly new target RalPath and a new // SourceStateFile. func (s *SourceState) newSourceStateFile( - sourceRelPath SourceRelPath, fileAttr FileAttr, targetRelPath RelPath, + absPath AbsPath, sourceRelPath SourceRelPath, fileAttr FileAttr, targetRelPath RelPath, ) (RelPath, *SourceStateFile) { sourceLazyContents := newLazyContentsFunc(func() ([]byte, error) { contents, err := s.system.ReadFile(s.sourceDirAbsPath.Join(sourceRelPath.RelPath())) @@ -1690,7 +1694,7 @@ func (s *SourceState) newSourceStateFile( return targetRelPath, &SourceStateFile{ lazyContents: sourceLazyContents, - origin: sourceRelPath.String(), + origin: SourceStateOriginAbsPath(absPath), sourceRelPath: sourceRelPath, Attr: fileAttr, targetStateEntryFunc: targetStateEntryFunc, @@ -1701,7 +1705,7 @@ func (s *SourceState) newSourceStateFile( // // We return a SourceStateEntry rather than a *SourceStateDir to simplify nil checks later. func (s *SourceState) newSourceStateDirEntry( - fileInfo fs.FileInfo, parentSourceRelPath SourceRelPath, options *AddOptions, + actualStateDir *ActualStateDir, fileInfo fs.FileInfo, parentSourceRelPath SourceRelPath, options *AddOptions, ) (SourceStateEntry, error) { dirAttr := DirAttr{ TargetName: fileInfo.Name(), @@ -1712,7 +1716,7 @@ func (s *SourceState) newSourceStateDirEntry( sourceRelPath := parentSourceRelPath.Join(NewSourceRelDirPath(dirAttr.SourceName())) return &SourceStateDir{ Attr: dirAttr, - origin: sourceRelPath.String(), + origin: actualStateDir, sourceRelPath: sourceRelPath, targetStateEntry: &TargetStateDir{ perm: 0o777 &^ s.umask, @@ -1765,7 +1769,7 @@ func (s *SourceState) newSourceStateFileEntryFromFile( sourceRelPath := parentSourceRelPath.Join(NewSourceRelPath(fileAttr.SourceName(s.encryption.EncryptedSuffix()))) return &SourceStateFile{ Attr: fileAttr, - origin: sourceRelPath.String(), + origin: actualStateFile, sourceRelPath: sourceRelPath, lazyContents: lazyContents, targetStateEntry: &TargetStateFile{ @@ -1827,7 +1831,7 @@ func (s *SourceState) newSourceStateFileEntryFromSymlink( // readExternal reads an external and returns its SourceStateEntries. func (s *SourceState) readExternal( - ctx context.Context, externalRelPath RelPath, parentSourceRelPath SourceRelPath, external External, + ctx context.Context, externalRelPath RelPath, parentSourceRelPath SourceRelPath, external *External, options *ReadOptions, ) (map[RelPath][]SourceStateEntry, error) { switch external.Type { @@ -1845,7 +1849,7 @@ func (s *SourceState) readExternal( // readExternalArchive reads an external archive and returns its // SourceStateEntries. func (s *SourceState) readExternalArchive( - ctx context.Context, externalRelPath RelPath, parentSourceRelPath SourceRelPath, external External, + ctx context.Context, externalRelPath RelPath, parentSourceRelPath SourceRelPath, external *External, options *ReadOptions, ) (map[RelPath][]SourceStateEntry, error) { data, err := s.getExternalData(ctx, externalRelPath, external, options) @@ -1867,8 +1871,7 @@ func (s *SourceState) readExternalArchive( } sourceStateDir := &SourceStateDir{ Attr: dirAttr, - external: true, - origin: external.URL, + origin: external, sourceRelPath: parentSourceRelPath.Join(NewSourceRelPath(dirAttr.SourceName())), targetStateEntry: &TargetStateDir{ perm: 0o777 &^ s.umask, @@ -1943,8 +1946,7 @@ func (s *SourceState) readExternalArchive( } sourceStateEntry = &SourceStateDir{ Attr: dirAttr, - external: true, - origin: external.URL, + origin: external, sourceRelPath: parentSourceRelPath.Join(dirSourceRelPath, NewSourceRelPath(dirAttr.SourceName())), targetStateEntry: targetStateEntry, } @@ -1971,8 +1973,7 @@ func (s *SourceState) readExternalArchive( sourceStateEntry = &SourceStateFile{ lazyContents: lazyContents, Attr: fileAttr, - external: true, - origin: external.URL, + origin: external, sourceRelPath: parentSourceRelPath.Join(dirSourceRelPath, sourceRelPath), targetStateEntry: targetStateEntry, } @@ -1987,8 +1988,7 @@ func (s *SourceState) readExternalArchive( } sourceStateEntry = &SourceStateFile{ Attr: fileAttr, - external: true, - origin: external.URL, + origin: external, sourceRelPath: parentSourceRelPath.Join(dirSourceRelPath, sourceRelPath), targetStateEntry: targetStateEntry, } @@ -2006,7 +2006,7 @@ func (s *SourceState) readExternalArchive( // readExternalFile reads an external file and returns its SourceStateEntries. func (s *SourceState) readExternalFile( - ctx context.Context, externalRelPath RelPath, parentSourceRelPath SourceRelPath, external External, + ctx context.Context, externalRelPath RelPath, parentSourceRelPath SourceRelPath, external *External, options *ReadOptions, ) (map[RelPath][]SourceStateEntry, error) { lazyContents := newLazyContentsFunc(func() ([]byte, error) { @@ -2022,8 +2022,7 @@ func (s *SourceState) readExternalFile( perm: fileAttr.perm() &^ s.umask, } sourceStateEntry := &SourceStateFile{ - external: true, - origin: external.URL, + origin: external, sourceRelPath: parentSourceRelPath.Join(NewSourceRelPath(fileAttr.SourceName(s.encryption.EncryptedSuffix()))), targetStateEntry: targetStateEntry, } @@ -2093,7 +2092,7 @@ func (s *SourceState) readScriptsDir( return nil } var sourceStateEntry SourceStateEntry - targetRelPath, sourceStateEntry = s.newSourceStateFile(sourceRelPath, fa, targetRelPath) + targetRelPath, sourceStateEntry = s.newSourceStateFile(sourceAbsPath, sourceRelPath, fa, targetRelPath) addSourceStateEntry(targetRelPath, sourceStateEntry) return nil default: @@ -2139,7 +2138,7 @@ func (s *SourceState) sourceStateEntry( case *ActualStateAbsent: return nil, fmt.Errorf("%s: not found", destAbsPath) case *ActualStateDir: - return s.newSourceStateDirEntry(fileInfo, parentSourceRelPath, options) + return s.newSourceStateDirEntry(actualStateEntry, fileInfo, parentSourceRelPath, options) case *ActualStateFile: return s.newSourceStateFileEntryFromFile(actualStateEntry, fileInfo, parentSourceRelPath, options) case *ActualStateSymlink: @@ -2149,6 +2148,14 @@ func (s *SourceState) sourceStateEntry( } } +func (e *External) Path() AbsPath { + return e.sourceAbsPath +} + +func (e *External) OriginString() string { + return e.URL + " defined in " + e.sourceAbsPath.String() +} + // allEquivalentDirs returns if sourceStateEntries are all equivalent // directories. func allEquivalentDirs(sourceStateEntries []SourceStateEntry) bool { diff --git a/pkg/chezmoi/sourcestate_test.go b/pkg/chezmoi/sourcestate_test.go index 12d03ed14dd..ba929ddd05a 100644 --- a/pkg/chezmoi/sourcestate_test.go +++ b/pkg/chezmoi/sourcestate_test.go @@ -858,7 +858,7 @@ func TestSourceStateRead(t *testing.T) { expectedSourceState: NewSourceState( withEntries(map[RelPath]SourceStateEntry{ NewRelPath("dir"): &SourceStateDir{ - origin: "dir", + origin: SourceStateOriginAbsPath(NewAbsPath("/home/user/.local/share/chezmoi/dir")), sourceRelPath: NewSourceRelDirPath("dir"), Attr: DirAttr{ TargetName: "dir", @@ -880,7 +880,7 @@ func TestSourceStateRead(t *testing.T) { expectedSourceState: NewSourceState( withEntries(map[RelPath]SourceStateEntry{ NewRelPath(".file"): &SourceStateFile{ - origin: "dot_file", + origin: SourceStateOriginAbsPath(NewAbsPath("/home/user/.local/share/chezmoi/dot_file")), sourceRelPath: NewSourceRelPath("dot_file"), Attr: FileAttr{ TargetName: ".file", @@ -903,7 +903,7 @@ func TestSourceStateRead(t *testing.T) { "dot_file.tmpl": "# contents of .file\n", }, }, - expectedError: ".file: inconsistent state (dot_file, dot_file.tmpl)", + expectedError: ".file: inconsistent state (/home/user/.local/share/chezmoi/dot_file, /home/user/.local/share/chezmoi/dot_file.tmpl)", }, { name: "duplicate_target_dir", @@ -917,7 +917,7 @@ func TestSourceStateRead(t *testing.T) { }, }, }, - expectedError: "dir: inconsistent state (dir, exact_dir)", + expectedError: "dir: inconsistent state (/home/user/.local/share/chezmoi/dir, /home/user/.local/share/chezmoi/exact_dir)", }, { name: "duplicate_target_script", @@ -927,7 +927,7 @@ func TestSourceStateRead(t *testing.T) { "run_once_script": "#!/bin/sh\n", }, }, - expectedError: "script: inconsistent state (run_once_script, run_script)", + expectedError: "script: inconsistent state (/home/user/.local/share/chezmoi/run_once_script, /home/user/.local/share/chezmoi/run_script)", }, { name: "symlink_with_attr", @@ -940,7 +940,7 @@ func TestSourceStateRead(t *testing.T) { expectedSourceState: NewSourceState( withEntries(map[RelPath]SourceStateEntry{ NewRelPath(".file"): &SourceStateFile{ - origin: "executable_dot_file", + origin: SourceStateOriginAbsPath(NewAbsPath("/home/user/.local/share/chezmoi/executable_dot_file")), sourceRelPath: NewSourceRelPath("executable_dot_file"), Attr: FileAttr{ TargetName: ".file", @@ -967,7 +967,7 @@ func TestSourceStateRead(t *testing.T) { expectedSourceState: NewSourceState( withEntries(map[RelPath]SourceStateEntry{ NewRelPath("script"): &SourceStateFile{ - origin: "run_script", + origin: SourceStateOriginAbsPath(NewAbsPath("/home/user/.local/share/chezmoi/run_script")), sourceRelPath: NewSourceRelPath("run_script"), Attr: FileAttr{ TargetName: "script", @@ -992,7 +992,7 @@ func TestSourceStateRead(t *testing.T) { expectedSourceState: NewSourceState( withEntries(map[RelPath]SourceStateEntry{ NewRelPath("script"): &SourceStateFile{ - origin: "run_script", + origin: SourceStateOriginAbsPath(NewAbsPath("/home/user/.local/share/chezmoi/run_script")), sourceRelPath: NewSourceRelPath("run_script"), Attr: FileAttr{ TargetName: "script", @@ -1017,7 +1017,7 @@ func TestSourceStateRead(t *testing.T) { expectedSourceState: NewSourceState( withEntries(map[RelPath]SourceStateEntry{ NewRelPath(".symlink"): &SourceStateFile{ - origin: "symlink_dot_symlink", + origin: SourceStateOriginAbsPath(NewAbsPath("/home/user/.local/share/chezmoi/symlink_dot_symlink")), sourceRelPath: NewSourceRelPath("symlink_dot_symlink"), Attr: FileAttr{ TargetName: ".symlink", @@ -1043,7 +1043,7 @@ func TestSourceStateRead(t *testing.T) { expectedSourceState: NewSourceState( withEntries(map[RelPath]SourceStateEntry{ NewRelPath("dir"): &SourceStateDir{ - origin: "dir", + origin: SourceStateOriginAbsPath(NewAbsPath("/home/user/.local/share/chezmoi/dir")), sourceRelPath: NewSourceRelDirPath("dir"), Attr: DirAttr{ TargetName: "dir", @@ -1053,7 +1053,7 @@ func TestSourceStateRead(t *testing.T) { }, }, NewRelPath("dir/file"): &SourceStateFile{ - origin: "dir/file", + origin: SourceStateOriginAbsPath(NewAbsPath("/home/user/.local/share/chezmoi/dir/file")), sourceRelPath: NewSourceRelPath("dir/file"), Attr: FileAttr{ TargetName: "file", @@ -1120,7 +1120,7 @@ func TestSourceStateRead(t *testing.T) { expectedSourceState: NewSourceState( withEntries(map[RelPath]SourceStateEntry{ NewRelPath("dir"): &SourceStateDir{ - origin: "exact_dir", + origin: SourceStateOriginAbsPath(NewAbsPath("/home/user/.local/share/chezmoi/exact_dir")), sourceRelPath: NewSourceRelDirPath("exact_dir"), Attr: DirAttr{ TargetName: "dir", @@ -1131,7 +1131,7 @@ func TestSourceStateRead(t *testing.T) { }, }, NewRelPath("dir/file1"): &SourceStateFile{ - origin: "exact_dir/file1", + origin: SourceStateOriginAbsPath(NewAbsPath("/home/user/.local/share/chezmoi/exact_dir/file1")), sourceRelPath: NewSourceRelPath("exact_dir/file1"), Attr: FileAttr{ TargetName: "file1", @@ -1144,6 +1144,7 @@ func TestSourceStateRead(t *testing.T) { }, }, NewRelPath("dir/file2"): &SourceStateRemove{ + origin: SourceStateOriginAbsPath(NewAbsPath("/home/user/.local/share/chezmoi/exact_dir")), sourceRelPath: NewSourceRelDirPath("exact_dir"), targetRelPath: NewRelPath("dir/file2"), }, @@ -1169,6 +1170,7 @@ func TestSourceStateRead(t *testing.T) { expectedSourceState: NewSourceState( withEntries(map[RelPath]SourceStateEntry{ NewRelPath("file"): &SourceStateRemove{ + origin: SourceStateOriginRemove{}, sourceRelPath: NewSourceRelPath(".chezmoiremove"), targetRelPath: NewRelPath("file"), }, @@ -1195,6 +1197,7 @@ func TestSourceStateRead(t *testing.T) { expectedSourceState: NewSourceState( withEntries(map[RelPath]SourceStateEntry{ NewRelPath("file1"): &SourceStateRemove{ + origin: SourceStateOriginRemove{}, sourceRelPath: NewSourceRelPath(".chezmoiremove"), targetRelPath: NewRelPath("file1"), }, @@ -1231,7 +1234,7 @@ func TestSourceStateRead(t *testing.T) { expectedSourceState: NewSourceState( withEntries(map[RelPath]SourceStateEntry{ NewRelPath("dir"): &SourceStateDir{ - origin: "dir", + origin: SourceStateOriginAbsPath(NewAbsPath("/home/user/.local/share/chezmoi/dir")), sourceRelPath: NewSourceRelDirPath("dir"), Attr: DirAttr{ TargetName: "dir", @@ -1241,6 +1244,7 @@ func TestSourceStateRead(t *testing.T) { }, }, NewRelPath("dir/file1"): &SourceStateRemove{ + origin: SourceStateOriginRemove{}, sourceRelPath: NewSourceRelPath(".chezmoiremove"), targetRelPath: NewRelPath("dir/file1"), }, @@ -1365,7 +1369,7 @@ func TestSourceStateReadExternal(t *testing.T) { for _, tc := range []struct { name string root interface{} - expectedExternals map[RelPath]External + expectedExternals map[RelPath]*External }{ { name: "external_yaml", @@ -1378,11 +1382,11 @@ func TestSourceStateReadExternal(t *testing.T) { ), }, }, - expectedExternals: map[RelPath]External{ + expectedExternals: map[RelPath]*External{ NewRelPath("file"): { - Type: "file", - URL: httpServer.URL + "/file", - origin: "/home/user/.local/share/chezmoi/.chezmoiexternal.yaml", + Type: "file", + URL: httpServer.URL + "/file", + sourceAbsPath: NewAbsPath("/home/user/.local/share/chezmoi/.chezmoiexternal.yaml"), }, }, }, @@ -1397,11 +1401,11 @@ func TestSourceStateReadExternal(t *testing.T) { ), }, }, - expectedExternals: map[RelPath]External{ + expectedExternals: map[RelPath]*External{ NewRelPath("file"): { - Type: "file", - URL: httpServer.URL + "/file", - origin: "/home/user/.local/share/chezmoi/.chezmoiexternal.toml", + Type: "file", + URL: httpServer.URL + "/file", + sourceAbsPath: NewAbsPath("/home/user/.local/share/chezmoi/.chezmoiexternal.toml"), }, }, }, @@ -1416,11 +1420,11 @@ func TestSourceStateReadExternal(t *testing.T) { ), }, }, - expectedExternals: map[RelPath]External{ + expectedExternals: map[RelPath]*External{ NewRelPath(".dir/file"): { - Type: "file", - URL: httpServer.URL + "/file", - origin: "/home/user/.local/share/chezmoi/dot_dir/.chezmoiexternal.yaml", + Type: "file", + URL: httpServer.URL + "/file", + sourceAbsPath: NewAbsPath("/home/user/.local/share/chezmoi/dot_dir/.chezmoiexternal.yaml"), }, }, }, @@ -1523,12 +1527,12 @@ func TestSourceStateReadExternalCache(t *testing.T) { WithSystem(system), ) require.NoError(t, s.Read(ctx, readOptions)) - assert.Equal(t, map[RelPath]External{ + assert.Equal(t, map[RelPath]*External{ NewRelPath(".dir"): { Type: "archive", URL: httpServer.URL + "/archive.tar", RefreshPeriod: Duration(1 * time.Minute), - origin: "/home/user/.local/share/chezmoi/.chezmoiexternal.yaml", + sourceAbsPath: NewAbsPath("/home/user/.local/share/chezmoi/.chezmoiexternal.yaml"), }, }, s.externals) } diff --git a/pkg/chezmoi/sourcestateentry.go b/pkg/chezmoi/sourcestateentry.go index 63614bbc514..86572ed41c3 100644 --- a/pkg/chezmoi/sourcestateentry.go +++ b/pkg/chezmoi/sourcestateentry.go @@ -9,13 +9,21 @@ import ( "github.com/twpayne/chezmoi/v2/pkg/chezmoilog" ) +// A SourceStateOrigin represents the origin of a source state. +type SourceStateOrigin interface { + Path() AbsPath + OriginString() string +} + +// A SourceStateOriginAbsPath is an absolute path. +type SourceStateOriginAbsPath AbsPath + // A SourceStateEntry represents the state of an entry in the source state. type SourceStateEntry interface { zerolog.LogObjectMarshaler Evaluate() error - External() bool Order() ScriptOrder - Origin() string + Origin() SourceStateOrigin SourceRelPath() SourceRelPath TargetStateEntry(destSystem System, destDirAbsPath AbsPath) (TargetStateEntry, error) } @@ -23,8 +31,7 @@ type SourceStateEntry interface { // A SourceStateCommand represents a command that should be run. type SourceStateCommand struct { cmd *exec.Cmd - external bool - origin string + origin SourceStateOrigin forceRefresh bool refreshPeriod Duration } @@ -32,8 +39,7 @@ type SourceStateCommand struct { // A SourceStateDir represents the state of a directory in the source state. type SourceStateDir struct { Attr DirAttr - external bool - origin string + origin SourceStateOrigin sourceRelPath SourceRelPath targetStateEntry TargetStateEntry } @@ -42,8 +48,7 @@ type SourceStateDir struct { type SourceStateFile struct { *lazyContents Attr FileAttr - external bool - origin string + origin SourceStateOrigin sourceRelPath SourceRelPath targetStateEntryFunc targetStateEntryFunc targetStateEntry TargetStateEntry @@ -52,25 +57,29 @@ type SourceStateFile struct { // A SourceStateRemove represents that an entry should be removed. type SourceStateRemove struct { + origin SourceStateOrigin sourceRelPath SourceRelPath targetRelPath RelPath } +// A SourceStateOriginRemove is used for removes. The source of the remove is +// not currently tracked. The remove could come from an exact_ directory, a +// non-empty_ file with emoty contents, or one of many patterns in many +// .chezmoiignore files. +// +// FIXME Remove this when the sources of all removes are tracked. +type SourceStateOriginRemove struct{} + // Evaluate evaluates s and returns any error. func (s *SourceStateCommand) Evaluate() error { return nil } -// External returns if s is from an external. -func (s *SourceStateCommand) External() bool { - return s.external -} - // MarshalZerologObject implements // github.com/rs/zerolog.LogObjectMarshaler.MarshalZerologObject. func (s *SourceStateCommand) MarshalZerologObject(e *zerolog.Event) { e.EmbedObject(chezmoilog.OSExecCmdLogObject{Cmd: s.cmd}) - e.Str("origin", s.origin) + e.Str("origin", s.origin.OriginString()) } // Order returns s's order. @@ -79,7 +88,7 @@ func (s *SourceStateCommand) Order() ScriptOrder { } // Origin returns s's origin. -func (s *SourceStateCommand) Origin() string { +func (s *SourceStateCommand) Origin() SourceStateOrigin { return s.origin } @@ -102,11 +111,6 @@ func (s *SourceStateDir) Evaluate() error { return nil } -// External returns if s is from an external. -func (s *SourceStateDir) External() bool { - return s.external -} - // MarshalZerologObject implements // github.com/rs/zerolog.LogObjectMarshaler.MarshalZerologObject. func (s *SourceStateDir) MarshalZerologObject(e *zerolog.Event) { @@ -120,7 +124,7 @@ func (s *SourceStateDir) Order() ScriptOrder { } // Origin returns s's origin. -func (s *SourceStateDir) Origin() string { +func (s *SourceStateDir) Origin() SourceStateOrigin { return s.origin } @@ -140,11 +144,6 @@ func (s *SourceStateFile) Evaluate() error { return err } -// External returns if s is from an external. -func (s *SourceStateFile) External() bool { - return s.external -} - // MarshalZerologObject implements // github.com/rs/zerolog.LogObjectMarshaler.MarshalZerologObject. func (s *SourceStateFile) MarshalZerologObject(e *zerolog.Event) { @@ -169,7 +168,7 @@ func (s *SourceStateFile) Order() ScriptOrder { } // Origin returns s's origin. -func (s *SourceStateFile) Origin() string { +func (s *SourceStateFile) Origin() SourceStateOrigin { return s.origin } @@ -192,11 +191,6 @@ func (s *SourceStateRemove) Evaluate() error { return nil } -// External returns if s is from an external. -func (s *SourceStateRemove) External() bool { - return false -} - // MarshalZerologObject implements zerolog.LogObjectMarshaler. func (s *SourceStateRemove) MarshalZerologObject(e *zerolog.Event) { e.Stringer("targetRelPath", s.targetRelPath) @@ -208,8 +202,8 @@ func (s *SourceStateRemove) Order() ScriptOrder { } // Origin returns s's origin. -func (s *SourceStateRemove) Origin() string { - return s.sourceRelPath.String() +func (s *SourceStateRemove) Origin() SourceStateOrigin { + return s.origin } // SourceRelPath returns s's source relative path. @@ -221,3 +215,23 @@ func (s *SourceStateRemove) SourceRelPath() SourceRelPath { func (s *SourceStateRemove) TargetStateEntry(destSystem System, destDirAbsPath AbsPath) (TargetStateEntry, error) { return &TargetStateRemove{}, nil } + +// Path returns s's path. +func (s SourceStateOriginAbsPath) Path() AbsPath { + return AbsPath(s) +} + +// Origin returns s's origin. +func (s SourceStateOriginAbsPath) OriginString() string { + return AbsPath(s).String() +} + +// Path returns s's path. +func (s SourceStateOriginRemove) Path() AbsPath { + return EmptyAbsPath +} + +// Origin returns s's origin. +func (s SourceStateOriginRemove) OriginString() string { + return "remove" +} diff --git a/pkg/chezmoi/sourcestatetreenode.go b/pkg/chezmoi/sourcestatetreenode.go index 821e6a5db6c..ff8fae36574 100644 --- a/pkg/chezmoi/sourcestatetreenode.go +++ b/pkg/chezmoi/sourcestatetreenode.go @@ -94,7 +94,7 @@ func (n *sourceStateEntryTreeNode) Map() map[RelPath]SourceStateEntry { // MkdirAll creates SourceStateDirs for all components of targetRelPath if they // do not already exist and returns the SourceStateDir of relPath. func (n *sourceStateEntryTreeNode) MkdirAll( - targetRelPath RelPath, origin string, umask fs.FileMode, + targetRelPath RelPath, origin SourceStateOrigin, umask fs.FileMode, ) (*SourceStateDir, error) { if targetRelPath == EmptyRelPath { return nil, nil diff --git a/pkg/cmd/forgetcmd.go b/pkg/cmd/forgetcmd.go index d514b072313..71ede348282 100644 --- a/pkg/cmd/forgetcmd.go +++ b/pkg/cmd/forgetcmd.go @@ -35,16 +35,26 @@ func (c *Config) runForgetCmd(cmd *cobra.Command, args []string, sourceState *ch return err } +TARGETRELPATH: for _, targetRelPath := range targetRelPaths { - // Filter out source state entries with an empty source relative path. - // These are generated by externals, which we cannot handle. - relPath := sourceState.MustEntry(targetRelPath).SourceRelPath().RelPath() - if relPath.Empty() { - c.errorf("warning: %s: cannot forget entry, is it an external?", targetRelPath) - continue + sourceStateEntry := sourceState.MustEntry(targetRelPath) + + // Skip source state entries that are not regular entries. These are + // removes or externals, which we cannot handle. + switch sourceStateOrigin := sourceStateEntry.Origin(); sourceStateOrigin.(type) { + case chezmoi.SourceStateOriginAbsPath: + // OK, keep going. + case chezmoi.SourceStateOriginRemove: + c.errorf("warning: %s: cannot forget entry from remove\n", targetRelPath) + continue TARGETRELPATH + case *chezmoi.External: + c.errorf("warning: %s: cannot forget entry from external %s\n", targetRelPath, sourceStateOrigin.OriginString()) + continue TARGETRELPATH + default: + panic(fmt.Sprintf("%s: %T: unknown source state origin type", targetRelPath, sourceStateOrigin)) } - sourceAbsPath := c.SourceDirAbsPath.Join(relPath) + sourceAbsPath := c.SourceDirAbsPath.Join(sourceStateEntry.SourceRelPath().RelPath()) if !c.force { choice, err := c.promptChoice(fmt.Sprintf("Remove %s", sourceAbsPath), choicesYesNoAllQuit) if err != nil { diff --git a/pkg/cmd/testdata/scripts/edgecases.txt b/pkg/cmd/testdata/scripts/edgecases.txt index 7c4370b957e..3c424485b99 100644 --- a/pkg/cmd/testdata/scripts/edgecases.txt +++ b/pkg/cmd/testdata/scripts/edgecases.txt @@ -39,7 +39,7 @@ chhome home3/user # test that chezmoi reports an inconsistent state error when a file should be both removed and present ! chezmoi apply -stderr 'chezmoi: \.file: inconsistent state \(\.chezmoiremove, dot_file\)' +stderr 'chezmoi: \.file: inconsistent state' chhome home4/user @@ -52,7 +52,7 @@ chhome home5/user # test that chezmoi reports an inconsistent state error when a file should be both removed and present, even if the file is not already present ! chezmoi apply -stderr 'chezmoi: \.file: inconsistent state \(\.chezmoiremove, dot_file\)' +stderr 'chezmoi: \.file: inconsistent state -- golden/.file -- # contents of .file diff --git a/pkg/cmd/testdata/scripts/issue2177.txt b/pkg/cmd/testdata/scripts/issue2177.txt index bdc2eb04f57..9c0084bc139 100644 --- a/pkg/cmd/testdata/scripts/issue2177.txt +++ b/pkg/cmd/testdata/scripts/issue2177.txt @@ -1,6 +1,6 @@ # test that chezmoi forget prints a warning when asked to forget externals chezmoi forget $HOME${/}.external -stderr 'cannot forget entry' +stderr 'cannot forget entry from external https://github\.com/user/repo\.git defined in .*/home/user/\.local/share/chezmoi/\.chezmoiexternal\.toml' -- home/user/.local/share/chezmoi/.chezmoiexternal.toml -- [".external"]
feat
Track source state origins more precisely
57499748648c7860eeb2094c4db36f6024ed3536
2024-03-31 01:13:34
Tom Payne
chore: Skip tests that require a net connection when offline
false
diff --git a/internal/cmd/main_test.go b/internal/cmd/main_test.go index 4826f49f23f..3f5bef893b9 100644 --- a/internal/cmd/main_test.go +++ b/internal/cmd/main_test.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io/fs" + "net" "net/http" "net/http/httptest" "os" @@ -31,6 +32,7 @@ import ( var ( envConditionRx = regexp.MustCompile(`\Aenv:(\w+)\z`) envVarRx = regexp.MustCompile(`\$\w+`) + lookupRx = regexp.MustCompile(`\Alookup:(.*)\z`) umaskConditionRx = regexp.MustCompile(`\Aumask:([0-7]{3})\z`) ) @@ -79,6 +81,10 @@ func TestScript(t *testing.T) { if m := envConditionRx.FindStringSubmatch(cond); m != nil { return os.Getenv(m[1]) != "", nil } + if m := lookupRx.FindStringSubmatch(cond); m != nil { + _, err := net.LookupIP(m[1]) + return err == nil, nil + } if m := umaskConditionRx.FindStringSubmatch(cond); m != nil { umask, _ := strconv.ParseInt(m[1], 8, 64) return chezmoitest.Umask == fs.FileMode(umask), nil diff --git a/internal/cmd/testdata/scripts/issue2649.txtar b/internal/cmd/testdata/scripts/issue2649.txtar index 2f7b5b0c675..1c077fa1d97 100644 --- a/internal/cmd/testdata/scripts/issue2649.txtar +++ b/internal/cmd/testdata/scripts/issue2649.txtar @@ -1,3 +1,5 @@ +[!lookup:github.com] skip 'github.com not found' + # test that chezmoi init clones a public dotfiles repo if git is installed [exec:git] exec chezmoi init --use-builtin-git=false chezmoi [exec:git] exists ${CHEZMOISOURCEDIR}/README.md
chore
Skip tests that require a net connection when offline
cd4e9780030f1af9db0e5244ef1ab27191fe1185
2025-01-08 02:53:43
Tom Payne
chore: Minor test clean-ups
false
diff --git a/internal/cmd/keepassxctemplatefuncs_test.go b/internal/cmd/keepassxctemplatefuncs_test.go index 1c9f10f154f..cc5717912f9 100644 --- a/internal/cmd/keepassxctemplatefuncs_test.go +++ b/internal/cmd/keepassxctemplatefuncs_test.go @@ -54,6 +54,17 @@ func TestKeepassxcParseOutput(t *testing.T) { } } +type keepassEntry struct { + database string + databasePassword string + groupName string + entryName string + entryUsername string + entryPassword string + attachmentName string + attachmentData string +} + func TestKeepassxcTemplateFuncs(t *testing.T) { // Find the path to keepassxc-cli command. command, err := exec.LookPath("keepassxc-cli") @@ -91,41 +102,31 @@ func TestKeepassxcTemplateFuncs(t *testing.T) { dbCreateCmd.Stderr = os.Stderr assert.NoError(t, dbCreateCmd.Run()) - setupKeepassEntry( - t, - command, - tempDir, - keepassEntry{ - database, - databasePassword, - groupName, - entryName, - entryUsername, - entryPassword, - attachmentName, - attachmentData, - }, - ) - setupKeepassEntry( - t, - command, - tempDir, - keepassEntry{ - database, - databasePassword, - nestedGroupName, - nestedEntryName, - nestedEntryUsername, - nestedEntryPassword, - nestedAttachmentName, - nestedAttachmentData, - }, - ) + createKeepassEntry(t, command, tempDir, keepassEntry{ + database: database, + databasePassword: databasePassword, + groupName: groupName, + entryName: entryName, + entryUsername: entryUsername, + entryPassword: entryPassword, + attachmentName: attachmentName, + attachmentData: attachmentData, + }) + createKeepassEntry(t, command, tempDir, keepassEntry{ + database: database, + databasePassword: databasePassword, + groupName: nestedGroupName, + entryName: nestedEntryName, + entryUsername: nestedEntryUsername, + entryPassword: nestedEntryPassword, + attachmentName: nestedAttachmentName, + attachmentData: nestedAttachmentData, + }) for _, mode := range []keepassxcMode{ + keepassxcModeBuiltin, keepassxcModeCachePassword, keepassxcModeOpen, - keepassxcModeBuiltin, } { t.Run(string(mode), func(t *testing.T) { t.Run("correct_password", func(t *testing.T) { @@ -187,21 +188,14 @@ func TestKeepassxcTemplateFuncs(t *testing.T) { } } -func setupKeepassEntry(t *testing.T, command, tempDir string, kpe keepassEntry) { +func createKeepassEntry(t *testing.T, command, tempDir string, kpe keepassEntry) { t.Helper() // Create nested groups in the database. groupPath := strings.Split(kpe.groupName, "/") for i := range groupPath { - var name string - if i == 0 { - name = groupPath[i] - } else { - name = strings.Join(groupPath[0:i+1], "/") - } + name := strings.Join(groupPath[0:i+1], "/") mkdirCmd := exec.Command(command, "mkdir", kpe.database, name) - mkdirCmd.Stdin = strings.NewReader(chezmoitest.JoinLines( - kpe.databasePassword, - )) + mkdirCmd.Stdin = strings.NewReader(kpe.databasePassword + "\n") mkdirCmd.Stdout = os.Stdout mkdirCmd.Stderr = os.Stderr assert.NoError(t, mkdirCmd.Run()) @@ -227,21 +221,8 @@ func setupKeepassEntry(t *testing.T, command, tempDir string, kpe keepassEntry) kpe.attachmentName, importFile, ) - attachmentImportCmd.Stdin = strings.NewReader(chezmoitest.JoinLines( - kpe.databasePassword, - )) + attachmentImportCmd.Stdin = strings.NewReader(kpe.databasePassword + "\n") attachmentImportCmd.Stdout = os.Stdout attachmentImportCmd.Stderr = os.Stderr assert.NoError(t, attachmentImportCmd.Run()) } - -type keepassEntry struct { - database string - databasePassword string - groupName string - entryName string - entryUsername string - entryPassword string - attachmentName string - attachmentData string -}
chore
Minor test clean-ups
2461322798e1f1bf0cd5f8418ee0f687597ac5f9
2025-01-25 09:18:44
Tom Payne
chore: Update GitHub Actions
false
diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index d9f89bd21d7..5aa5db8ba9b 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -48,7 +48,7 @@ runs: key: ${{ inputs.cache-prefix }}-${{ runner.os }}-${{ runner.arch }}-go-${{ inputs.go-version }}-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ inputs.cache-prefix }}-${{ runner.os }}-${{ runner.arch }}-go-${{ inputs.go-version }}- - - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a + - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 with: cache: false go-version: ${{ inputs.go-version }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0f177e71c19..24bf64d19f5 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@3407610120cd5656b6fc71991415cb50748b9489 + - uses: github/codeql-action/init@7e3036b9cd87fc26dd06747b7aa4b96c27aaef3a with: languages: go - - uses: github/codeql-action/analyze@3407610120cd5656b6fc71991415cb50748b9489 + - uses: github/codeql-action/analyze@7e3036b9cd87fc26dd06747b7aa4b96c27aaef3a misspell: runs-on: ubuntu-22.04 permissions: @@ -183,7 +183,7 @@ jobs: contents: read steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a + - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 with: go-version: oldstable - name: build @@ -435,7 +435,7 @@ jobs: go run ./internal/cmds/lint-commit-messages ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }}..${{ github.event.pull_request.head.sha }} - name: lint-markdown if: false # FIXME - uses: DavidAnson/markdownlint-cli2-action@a23dae216ce3fee4db69da41fed90d2a4af801cf + uses: DavidAnson/markdownlint-cli2-action@05f32210e84442804257b2a6f20b273450ec8265 lint: name: lint-${{ matrix.runs-on }} strategy: @@ -456,7 +456,7 @@ jobs: with: go-version: ${{ env.GO_VERSION }} upload-cache: false - - uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 + - uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae with: version: v${{ env.GOLANGCI_LINT_VERSION }} args: --timeout=5m
chore
Update GitHub Actions
153ff43aca7653a0b00a2f41883e3b988f43109b
2024-04-23 23:13:59
Tom Payne
fix: Better detect username on Android/Termux systems
false
diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 22e77fd7efa..ff716194842 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -2222,23 +2222,28 @@ func (c *Config) progressAutoFunc() bool { func (c *Config) newTemplateData(cmd *cobra.Command) *templateData { // Determine the user's username and group, if possible. // - // user.Current and user.LookupGroupId in Go's standard library are + // os/user.Current and os/user.LookupGroupId in Go's standard library are // generally unreliable, so work around errors if possible, or ignore them. // + // On Android, user.Current always fails. Instead, use $LOGNAME (as this is + // set by Termux), or $USER if $LOGNAME is not set. + // // If CGO is disabled, then the Go standard library falls back to parsing // /etc/passwd and /etc/group, which will return incorrect results without // error if the system uses an alternative password database such as NIS or // LDAP. // - // If CGO is enabled then user.Current and user.LookupGroupId will use the - // underlying libc functions, namely getpwuid_r and getgrnam_r. If linked - // with glibc this will return the correct result. If linked with musl then - // they will use musl's implementation which, like Go's non-CGO + // If CGO is enabled then os/user.Current and os/user.LookupGroupId will use + // the underlying libc functions, namely getpwuid_r and getgrnam_r. If + // linked with glibc this will return the correct result. If linked with + // musl then they will use musl's implementation which, like Go's non-CGO // implementation, also only parses /etc/passwd and /etc/group and so also // returns incorrect results without error if NIS or LDAP are being used. // - // On Windows, the user's group ID returned by user.Current() is an SID and - // no further useful lookup is possible with Go's standard library. + // On Windows, the user's group ID returned by os/user.Current() is an SID + // and no further useful lookup is possible with Go's standard library. + // + // If os/user.Current fails, then fallback to $USER. // // Since neither the username nor the group are likely widely used in // templates, leave these variables unset if their values cannot be @@ -2246,7 +2251,9 @@ func (c *Config) newTemplateData(cmd *cobra.Command) *templateData { // alerting the user to the problem and allowing them to find alternative // solutions. var gid, group, uid, username string - if currentUser, err := user.Current(); err == nil { + if runtime.GOOS == "android" { + username = firstNonEmptyString(os.Getenv("LOGNAME"), os.Getenv("USER")) + } else if currentUser, err := user.Current(); err == nil { gid = currentUser.Gid uid = currentUser.Uid username = currentUser.Username
fix
Better detect username on Android/Termux systems
440f56c001879a3f33b6e7e28ab76561e727200b
2024-11-17 19:01:51
Tom Payne
chore: Update GitHub Actions
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f7dd38fa298..1d0026e0aab 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -329,7 +329,7 @@ jobs: with: cache-prefix: website-go go-version: ${{ env.GO_VERSION }} - - uses: astral-sh/setup-uv@2e657c127d5b1635d5a8e3fa40e0ac50a5bf6992 + - uses: astral-sh/setup-uv@e779db74266a80753577425b0f4ee823649f251d with: enable-cache: true version: ${{ env.UV_VERSION }} @@ -510,7 +510,7 @@ jobs: with: cache-prefix: website-go go-version: ${{ env.GO_VERSION }} - - uses: astral-sh/setup-uv@2e657c127d5b1635d5a8e3fa40e0ac50a5bf6992 + - uses: astral-sh/setup-uv@e779db74266a80753577425b0f4ee823649f251d with: enable-cache: true version: ${{ env.UV_VERSION }}
chore
Update GitHub Actions
084add0ad8827b45b56064bc04aefb0abcbe003e
2023-12-25 20:06:24
Tom Payne
fix: Handle implicit directories in externals
false
diff --git a/internal/chezmoi/entrytypeset.go b/internal/chezmoi/entrytypeset.go index 03598491caf..03131336bf7 100644 --- a/internal/chezmoi/entrytypeset.go +++ b/internal/chezmoi/entrytypeset.go @@ -134,7 +134,7 @@ func (s *EntryTypeSet) ContainsSourceStateEntry(sourceStateEntry SourceStateEntr default: return false } - case *SourceStateDir: + case *SourceStateDir, *SourceStateImplicitDir: switch { case s.bits&EntryTypeExternals != 0 && isExternal: return true diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go index c02e4d0883a..63dd35878dd 100644 --- a/internal/chezmoi/sourcestate.go +++ b/internal/chezmoi/sourcestate.go @@ -2224,6 +2224,25 @@ func (s *SourceState) newSourceStateFileEntryFromSymlink( }, nil } +// populateImplicitDirs creates implicit parent directories for externalRelPath. +func (s *SourceState) populateImplicitParentDirs( + externalRelPath RelPath, + external *External, + sourceStateEntries map[RelPath][]SourceStateEntry, +) map[RelPath][]SourceStateEntry { + for relPath := externalRelPath.Dir(); relPath != DotRelPath; relPath = relPath.Dir() { + sourceStateEntries[relPath] = append(sourceStateEntries[relPath], + &SourceStateImplicitDir{ + origin: external, + targetStateEntry: &TargetStateDir{ + perm: fs.ModePerm &^ s.umask, + }, + }, + ) + } + return sourceStateEntries +} + // readExternal reads an external and returns its SourceStateEntries. func (s *SourceState) readExternal( ctx context.Context, @@ -2414,7 +2433,7 @@ func (s *SourceState) readExternalArchive( return nil, fmt.Errorf("%s: %s: %w", externalRelPath, external.URL, err) } - return sourceStateEntries, nil + return s.populateImplicitParentDirs(externalRelPath, external, sourceStateEntries), nil } // readExternalArchiveData reads an external archive's data and returns its data @@ -2554,9 +2573,9 @@ func (s *SourceState) readExternalArchiveFile( return nil, fmt.Errorf("%s: path not found in %s", external.ArchivePath, external.URL) } - return map[RelPath][]SourceStateEntry{ + return s.populateImplicitParentDirs(externalRelPath, external, map[RelPath][]SourceStateEntry{ externalRelPath: {sourceStateEntry}, - }, nil + }), nil } // ReadExternalDir returns all source state entries in an external_ dir. @@ -2685,9 +2704,9 @@ func (s *SourceState) readExternalFile( ), targetStateEntry: targetStateEntry, } - return map[RelPath][]SourceStateEntry{ + return s.populateImplicitParentDirs(externalRelPath, external, map[RelPath][]SourceStateEntry{ externalRelPath: {sourceStateEntry}, - }, nil + }), nil } // readScriptsDir reads all scripts in scriptsDirAbsPath. @@ -2829,19 +2848,39 @@ func (e *External) OriginString() string { // allEquivalentDirs returns if sourceStateEntries are all equivalent // directories. func allEquivalentDirs(sourceStateEntries []SourceStateEntry) bool { - sourceStateDir0, ok := sourceStateEntries[0].(*SourceStateDir) - if !ok { - return false - } - for _, sourceStateEntry := range sourceStateEntries[1:] { - sourceStateDir, ok := sourceStateEntry.(*SourceStateDir) - if !ok { + // Find all directories to check for equivalence. + var firstSourceStateDir *SourceStateDir + sourceStateDirs := make([]SourceStateEntry, 0, len(sourceStateEntries)) + for _, sourceStateEntry := range sourceStateEntries { + switch sourceStateEntry := sourceStateEntry.(type) { + case *SourceStateDir: + firstSourceStateDir = sourceStateEntry + sourceStateDirs = append(sourceStateDirs, sourceStateEntry) + case *SourceStateImplicitDir: + sourceStateDirs = append(sourceStateDirs, sourceStateEntry) + default: return false } - if sourceStateDir0.Attr != sourceStateDir.Attr { - return false + } + + // If there are no SourceStateDirs then there are no equivalent directories. + if len(sourceStateDirs) == 0 { + return false + } + + // Check for equivalence. + for _, sourceStateDir := range sourceStateDirs { + switch sourceStateDir := sourceStateDir.(type) { + case *SourceStateDir: + if sourceStateDir.Attr != firstSourceStateDir.Attr { + return false + } + case *SourceStateImplicitDir: + // SourceStateImplicitDirs are considered equivalent to all other + // directories. } } + return true } diff --git a/internal/chezmoi/sourcestateentry.go b/internal/chezmoi/sourcestateentry.go index 038d244d986..775dc33dec1 100644 --- a/internal/chezmoi/sourcestateentry.go +++ b/internal/chezmoi/sourcestateentry.go @@ -64,6 +64,15 @@ type SourceStateFile struct { targetStateEntryErr error } +// A SourceStateImplicitDir represents the state of a directory that is implicit +// in the source state, typically because it is a parent directory of an +// external. Implicit directories have no attributes and are considered +// equivalent to any other directory. +type SourceStateImplicitDir struct { + origin SourceStateOrigin + targetStateEntry TargetStateEntry +} + // A SourceStateRemove represents that an entry should be removed. type SourceStateRemove struct { origin SourceStateOrigin @@ -208,6 +217,39 @@ func (s *SourceStateFile) TargetStateEntry( return s.targetStateEntry, s.targetStateEntryErr } +// Evaluate evaluates s and returns any error. +func (s *SourceStateImplicitDir) Evaluate() error { + return nil +} + +// MarshalZerologObject implements +// github.com/rs/zerolog.LogObjectMarshaler.MarshalZerologObject. +func (s *SourceStateImplicitDir) MarshalZerologObject(e *zerolog.Event) { +} + +// Order returns s's order. +func (s *SourceStateImplicitDir) Order() ScriptOrder { + return ScriptOrderDuring +} + +// Origin returns s's origin. +func (s *SourceStateImplicitDir) Origin() SourceStateOrigin { + return s.origin +} + +// SourceRelPath returns s's source relative path. +func (s *SourceStateImplicitDir) SourceRelPath() SourceRelPath { + return emptySourceRelPath +} + +// TargetStateEntry returns s's target state entry. +func (s *SourceStateImplicitDir) TargetStateEntry( + destSystem System, + destDirAbsPath AbsPath, +) (TargetStateEntry, error) { + return s.targetStateEntry, nil +} + // Evaluate evaluates s and returns any error. func (s *SourceStateRemove) Evaluate() error { return nil diff --git a/internal/cmd/testdata/scripts/issue3414.txtar b/internal/cmd/testdata/scripts/issue3414.txtar new file mode 100644 index 00000000000..19ec526cfda --- /dev/null +++ b/internal/cmd/testdata/scripts/issue3414.txtar @@ -0,0 +1,26 @@ +exec tar czf www/archive.tar.gz archive + +httpd www + +# test that running chezmoi apply twice does not complain about modified files +exec chezmoi apply +exec chezmoi apply --no-tty + +-- archive/shell/completion.bash -- +# contents of shell/completion.bash +-- archive/shell/key-bindings.bash -- +# contents of shell/key-bindings.bash +-- home/user/.local/share/chezmoi/.chezmoiexternal.toml -- +[".bashrc.d/additional/fzf/shell/completion.bash"] + type = "archive-file" + path = "shell/completion.bash" + url = "{{ env "HTTPD_URL" }}/archive.tar.gz" + stripComponents = 1 +[".bashrc.d/additional/fzf/shell/key-bindings.bash"] + type = "archive-file" + path = "shell/key-bindings.bash" + url = "{{ env "HTTPD_URL" }}/archive.tar.gz" + stripComponents = 1 +-- home/user/.local/share/chezmoi/exact_dot_bashrc.d/file.sh -- +# contents of .bashrc.d/file.sh +-- www/.keep --
fix
Handle implicit directories in externals
3bf750c9113ca4a90a9eac2115f9ac1add684544
2021-10-30 01:53:46
Tom Payne
chore: Ensure full CI is run on pushes to master or changes to GitHub Actions
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5e0c0888323..8c3ee00353b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,11 +27,12 @@ jobs: filters: | code: - '**/*.go' + - '.github/workflows/**' - 'go.*' - 'internal/**' codeql: needs: changes - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: ubuntu-18.04 permissions: security-events: write @@ -48,7 +49,7 @@ jobs: uses: github/codeql-action/analyze@v1 test-archlinux: needs: changes - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: ubuntu-20.04 steps: - name: Checkout @@ -58,7 +59,7 @@ jobs: ( cd assets/docker && ./test.sh archlinux ) test-debian-i386: needs: changes - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: macos-10.15 env: VAGRANT_BOX: debian11-i386 @@ -77,7 +78,7 @@ jobs: ( cd assets/vagrant && ./test.sh debian11-i386 ) test-fedora: needs: changes - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: ubuntu-20.04 steps: - name: Checkout @@ -87,7 +88,7 @@ jobs: ( cd assets/docker && ./test.sh fedora ) test-freebsd: needs: changes - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: macos-10.15 env: VAGRANT_BOX: freebsd13 @@ -106,7 +107,7 @@ jobs: ( cd assets/vagrant && ./test.sh freebsd13 ) test-macos: needs: changes - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: macos-11 steps: - name: Set up Go @@ -139,7 +140,7 @@ jobs: go test -race ./... test-openbsd: needs: changes - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: macos-10.15 env: VAGRANT_BOX: openbsd6 @@ -158,7 +159,7 @@ jobs: ( cd assets/vagrant && ./test.sh openbsd6 ) test-openindiana: needs: changes - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: macos-10.15 env: VAGRANT_BOX: openindiana @@ -184,7 +185,7 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - name: Install age - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' 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 - @@ -208,26 +209,26 @@ jobs: run: | go run . --version - name: Test (umask 022) - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' run: | go test -ldflags="-X github.com/twpayne/chezmoi/internal/chezmoitest.umaskStr=0o022" -race ./... - name: Test (umask 002) - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' run: | go test -ldflags="-X github.com/twpayne/chezmoi/internal/chezmoitest.umaskStr=0o002" -race ./... - name: Install release dependencies - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' run: | sudo apt-get update sudo apt-get -yq --no-install-suggests --no-install-recommends install musl-tools snapcraft - name: Build release - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' uses: goreleaser/goreleaser-action@v2 with: version: latest args: release --skip-publish --snapshot - name: Test release - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' run: | # verify that version information is embedded correctly file ./dist/chezmoi-cgo-glibc_linux_amd64/chezmoi | tee /dev/stderr | grep -q "dynamically linked" @@ -236,50 +237,50 @@ jobs: ./dist/chezmoi-cgo-musl_linux_amd64/chezmoi --version | tee /dev/stderr | grep -q "chezmoi version v2" ./dist/chezmoi-nocgo_linux_386/chezmoi --version | tee /dev/stderr | grep -q "chezmoi version v2" - name: Upload artifact chezmoi-darwin-amd64 - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' uses: actions/upload-artifact@v2 with: name: chezmoi-darwin-amd64 path: dist/chezmoi-nocgo_darwin_amd64/chezmoi - name: Upload artifact chezmoi-darwin-arm64 - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' uses: actions/upload-artifact@v2 with: name: chezmoi-darwin-arm64 path: dist/chezmoi-nocgo_darwin_arm64/chezmoi - name: Upload artifact chezmoi-illumos-amd64 - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' uses: actions/upload-artifact@v2 with: name: chezmoi-illumos-amd64 path: dist/chezmoi-nocgo_illumos_amd64/chezmoi - name: Upload artifact chezmoi-linux-amd64 - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' uses: actions/upload-artifact@v2 with: name: chezmoi-linux-amd64 path: dist/chezmoi-cgo-glibc_linux_amd64/chezmoi - name: Upload artifact chezmoi-linux-musl-amd64 - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' uses: actions/upload-artifact@v2 with: name: chezmoi-linux-musl-amd64 path: dist/chezmoi-cgo-musl_linux_amd64/chezmoi - name: Upload artifact chezmoi-solaris-amd64 - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' uses: actions/upload-artifact@v2 with: name: chezmoi-solaris-amd64 path: dist/chezmoi-nocgo_solaris_amd64/chezmoi - name: Upload artifact chezmoi-windows-amd64.exe - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' uses: actions/upload-artifact@v2 with: name: chezmoi-windows-amd64.exe path: dist/chezmoi-nocgo_windows_amd64/chezmoi.exe test-ubuntu-go1-16: needs: changes - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: ubuntu-18.04 steps: - name: Set up Go @@ -312,7 +313,7 @@ jobs: go test ./... test-windows: needs: changes - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: windows-2019 steps: - name: Set up Go @@ -356,7 +357,7 @@ jobs: go test -race ./... test-voidlinux: needs: changes - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: ubuntu-20.04 steps: - name: Checkout @@ -397,7 +398,7 @@ jobs: findtypos -format=github-actions chezmoi . lint: needs: changes - if: needs.changes.outputs.code == 'true' + if: github.event_name == 'push' || needs.changes.outputs.code == 'true' runs-on: ubuntu-18.04 steps: - name: Checkout
chore
Ensure full CI is run on pushes to master or changes to GitHub Actions
fd5bb6a26e95d53efe9ef4006f49c970159db210
2022-01-21 22:31:50
Qeole
docs: Fix link to user guide
false
diff --git a/assets/chezmoi.io/docs/quick-start.md b/assets/chezmoi.io/docs/quick-start.md index 5dcf44b0c2a..84e6b63b96b 100644 --- a/assets/chezmoi.io/docs/quick-start.md +++ b/assets/chezmoi.io/docs/quick-start.md @@ -136,5 +136,5 @@ $ chezmoi help chezmoi has much more functionality. Good starting points are reading [articles about chezmoi](/links/articles-podcasts-and-videos/) adding more dotfiles, and using templates to manage files that vary from machine to machine and retrieve -secrets from your password manager. Read the [user manual](/user-manual/) to +secrets from your password manager. Read the [user guide](/user-guide/) to explore.
docs
Fix link to user guide
35148c7ea6905743836225644cd4b0cfaadfc603
2024-10-13 11:58:27
Tom Payne
feat: Add common --parent-dirs/-P 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 d081d40432f..b12058d72be 100644 --- a/assets/chezmoi.io/docs/reference/command-line-flags/common.md +++ b/assets/chezmoi.io/docs/reference/command-line-flags/common.md @@ -46,6 +46,10 @@ Prompt before applying each target. Write the output to *filename* instead of stdout. +## `-P`, `--parent-dirs` + +Also perform command on all parent directories of *target*. + ## `-r`, `--recursive` Recurse into subdirectories, `true` by default. diff --git a/internal/cmd/applycmd.go b/internal/cmd/applycmd.go index ff1a87c748b..225df8850a8 100644 --- a/internal/cmd/applycmd.go +++ b/internal/cmd/applycmd.go @@ -7,9 +7,10 @@ import ( ) type applyCmdConfig struct { - filter *chezmoi.EntryTypeFilter - init bool - recursive bool + filter *chezmoi.EntryTypeFilter + init bool + parentDirs bool + recursive bool } func (c *Config) newApplyCmd() *cobra.Command { @@ -30,6 +31,7 @@ func (c *Config) newApplyCmd() *cobra.Command { applyCmd.Flags().VarP(c.apply.filter.Exclude, "exclude", "x", "Exclude entry types") applyCmd.Flags().VarP(c.apply.filter.Include, "include", "i", "Include entry types") applyCmd.Flags().BoolVar(&c.apply.init, "init", c.apply.init, "Recreate config file from template") + applyCmd.Flags().BoolVarP(&c.apply.parentDirs, "parent-dirs", "P", c.apply.parentDirs, "Apply all parent directories") applyCmd.Flags().BoolVarP(&c.apply.recursive, "recursive", "r", c.apply.recursive, "Recurse into subdirectories") return applyCmd @@ -40,6 +42,7 @@ func (c *Config) runApplyCmd(cmd *cobra.Command, args []string) error { cmd: cmd, filter: c.apply.filter, init: c.apply.init, + parentDirs: c.apply.parentDirs, recursive: c.apply.recursive, umask: c.Umask, preApplyFunc: c.defaultPreApplyFunc, diff --git a/internal/cmd/archivecmd.go b/internal/cmd/archivecmd.go index 2fc70b379d5..6d7421532d0 100644 --- a/internal/cmd/archivecmd.go +++ b/internal/cmd/archivecmd.go @@ -14,11 +14,12 @@ import ( ) type archiveCmdConfig struct { - filter *chezmoi.EntryTypeFilter - format chezmoi.ArchiveFormat - gzip bool - init bool - recursive bool + filter *chezmoi.EntryTypeFilter + format chezmoi.ArchiveFormat + gzip bool + init bool + parentDirs bool + recursive bool } func (c *Config) newArchiveCmd() *cobra.Command { @@ -40,6 +41,7 @@ func (c *Config) newArchiveCmd() *cobra.Command { archiveCmd.Flags().BoolVarP(&c.archive.gzip, "gzip", "z", c.archive.gzip, "Compress output with gzip") archiveCmd.Flags().VarP(c.archive.filter.Exclude, "include", "i", "Include entry types") archiveCmd.Flags().BoolVar(&c.archive.init, "init", c.archive.init, "Recreate config file from template") + archiveCmd.Flags().BoolVarP(&c.archive.parentDirs, "parent-dirs", "P", c.archive.parentDirs, "Archive parent directories") archiveCmd.Flags().BoolVarP(&c.archive.recursive, "recursive", "r", c.archive.recursive, "Recurse into subdirectories") return archiveCmd @@ -73,10 +75,11 @@ func (c *Config) runArchiveCmd(cmd *cobra.Command, args []string) error { return chezmoi.UnknownArchiveFormatError(format) } if err := c.applyArgs(cmd.Context(), archiveSystem, chezmoi.EmptyAbsPath, args, applyArgsOptions{ - cmd: cmd, - filter: c.archive.filter, - init: c.archive.init, - recursive: c.archive.recursive, + cmd: cmd, + filter: c.archive.filter, + init: c.archive.init, + parentDirs: c.archive.parentDirs, + recursive: c.archive.recursive, }); err != nil { return err } diff --git a/internal/cmd/config.go b/internal/cmd/config.go index d5e6f371379..4fa06557927 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -564,6 +564,7 @@ type applyArgsOptions struct { cmd *cobra.Command filter *chezmoi.EntryTypeFilter init bool + parentDirs bool recursive bool umask fs.FileMode preApplyFunc chezmoi.PreApplyFunc @@ -652,6 +653,10 @@ func (c *Config) applyArgs( } } + if options.parentDirs { + targetRelPaths = prependParentRelPaths(targetRelPaths) + } + applyOptions := chezmoi.ApplyOptions{ Filter: options.filter, PreApplyFunc: options.preApplyFunc, @@ -2941,6 +2946,28 @@ func parseCommand(command string, args []string) (string, []string, error) { return command, args, nil } +// prependParentRelPaths returns a new slice of RelPaths where the parents of +// each RelPath appear before each RelPath. +func prependParentRelPaths(relPaths []chezmoi.RelPath) []chezmoi.RelPath { + // For each target relative path, enumerate its parents from the root down + // and insert any parents which have not yet been seen. + result := make([]chezmoi.RelPath, 0, len(relPaths)) + seenRelPaths := make(map[chezmoi.RelPath]struct{}, len(relPaths)) + for _, relPath := range relPaths { + components := relPath.SplitAll() + for i := 1; i < len(components); i++ { + parentRelPath := chezmoi.EmptyRelPath.Join(components[:i]...) + if _, ok := seenRelPaths[parentRelPath]; !ok { + result = append(result, parentRelPath) + seenRelPaths[parentRelPath] = struct{}{} + } + } + result = append(result, relPath) + seenRelPaths[relPath] = struct{}{} + } + return result +} + // registerCommonFlagCompletionFuncs registers completion functions for cmd's // common flags, recursively. It panics on any error. func registerCommonFlagCompletionFuncs(cmd *cobra.Command) { diff --git a/internal/cmd/config_test.go b/internal/cmd/config_test.go index 3b3ac722fe8..fe14e708d31 100644 --- a/internal/cmd/config_test.go +++ b/internal/cmd/config_test.go @@ -267,6 +267,55 @@ func TestParseConfig(t *testing.T) { } } +func TestPrependParentRelPaths(t *testing.T) { + for _, tc := range []struct { + name string + relPathStrs []string + expectedRelPathStrs []string + }{ + { + name: "empty", + }, + { + name: "single", + relPathStrs: []string{"a"}, + expectedRelPathStrs: []string{"a"}, + }, + { + name: "multiple", + relPathStrs: []string{"a", "b", "c"}, + expectedRelPathStrs: []string{"a", "b", "c"}, + }, + { + name: "single_parent", + relPathStrs: []string{"a/b"}, + expectedRelPathStrs: []string{"a", "a/b"}, + }, + { + name: "multiple_parents", + relPathStrs: []string{"a/b/c"}, + expectedRelPathStrs: []string{"a", "a/b", "a/b/c"}, + }, + { + name: "duplicate_parents", + relPathStrs: []string{"a/b/c", "a/b/d"}, + expectedRelPathStrs: []string{"a", "a/b", "a/b/c", "a/b/d"}, + }, + } { + t.Run(tc.name, func(t *testing.T) { + relPaths := make([]chezmoi.RelPath, len(tc.relPathStrs)) + for i, relPathStr := range tc.relPathStrs { + relPaths[i] = chezmoi.NewRelPath(relPathStr) + } + expected := make([]chezmoi.RelPath, len(tc.expectedRelPathStrs)) + for i, relPathStr := range tc.expectedRelPathStrs { + expected[i] = chezmoi.NewRelPath(relPathStr) + } + assert.Equal(t, expected, prependParentRelPaths(relPaths)) + }) + } +} + func TestInitConfigWithIncludedTemplate(t *testing.T) { mainFilename := ".chezmoi.yaml.tmpl" secondaryFilename := "personal.config.yaml.tmpl" diff --git a/internal/cmd/diffcmd.go b/internal/cmd/diffcmd.go index ab61014f5f9..7f2d90ba730 100644 --- a/internal/cmd/diffcmd.go +++ b/internal/cmd/diffcmd.go @@ -15,6 +15,7 @@ type diffCmdConfig struct { ScriptContents bool `json:"scriptContents" mapstructure:"scriptContents" yaml:"scriptContents"` include *chezmoi.EntryTypeSet init bool + parentDirs bool recursive bool } @@ -38,6 +39,7 @@ 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.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") @@ -47,10 +49,11 @@ func (c *Config) newDiffCmd() *cobra.Command { func (c *Config) runDiffCmd(cmd *cobra.Command, args []string) (err error) { return c.applyArgs(cmd.Context(), c.destSystem, c.DestDirAbsPath, args, applyArgsOptions{ - cmd: cmd, - filter: chezmoi.NewEntryTypeFilter(c.Diff.include.Bits(), c.Diff.Exclude.Bits()), - init: c.Diff.init, - recursive: c.Diff.recursive, - umask: c.Umask, + cmd: cmd, + filter: chezmoi.NewEntryTypeFilter(c.Diff.include.Bits(), c.Diff.Exclude.Bits()), + init: c.Diff.init, + parentDirs: c.Diff.parentDirs, + recursive: c.Diff.recursive, + umask: c.Umask, }) } diff --git a/internal/cmd/dumpcmd.go b/internal/cmd/dumpcmd.go index 61fcf1711cb..69aa853ad00 100644 --- a/internal/cmd/dumpcmd.go +++ b/internal/cmd/dumpcmd.go @@ -7,9 +7,10 @@ import ( ) type dumpCmdConfig struct { - filter *chezmoi.EntryTypeFilter - init bool - recursive bool + filter *chezmoi.EntryTypeFilter + init bool + parentDirs bool + recursive bool } func (c *Config) newDumpCmd() *cobra.Command { @@ -30,6 +31,7 @@ func (c *Config) newDumpCmd() *cobra.Command { dumpCmd.Flags().VarP(&c.Format, "format", "f", "Output format") dumpCmd.Flags().VarP(c.dump.filter.Include, "include", "i", "Include entry types") dumpCmd.Flags().BoolVar(&c.dump.init, "init", c.dump.init, "Recreate config file from template") + dumpCmd.Flags().BoolVarP(&c.dump.parentDirs, "parent-dirs", "P", c.dump.parentDirs, "Dump all parent directories") dumpCmd.Flags().BoolVarP(&c.dump.recursive, "recursive", "r", c.dump.recursive, "Recurse into subdirectories") return dumpCmd @@ -38,11 +40,12 @@ func (c *Config) newDumpCmd() *cobra.Command { func (c *Config) runDumpCmd(cmd *cobra.Command, args []string) error { dumpSystem := chezmoi.NewDumpSystem() if err := c.applyArgs(cmd.Context(), dumpSystem, chezmoi.EmptyAbsPath, args, applyArgsOptions{ - cmd: cmd, - filter: c.dump.filter, - init: c.dump.init, - recursive: c.dump.recursive, - umask: c.Umask, + cmd: cmd, + filter: c.dump.filter, + init: c.dump.init, + parentDirs: c.dump.parentDirs, + recursive: c.dump.recursive, + umask: c.Umask, }); err != nil { return err } diff --git a/internal/cmd/statuscmd.go b/internal/cmd/statuscmd.go index 9a199a35afa..1789c7a4074 100644 --- a/internal/cmd/statuscmd.go +++ b/internal/cmd/statuscmd.go @@ -14,11 +14,12 @@ import ( ) type statusCmdConfig struct { - Exclude *chezmoi.EntryTypeSet `json:"exclude" mapstructure:"exclude" yaml:"exclude"` - PathStyle *chezmoi.PathStyle `json:"pathStyle" mapstructure:"pathStyle" yaml:"pathStyle"` - include *chezmoi.EntryTypeSet - init bool - recursive bool + Exclude *chezmoi.EntryTypeSet `json:"exclude" mapstructure:"exclude" yaml:"exclude"` + PathStyle *chezmoi.PathStyle `json:"pathStyle" mapstructure:"pathStyle" yaml:"pathStyle"` + include *chezmoi.EntryTypeSet + init bool + parentDirs bool + recursive bool } func (c *Config) newStatusCmd() *cobra.Command { @@ -40,6 +41,7 @@ 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.recursive, "recursive", "r", c.Status.recursive, "Recurse into subdirectories") return statusCmd @@ -88,6 +90,7 @@ func (c *Config) runStatusCmd(cmd *cobra.Command, args []string) error { cmd: cmd, filter: chezmoi.NewEntryTypeFilter(c.Status.include.Bits(), c.Status.Exclude.Bits()), init: c.Status.init, + parentDirs: c.Status.parentDirs, recursive: c.Status.recursive, umask: c.Umask, preApplyFunc: preApplyFunc, diff --git a/internal/cmd/testdata/scripts/issue3987.txtar b/internal/cmd/testdata/scripts/issue3987.txtar new file mode 100644 index 00000000000..37528b1c052 --- /dev/null +++ b/internal/cmd/testdata/scripts/issue3987.txtar @@ -0,0 +1,6 @@ +# test that chezmoi apply --parent-dirs creates parent directories +exec chezmoi apply --parent-dirs $HOME/.config/nvim/after/queries/gotmpl/injections.scm +exists $HOME/.config/nvim/after/queries/gotmpl/injections.scm + +-- home/user/.local/share/chezmoi/private_dot_config/nvim/after/queries/gotmpl/injections.scm -- +# contents of injections.scm diff --git a/internal/cmd/updatecmd.go b/internal/cmd/updatecmd.go index 3ad5555c8de..e6a7b8d4713 100644 --- a/internal/cmd/updatecmd.go +++ b/internal/cmd/updatecmd.go @@ -16,6 +16,7 @@ type updateCmdConfig struct { RecurseSubmodules bool `json:"recurseSubmodules" mapstructure:"recurseSubmodules" yaml:"recurseSubmodules"` filter *chezmoi.EntryTypeFilter init bool + parentDirs bool recursive bool } @@ -40,6 +41,7 @@ func (c *Config) newUpdateCmd() *cobra.Command { updateCmd.Flags().VarP(c.Update.filter.Exclude, "exclude", "x", "Exclude entry types") updateCmd.Flags().VarP(c.Update.filter.Include, "include", "i", "Include entry types") updateCmd.Flags().BoolVar(&c.Update.init, "init", c.Update.init, "Recreate config file from template") + updateCmd.Flags().BoolVarP(&c.Update.parentDirs, "parent-dirs", "P", c.Update.parentDirs, "Update all parent directories") updateCmd.Flags(). BoolVar(&c.Update.RecurseSubmodules, "recurse-submodules", c.Update.RecurseSubmodules, "Recursively update submodules") updateCmd.Flags().BoolVarP(&c.Update.recursive, "recursive", "r", c.Update.recursive, "Recurse into subdirectories") @@ -92,6 +94,7 @@ func (c *Config) runUpdateCmd(cmd *cobra.Command, args []string) error { cmd: cmd, filter: c.Update.filter, init: c.Update.init, + parentDirs: c.Update.parentDirs, recursive: c.Update.recursive, umask: c.Umask, preApplyFunc: c.defaultPreApplyFunc, diff --git a/internal/cmd/verifycmd.go b/internal/cmd/verifycmd.go index 7543610cb80..977060c9dc7 100644 --- a/internal/cmd/verifycmd.go +++ b/internal/cmd/verifycmd.go @@ -7,10 +7,11 @@ import ( ) type verifyCmdConfig struct { - Exclude *chezmoi.EntryTypeSet `json:"exclude" mapstructure:"exclude" yaml:"exclude"` - include *chezmoi.EntryTypeSet - init bool - recursive bool + Exclude *chezmoi.EntryTypeSet `json:"exclude" mapstructure:"exclude" yaml:"exclude"` + include *chezmoi.EntryTypeSet + init bool + parentDirs bool + recursive bool } func (c *Config) newVerifyCmd() *cobra.Command { @@ -30,6 +31,7 @@ func (c *Config) newVerifyCmd() *cobra.Command { verifyCmd.Flags().VarP(c.Verify.Exclude, "exclude", "x", "Exclude entry types") verifyCmd.Flags().VarP(c.Verify.include, "include", "i", "Include entry types") verifyCmd.Flags().BoolVar(&c.Verify.init, "init", c.Verify.init, "Recreate config file from template") + verifyCmd.Flags().BoolVarP(&c.Verify.parentDirs, "parent-dirs", "P", c.Verify.parentDirs, "Verify all parent directories") verifyCmd.Flags().BoolVarP(&c.Verify.recursive, "recursive", "r", c.Verify.recursive, "Recurse into subdirectories") return verifyCmd @@ -38,10 +40,11 @@ func (c *Config) newVerifyCmd() *cobra.Command { func (c *Config) runVerifyCmd(cmd *cobra.Command, args []string) error { errorOnWriteSystem := chezmoi.NewErrorOnWriteSystem(c.destSystem, chezmoi.ExitCodeError(1)) return c.applyArgs(cmd.Context(), errorOnWriteSystem, c.DestDirAbsPath, args, applyArgsOptions{ - cmd: cmd, - filter: chezmoi.NewEntryTypeFilter(c.Verify.include.Bits(), c.Verify.Exclude.Bits()), - init: c.Verify.init, - recursive: c.Verify.recursive, - umask: c.Umask, + cmd: cmd, + filter: chezmoi.NewEntryTypeFilter(c.Verify.include.Bits(), c.Verify.Exclude.Bits()), + init: c.Verify.init, + parentDirs: c.Verify.parentDirs, + recursive: c.Verify.recursive, + umask: c.Umask, }) }
feat
Add common --parent-dirs/-P flag
9a0a90a20425f36241800e1e2afa14f3c2732223
2022-10-28 19:46:57
Austin Ziegler
fix: Construct `templateDataMap` manually
false
diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index cdc4c9f23d4..f624e99686c 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -1239,17 +1239,29 @@ func (c *Config) getTemplateData() *templateData { // getTemplateDataMao returns the template data as a map. func (c *Config) getTemplateDataMap() map[string]any { templateData := c.getTemplateData() - // FIXME round-tripping via JSON is a horrible hack - data, err := json.Marshal(templateData) - if err != nil { - panic(err) - } - var templateDataMap map[string]any - if err := json.Unmarshal(data, &templateDataMap); err != nil { - panic(err) - } + return map[string]any{ - "chezmoi": templateDataMap, + "chezmoi": map[string]any{ + "arch": templateData.Arch, + "args": templateData.Args, + "cacheDir": templateData.CacheDir.String(), + "configFile": templateData.ConfigFile.String(), + "executable": templateData.Executable.String(), + "fqdnHostname": templateData.FQDNHostname, + "gid": templateData.GID, + "group": templateData.Group, + "homeDir": templateData.HomeDir.String(), + "hostname": templateData.Hostname, + "kernel": templateData.Kernel, + "os": templateData.OS, + "osRelease": templateData.OSRelease, + "sourceDir": templateData.SourceDir.String(), + "uid": templateData.UID, + "username": templateData.Username, + "version": templateData.Version, + "windowsVersion": templateData.WindowsVersion, + "workingTree": templateData.WorkingTree.String(), + }, } }
fix
Construct `templateDataMap` manually
978a61f87c284e668b86276839821ec93d4e6bf2
2022-01-17 00:45:11
Tom Payne
chore: Add test for add --force
false
diff --git a/internal/cmd/testdata/scripts/add.txt b/internal/cmd/testdata/scripts/add.txt index 6685a13d5cd..deec4ada382 100644 --- a/internal/cmd/testdata/scripts/add.txt +++ b/internal/cmd/testdata/scripts/add.txt @@ -65,6 +65,21 @@ chezmoi add $HOME${/}.dir exists $CHEZMOISOURCEDIR/dot_dir/file ! exists $CHEZMOISOURCEDIR/dot_dir/ignore +chhome home4/user + +# test that chezmoi add does not overwrite an already-added file +chezmoi add $HOME/.file +cmp $CHEZMOISOURCEDIR/dot_file golden/dot_file +edit $HOME/.file +cmp $CHEZMOISOURCEDIR/dot_file golden/dot_file + +# test that chezmoi add --force does overwrite an already-added file +chezmoi add --force $HOME/.file +cmp $CHEZMOISOURCEDIR/dot_file golden/edited_dot_file + +-- golden/edited_dot_file -- +# contents of .file +# edited -- home2/user/.dir/non_empty_subdir/file -- # contents of .dir/non_empty_subdir/file -- home3/user/.local/share/chezmoi/.chezmoiignore -- @@ -73,3 +88,5 @@ exists $CHEZMOISOURCEDIR/dot_dir/file # contents of .dir/file -- home3/user/.dir/ignore -- # contents of .dir/ignore +-- home4/user/.file -- +# contents of .file
chore
Add test for add --force
94360d2a5950026b6818402c372901aefbaea43f
2021-10-21 05:17:05
Tom Payne
chore: Add boolean operators to testscript conditions
false
diff --git a/internal/cmd/main_test.go b/internal/cmd/main_test.go index 1a9072bdc0a..265cd0b2c6a 100644 --- a/internal/cmd/main_test.go +++ b/internal/cmd/main_test.go @@ -27,6 +27,27 @@ import ( "github.com/twpayne/chezmoi/v2/internal/cmd" ) +// FIXME remove the following when +// https://github.com/rogpeppe/go-internal/pull/147 is merged. +const ( + goosList = "aix android darwin dragonfly freebsd hurd illumos ios js linux nacl netbsd openbsd plan9 solaris windows zos " + goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be loong64 mips mipsle mips64 mips64le mips64p32 mips64p32le ppc ppc64 ppc64le riscv riscv64 s390 s390x sparc sparc64 wasm " +) + +var ( + KnownOS = make(map[string]bool) + KnownArch = make(map[string]bool) +) + +func init() { + for _, v := range strings.Fields(goosList) { + KnownOS[v] = true + } + for _, v := range strings.Fields(goarchList) { + KnownArch[v] = true + } +} + var umaskConditionRx = regexp.MustCompile(`\Aumask:([0-7]{3})\z`) //nolint:interfacer @@ -66,17 +87,8 @@ func TestScript(t *testing.T) { "unix2dos": cmdUNIX2DOS, }, Condition: func(cond string) (bool, error) { - switch cond { - case "darwin": - return runtime.GOOS == "darwin", nil - case "freebsd": - return runtime.GOOS == "freebsd", nil - case "linux": - return runtime.GOOS == "linux", nil - case "openbsd": - return runtime.GOOS == "openbsd", nil - case "windows": - return runtime.GOOS == "windows", nil + if result, valid := goosCondition(cond); valid { + return result, nil } if m := umaskConditionRx.FindStringSubmatch(cond); m != nil { umask, _ := strconv.ParseInt(m[1], 8, 64) @@ -523,6 +535,61 @@ func cmdUNIX2DOS(ts *testscript.TestScript, neg bool, args []string) { } } +// goosCondition evaluates cond as a logical OR of GOARCHes or GOOSes enclosed +// in parentheses, returning true if any of them match. +func goosCondition(cond string) (result, valid bool) { + // FIXME remove the following two if statements when + // https://github.com/rogpeppe/go-internal/pull/147 is merged, and use + // github.com/rogpeppe/go-internal/imports.Known{Arch,OS} instead + if _, ok := KnownArch[cond]; ok { + result = runtime.GOARCH == cond + valid = true + return + } + if _, ok := KnownOS[cond]; ok { + result = runtime.GOOS == cond + valid = true + return + } + + // Interpret the condition as a logical OR of terms in parantheses. + if !strings.HasPrefix(cond, "(") || !strings.HasSuffix(cond, ")") { + result = false + valid = false + return + } + cond = strings.TrimPrefix(cond, "(") + cond = strings.TrimSuffix(cond, ")") + terms := strings.Split(cond, "||") + + // If any of the terms are neither known GOOSes nor GOARCHes then reject the + // condition as invalid. + for _, term := range terms { + if _, ok := KnownOS[term]; !ok { + if _, ok := KnownArch[term]; !ok { + valid = false + return + } + } + } + + // At this point, we know the expression is valid. + valid = true + + // If any of the terms match either runtime.GOOS or runtime.GOARCH then + // the condition is true. + for _, term := range terms { + if runtime.GOOS == term || runtime.GOARCH == term { + result = true + return + } + } + + // Otherwise, the condtion is false. + result = false + return +} + func prependDirToPath(dir, path string) string { return strings.Join(append([]string{dir}, filepath.SplitList(path)...), string(os.PathListSeparator)) } diff --git a/internal/cmd/testdata/scripts/archivetar.txt b/internal/cmd/testdata/scripts/archivetar.txt index 79ff7dc7437..591143bb548 100644 --- a/internal/cmd/testdata/scripts/archivetar.txt +++ b/internal/cmd/testdata/scripts/archivetar.txt @@ -1,15 +1,16 @@ mksourcedir -[openbsd] exec sed -e 's:/$::g' -i golden/archive-tar [windows] unix2dos golden/archive-tar chezmoi archive --output=archive.tar exec tar -tf archive.tar -cmp stdout golden/archive-tar +[!openbsd] cmp stdout golden/archive-tar +[openbsd] cmp stdout golden/archive-tar-openbsd chezmoi archive --gzip --output=archive.tar.gz exec tar -tzf archive.tar.gz -cmp stdout golden/archive-tar +[!openbsd] cmp stdout golden/archive-tar +[openbsd] cmp stdout golden/archive-tar-openbsd -- golden/archive-tar -- .create @@ -24,3 +25,16 @@ cmp stdout golden/archive-tar .readonly .symlink .template +-- golden/archive-tar-openbsd -- +.create +.dir +.dir/file +.dir/subdir +.dir/subdir/file +.empty +.executable +.file +.private +.readonly +.symlink +.template diff --git a/internal/cmd/testdata/scripts/runscriptdir_unix.txt b/internal/cmd/testdata/scripts/runscriptdir_unix.txt index 749df055116..f1a652b8563 100644 --- a/internal/cmd/testdata/scripts/runscriptdir_unix.txt +++ b/internal/cmd/testdata/scripts/runscriptdir_unix.txt @@ -1,8 +1,6 @@ [windows] skip 'UNIX only' [!umask:022] skip -[openbsd] exec sed -e 's:/$::g' -i golden/archive - chezmoi apply cmpenv stdout golden/apply @@ -12,13 +10,17 @@ cmp stdout golden/dump chezmoi archive --output=archive.tar exec tar -tf archive.tar -cmp stdout golden/archive +[openbsd] cmp stdout golden/archive-openbsd +[!openbsd] cmp stdout golden/archive -- golden/apply -- $HOME${/}dir -- golden/archive -- dir/ dir/script +-- golden/archive-openbsd -- +dir +dir/script -- golden/dump -- { "dir": { diff --git a/internal/cmd/testdata/scripts/scriptsubdir_unix.txt b/internal/cmd/testdata/scripts/scriptsubdir_unix.txt index 59b6c4af83d..c91e63befad 100644 --- a/internal/cmd/testdata/scripts/scriptsubdir_unix.txt +++ b/internal/cmd/testdata/scripts/scriptsubdir_unix.txt @@ -1,8 +1,6 @@ [windows] skip 'UNIX only' [!umask:022] skip -[openbsd] exec sed -e 's:/$::g' -i golden/archive - # test that scripts in subdirectories are run in the subdirectory chezmoi apply --force cmpenv stdout golden/apply @@ -12,7 +10,8 @@ cmp stdout golden/dump chezmoi archive --gzip --output=archive.tar.gz exec tar -tzf archive.tar.gz -cmp stdout golden/archive +[!openbsd] cmp stdout golden/archive +[openbsd] cmp stdout golden/archive-openbsd -- golden/apply -- $HOME @@ -25,6 +24,13 @@ dir/ dir/script otherdir/ anotherdir/script +-- golden/archive-openbsd -- +otherdir/script +anotherdir +dir +dir/script +otherdir +anotherdir/script -- golden/dump -- { "anotherdir": {
chore
Add boolean operators to testscript conditions
b427e3d7dd1ec7fef1ea7b3b8d14b669b338ed5c
2024-01-01 17:23:11
Tom Payne
chore: Relax commit message check
false
diff --git a/internal/cmds/lint-commit-messages/main.go b/internal/cmds/lint-commit-messages/main.go index 69925c8c891..ebc532d3706 100644 --- a/internal/cmds/lint-commit-messages/main.go +++ b/internal/cmds/lint-commit-messages/main.go @@ -10,7 +10,7 @@ import ( "strings" ) -var commitRx = regexp.MustCompile(`\A([0-9a-f]{40}) (chore(?:\(\w+\))?|docs|feat|fix): `) +var commitRx = regexp.MustCompile(`\A([0-9a-f]{40}) (chore(?:\([\w\-]+\))?|docs|feat|fix): `) func run() error { args := append([]string{"log", "--format=oneline"}, os.Args[1:]...) diff --git a/internal/cmds/lint-commit-messages/main_test.go b/internal/cmds/lint-commit-messages/main_test.go new file mode 100644 index 00000000000..7aaa33c7715 --- /dev/null +++ b/internal/cmds/lint-commit-messages/main_test.go @@ -0,0 +1,24 @@ +package main + +import ( + "strings" + "testing" + + "github.com/alecthomas/assert/v2" +) + +func TestCommitRx(t *testing.T) { + prefix := strings.Repeat("0", 40) + " " + for s, match := range map[string]bool{ + "chore(deps): text": true, + "chore(deps-dev): text": true, + "chore: text": true, + "docs: text": true, + "feat: text": true, + "fix: text": true, + "fixup!": false, + "snapshot": false, + } { + assert.Equal(t, match, commitRx.MatchString(prefix+s)) + } +}
chore
Relax commit message check
697cc04725bd7465b5db5e3fbacb2429b2f6b320
2023-09-18 23:50:03
Tom Payne
chore: Update developer documentation
false
diff --git a/assets/chezmoi.io/docs/developer/building-on-top-of-chezmoi.md b/assets/chezmoi.io/docs/developer/building-on-top-of-chezmoi.md index 4de32ac3ecd..5ffaf0d38c5 100644 --- a/assets/chezmoi.io/docs/developer/building-on-top-of-chezmoi.md +++ b/assets/chezmoi.io/docs/developer/building-on-top-of-chezmoi.md @@ -5,8 +5,3 @@ tool is semantically versioned. Building on top of chezmoi should primarily be done by executing the binary with arguments and the standard input and output configured appropriately. The `chezmoi dump` and `chezmoi state` commands allows the inspection of chezmoi's internal state. - -chezmoi's internal functionality is available as the Go module -`github.com/twpayne/chezmoi/v2`, however there are no guarantees whatsoever -about the API stability of this module. The semantic version applies to the -command line tool, and not to any Go APIs at any level. diff --git a/assets/chezmoi.io/docs/developer/developing-locally.md b/assets/chezmoi.io/docs/developer/developing-locally.md index 22bc08e54c9..1ac0b9858ba 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.19 or later. +Go tooling. chezmoi requires Go 1.20 or later. Checkout chezmoi: diff --git a/assets/chezmoi.io/docs/install.md.tmpl b/assets/chezmoi.io/docs/install.md.tmpl index dc750e91da2..7f239f1a9cb 100644 --- a/assets/chezmoi.io/docs/install.md.tmpl +++ b/assets/chezmoi.io/docs/install.md.tmpl @@ -249,7 +249,7 @@ pre-built binary and shell completions. ## Install from source -Download, build, and install chezmoi for your system with Go 1.19 or later: +Download, build, and install chezmoi for your system with Go 1.20 or later: ```console $ git clone https://github.com/twpayne/chezmoi.git
chore
Update developer documentation
ee6eccd124aa4e86e73970908151a9ec937605f2
2024-12-08 18:00:26
Tom Payne
chore: Add JSON Schema for goreleaser config
false
diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 9b566fb8482..9ae26a03e55 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,3 +1,5 @@ +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json + version: 2 project_name: chezmoi
chore
Add JSON Schema for goreleaser config
eb629583cac1a60ea696ae913194480e42478378
2024-03-10 06:19:51
Tom Payne
docs: Fix incomplete sentence in usage docs
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 d0b7a9974c9..bc92f8c5a02 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 @@ -5,9 +5,11 @@ There are five popular approaches: 1. Use `chezmoi edit $FILE`. This will open the source file for `$FILE` in your - editor, including . For extra ease, use `chezmoi edit --apply $FILE` to apply - the changes when you quit your editor, and `chezmoi edit --watch $FILE` to - apply the changes whenever you save the file. + editor, including opening the template if the file is templated and + transparently decrypting and re-encrypting it if it is encrypted. For extra + ease, use `chezmoi edit --apply $FILE` to apply the changes when you quit + your editor, and `chezmoi edit --watch $FILE` to apply the changes whenever + you save the file. 2. Use `chezmoi cd` and edit the files in the source directory directly. Run `chezmoi diff` to see what changes would be made, and `chezmoi apply` to make
docs
Fix incomplete sentence in usage docs
5411f46a43420f190958b092b798d6045c7c3baf
2023-07-02 16:41:29
dependabot[bot]
chore(deps): bump github.com/rogpeppe/go-internal
false
diff --git a/go.mod b/go.mod index efda5e9de31..54827e52349 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/muesli/combinator v0.3.0 github.com/muesli/termenv v0.15.2 github.com/pelletier/go-toml/v2 v2.0.8 - github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97 + github.com/rogpeppe/go-internal v1.11.0 github.com/rs/zerolog v1.29.1 github.com/sergi/go-diff v1.1.0 github.com/spf13/cobra v1.7.0 diff --git a/go.sum b/go.sum index d4278942fc7..e8df2e0a6ac 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,5 @@ -cloud.google.com/go/compute/metadata v0.2.0 h1:nBbNSZyDpkNlo3DepaaLKVuO7ClyifSAmNloSCZrHnQ= -cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= filippo.io/age v1.1.1 h1:pIpO7l151hCnQ4BdyBujnGP2YlUo0uj6sAVNHGBvXHg= filippo.io/age v1.1.1/go.mod h1:l03SrzDUrBkdBx8+IILdnn2KZysqQdbEBUQ4p3sqEQE= -filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= -filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= 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/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= @@ -29,9 +25,7 @@ github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW5 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-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= -github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= 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= 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.18.1 h1:+tefE750oAb7ZQGzla6bLkOwfcQCEtC5y2RqoqCeqKo= @@ -60,7 +54,6 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.19.2 h1:XFJ2Z6sNUUcAz9poj+245DMkrHE4 github.com/aws/aws-sdk-go-v2/service/sts v1.19.2/go.mod h1:dp0yLPsLBOi++WTxzCjA/oZqi6NPIhoR+uF7GeMU9eg= 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 h1:DTwqENW7X9arYimJrPeGZcV0ln14sGMt3pHZspWD+Mg= github.com/aymanbagabas/go-osc52 v1.0.3/go.mod h1:zT8H+Rk4VSabYN90pWyugflM3ZhpTZNC7cASDfUCdT4= 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= @@ -72,7 +65,6 @@ github.com/bradenhilton/cityhash v1.0.0 h1:1QauDCwfxwIGwO2jBTJdEBqXgfCusAgQOSgdl github.com/bradenhilton/cityhash v1.0.0/go.mod h1:Wmb8yW1egA9ulrsRX4mxfYx5zq4nBWOCZ+j63oK6uz8= github.com/bradenhilton/mozillainstallhash v1.0.1 h1:JVAVsItiWlLoudJX4L+tIuml+hoxjlzCwkhlENi9yS4= github.com/bradenhilton/mozillainstallhash v1.0.1/go.mod h1:J6cA36kUZrgaTkDl2bHRqI+4i2UKO1ImDB1P1x1PyOA= -github.com/bwesterb/go-ristretto v1.2.3 h1:1w53tCkGhCQ5djbat3+MH0BAQ5Kfgbt56UZQ/JMzngw= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/charmbracelet/bubbles v0.16.1 h1:6uzpAAaT9ZqKssntbvZMlksWHruQLNxg49H5WdeuYSY= github.com/charmbracelet/bubbles v0.16.1/go.mod h1:2QCp9LFlEsBQMvIYERr7Ww2H2bA7xen1idUDIzm/+Xc= @@ -90,13 +82,9 @@ github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2 github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= 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.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= -github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= -github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE= github.com/danieljoos/wincred v1.2.0/go.mod h1:FzQLLMKBFdvu+osBrnFODiv32YGwCfx0SkRa/eYHgec= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -105,26 +93,20 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0= github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= -github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad h1:Qk76DOWdOp+GlyDKBAG3Klr9cn7N+LcYc82AZ2S7+cA= github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad/go.mod h1:mPKfmRa823oBIgl2r20LeMSpTAteW5j7FLkc0vjmzyQ= github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 h1:RIB4cRk+lBqKK3Oy0r2gRX4ui7tuhiZq2SuTtTCi0/0= -github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/frankban/quicktest v1.14.5 h1:dfYrrRyLtiqT9GyKXgdh+k4inNeTvmGbuSgZ3lx3GhA= -github.com/frankban/quicktest v1.14.5/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= -github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f h1:Pz0DHeFij3XFhoBRGUDPzSJ+w2UcK5/0JvF8DRI58r8= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f/go.mod h1:8LHG1a3SRW71ettAD/jW13h8c6AqjVSeL11RAdgaqpo= github.com/go-git/go-git/v5 v5.7.0 h1:t9AudWVLmqzlo+4bqdf7GY+46SUuRsx59SboFxkq2aE= github.com/go-git/go-git/v5 v5.7.0/go.mod h1:coJHKEOk5kUClpsNlXrUvPrDxY3w3gjHvhcZd8Fodw8= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -133,7 +115,6 @@ github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x 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/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.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= @@ -144,7 +125,6 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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/v53 v53.2.0 h1:wvz3FyF53v4BK+AsnvCmeNhf8AkTaeh2SoYu/XUvTtI= github.com/google/go-github/v53 v53.2.0/go.mod h1:XhFRObz+m/l+UCm9b7KSIC3lT3NWSXGt7mOsAWEloao= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= @@ -155,7 +135,6 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 h1:l5lAOZEym3oK3SQ2HBHWsJUfbNBiTXJDeW2QDxw9AQ0= -github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 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= @@ -177,14 +156,9 @@ github.com/itchyny/timefmt-go v0.1.5/go.mod h1:nEP7L+2YmAbT2kZ2HfSs1d8Xtw9LY8D2s github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= -github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= -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/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -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.16.6 h1:91SKEy4K37vkp255cJ8QesJhjyRO0hn9i9G0GoUwLsk= @@ -192,14 +166,10 @@ github.com/klauspost/compress v1.16.6/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQs 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= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= 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/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= @@ -228,8 +198,6 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/mmcloughlin/avo v0.5.0 h1:nAco9/aI9Lg2kiuROBY6BhCI/z0t5jEvJfjWbL8qXLU= -github.com/mmcloughlin/avo v0.5.0/go.mod h1:ChHFdoV7ql95Wi7vuq2YT1bwCJqiWdZrQ1im3VujLYM= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= @@ -241,7 +209,6 @@ github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKt github.com/muesli/termenv v0.13.0/go.mod h1:sP1+uffeLaEYpyOTb8pLCUctGcGLnoFjSn4YJK5e2bc= github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= -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= @@ -251,8 +218,6 @@ github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+v github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -261,32 +226,22 @@ 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.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97 h1:3RPlVWzZ/PDqmVuf/FKHARG5EMid/tl7cv54Sw/QRVY= -github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= -github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= 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= -github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= 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= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= 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/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= -github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/skeema/knownhosts v1.1.1 h1:MTk78x9FPgDFVFkDLTrsnnfCJl7g1C/nnKvePgrIngE= github.com/skeema/knownhosts v1.1.1/go.mod h1:g4fPeYpque7P0xefxtGzV81ihjC8sX2IqpAoNkjxbMo= github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w= -github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= @@ -316,8 +271,6 @@ github.com/twpayne/go-xdg/v6 v6.1.1 h1:OzoxnDWEaqO1b32F8zZaDj3aJWgWyTsL8zOiun7UK 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/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA= -github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1 h1:+dBg5k7nuTE38VVdoroRsT0Z88fmvdYrI2EjzJst35I= github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1/go.mod h1:nmuySobZb4kFgFy6BptpXp/BBw+xFSyvVPP6auoJB4k= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= @@ -333,10 +286,6 @@ github.com/zalando/go-keyring v0.2.3 h1:v9CUu9phlABObO4LPWycf+zwMG7nlbb3t/B5wa97 github.com/zalando/go-keyring v0.2.3/go.mod h1:HL4k+OXQfJUWaMnqyuSOc0drfGPX2b51Du6K+MRgZMk= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= -go.etcd.io/gofail v0.1.0 h1:XItAMIhOojXFQMgrxjnd2EIIHun/d5qL0Pf7FzVTkFg= -go.etcd.io/gofail v0.1.0/go.mod h1:VZBCXYGZhHAinaBiiqYvuDynvahNsAyLFwB3kEHKz1M= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -416,7 +365,6 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg= golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= @@ -432,12 +380,10 @@ gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.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.v1 v1.0.0-20140924161607-9f9df34309c0 h1:POO/ycCATvegFmVuPpQzZFJ+pGZeX22Ufu6fibxDVjU= gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= @@ -445,7 +391,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM= howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= -mvdan.cc/editorconfig v0.2.0 h1:XL+7ys6ls/RKrkUNFQvEwIvNHh+JKx8Mj1pUV5wQxQE= -mvdan.cc/editorconfig v0.2.0/go.mod h1:lvnnD3BNdBYkhq+B4uBuFFKatfp02eB6HixDvEz91C0= mvdan.cc/sh/v3 v3.7.0 h1:lSTjdP/1xsddtaKfGg7Myu7DnlHItd3/M2tomOcNNBg= mvdan.cc/sh/v3 v3.7.0/go.mod h1:K2gwkaesF/D7av7Kxl0HbF5kGOd2ArupNTX3X44+8l8=
chore
bump github.com/rogpeppe/go-internal
37e74e6991a632c3cd83cc5aa45edc1558d850ae
2024-05-06 05:31:26
Tom Payne
chore: Update tools
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 22e4f51e9b6..02080743dc2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,10 +11,10 @@ on: schedule: - cron: 32 2 * * * env: - ACTIONLINT_VERSION: 1.6.26 + ACTIONLINT_VERSION: 1.6.27 AGE_VERSION: 1.1.1 CHOCOLATEY_VERSION: 2.2.2 - EDITORCONFIG_CHECKER_VERSION: 2.8.0 + EDITORCONFIG_CHECKER_VERSION: 3.0.1 FIND_TYPOS_VERSION: 0.0.3 GO_VERSION: 1.22.2 GOFUMPT_VERSION: 0.6.0 @@ -345,7 +345,7 @@ jobs: run: | GOOS="$(go env GOOS)" GOARCH="$(go env GOARCH)" - curl -sSfL "https://github.com/editorconfig-checker/editorconfig-checker/releases/download/${EDITORCONFIG_CHECKER_VERSION}/ec-${GOOS}-${GOARCH}.tar.gz" | tar -xzf - + curl -sSfL "https://github.com/editorconfig-checker/editorconfig-checker/releases/download/v${EDITORCONFIG_CHECKER_VERSION}/ec-${GOOS}-${GOARCH}.tar.gz" | tar -xzf - "bin/ec-${GOOS}-${GOARCH}" - name: lint-whitespace run: | diff --git a/Makefile b/Makefile index fe392ac6c31..3255247162c 100644 --- a/Makefile +++ b/Makefile @@ -149,7 +149,7 @@ ensure-actionlint: .PHONY: ensure-editorconfig-checker ensure-editorconfig-checker: if [ ! -x bin/editorconfig-checker ] || ( ./bin/editorconfig-checker --version | grep -Fqv "v${EDITORCONFIG_CHECKER_VERSION}" ) ; then \ - curl -sSfL "https://github.com/editorconfig-checker/editorconfig-checker/releases/download/${EDITORCONFIG_CHECKER_VERSION}/ec-${GOOS}-${GOARCH}.tar.gz" | tar -xzf - ; \ + curl -sSfL "https://github.com/editorconfig-checker/editorconfig-checker/releases/download/v${EDITORCONFIG_CHECKER_VERSION}/ec-${GOOS}-${GOARCH}.tar.gz" | tar -xzf - ; \ mv "bin/ec-${GOOS}-${GOARCH}" bin/editorconfig-checker ; \ fi
chore
Update tools
774eed29f7ddb9c910534d627990d63182ad0304
2022-07-29 03:21:53
Tom Payne
chore: Bump golangci-lint to v1.47.2
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 323d65374e8..38826bc3a93 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ env: AGE_VERSION: 1.0.0 GO_VERSION: 1.18.4 GOFUMPT_VERSION: 0.3.1 - GOLANGCI_LINT_VERSION: 1.47.1 + GOLANGCI_LINT_VERSION: 1.47.2 TPARSE_VERSION: 0.11.1 jobs: changes:
chore
Bump golangci-lint to v1.47.2
093d116c63f668afaf716fb76bafa808b2b46c69
2022-08-08 02:41:16
Tom Payne
chore: Tidy up managed and unmanaged commands
false
diff --git a/assets/chezmoi.io/docs/reference/commands/managed.md b/assets/chezmoi.io/docs/reference/commands/managed.md index 2f0298d2802..d5e339b5436 100644 --- a/assets/chezmoi.io/docs/reference/commands/managed.md +++ b/assets/chezmoi.io/docs/reference/commands/managed.md @@ -1,7 +1,7 @@ -# `managed` [*target*...] +# `managed` [*path*...] -List all managed entries in the destination directory under all *target*s in -alphabetical order. When no *target*s are supplied, list all managed entries in +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. ## `-i`, `--include` *types* diff --git a/assets/chezmoi.io/docs/reference/commands/unmanaged.md b/assets/chezmoi.io/docs/reference/commands/unmanaged.md index 511bfe7e336..78a49116173 100644 --- a/assets/chezmoi.io/docs/reference/commands/unmanaged.md +++ b/assets/chezmoi.io/docs/reference/commands/unmanaged.md @@ -1,9 +1,9 @@ -# `unmanaged` [*target*...] +# `unmanaged` [*path*...] -List all unmanaged files in *target*s. When no *target*s are supplied, list all +List all unmanaged files in *path*s. When no *path*s are supplied, list all unmanaged files in the destination directory. -It is an error to supply *target*s that are not found on the filesystem. +It is an error to supply *path*s that are not found on the filesystem. !!! example diff --git a/pkg/cmd/managedcmd.go b/pkg/cmd/managedcmd.go index 8c6abbcf846..ca715c9099b 100644 --- a/pkg/cmd/managedcmd.go +++ b/pkg/cmd/managedcmd.go @@ -17,7 +17,7 @@ type managedCmdConfig struct { func (c *Config) newManagedCmd() *cobra.Command { managedCmd := &cobra.Command{ - Use: "managed [paths]...", + Use: "managed [path]...", Aliases: []string{"list"}, Short: "List the managed entries in the destination directory", Long: mustLongHelp("managed"), @@ -36,18 +36,16 @@ func (c *Config) newManagedCmd() *cobra.Command { func (c *Config) runManagedCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error { include := c.managed.include.Sub(c.managed.exclude) - // Build queued paths. When no arguments, start from root; otherwise start - // from arguments. - paths := []chezmoi.RelPath{} - if len(args) != 0 { - for _, arg := range args { - if p, err := chezmoi.NormalizePath(arg); err != nil { - return err - } else if p, err := p.TrimDirPrefix(c.DestDirAbsPath); err != nil { - return err - } else { - paths = append(paths, p) - } + // Build queued relPaths. When there are no arguments, start from root, + // otherwise start from arguments. + var relPaths chezmoi.RelPaths + for _, arg := range args { + if absPath, err := chezmoi.NormalizePath(arg); err != nil { + return err + } else if relPath, err := absPath.TrimDirPrefix(c.DestDirAbsPath); err != nil { + return err + } else { + relPaths = append(relPaths, relPath) } } @@ -61,10 +59,10 @@ func (c *Config) runManagedCmd(cmd *cobra.Command, args []string, sourceState *c return nil } - // when specified arguments, only include paths under these arguments - if len(paths) != 0 { + // When arguments are given, only include paths under these arguments. + if len(relPaths) != 0 { included := false - for _, path := range paths { + for _, path := range relPaths { if targetRelPath.HasDirPrefix(path) || targetRelPath.String() == path.String() { included = true break diff --git a/pkg/cmd/unmanagedcmd.go b/pkg/cmd/unmanagedcmd.go index 94e7bc3d35b..13f3d9c14a7 100644 --- a/pkg/cmd/unmanagedcmd.go +++ b/pkg/cmd/unmanagedcmd.go @@ -13,7 +13,7 @@ import ( func (c *Config) newUnmanagedCmd() *cobra.Command { unmanagedCmd := &cobra.Command{ - Use: "unmanaged [paths]...", + Use: "unmanaged [path]...", Short: "List the unmanaged files in the destination directory", Long: mustLongHelp("unmanaged"), Example: example("unmanaged"), @@ -25,8 +25,25 @@ func (c *Config) newUnmanagedCmd() *cobra.Command { } func (c *Config) runUnmanagedCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error { - // the set of discovered, unmanaged items - unmanaged := map[string]bool{} + var absPaths chezmoi.AbsPaths + if len(args) == 0 { + absPaths = append(absPaths, c.DestDirAbsPath) + } else { + argsAbsPaths := make(map[chezmoi.AbsPath]struct{}) + for _, arg := range args { + argAbsPath, err := chezmoi.NormalizePath(arg) + if err != nil { + return err + } + argsAbsPaths[argAbsPath] = struct{}{} + } + for argAbsPath := range argsAbsPaths { + absPaths = append(absPaths, argAbsPath) + } + sort.Sort(absPaths) + } + + unmanagedRelPaths := make(map[chezmoi.RelPath]struct{}) walkFunc := func(destAbsPath chezmoi.AbsPath, fileInfo fs.FileInfo, err error) error { if err != nil { return err @@ -41,51 +58,27 @@ func (c *Config) runUnmanagedCmd(cmd *cobra.Command, args []string, sourceState managed := sourceState.Contains(targetRelPath) ignored := sourceState.Ignore(targetRelPath) if !managed && !ignored { - unmanaged[targetRelPath.String()] = true + unmanagedRelPaths[targetRelPath] = struct{}{} } if fileInfo.IsDir() && (!managed || ignored) { return vfs.SkipDir } return nil } - - // Build queued paths. When no arguments, start from root; otherwise start - // from arguments. The paths are deduplicated and sorted. - paths := make([]chezmoi.AbsPath, 0, len(args)) // (lsttype, size, capacity) - if len(args) == 0 { - paths = append(paths, c.DestDirAbsPath) - } else { - qPaths := make(map[chezmoi.AbsPath]bool, len(args)) // (map, capacity) - for _, arg := range args { - p, err := chezmoi.NormalizePath(arg) - if err != nil { - return err - } - qPaths[p] = true - } - for path := range qPaths { - paths = append(paths, path) - } - sort.Slice(paths, - func(i, j int) bool { return paths[i].Less(paths[j]) }) - } - - for _, path := range paths { - if err := chezmoi.Walk(c.destSystem, path, walkFunc); err != nil { + for _, absPath := range absPaths { + if err := chezmoi.Walk(c.destSystem, absPath, walkFunc); err != nil { return err } } - // collect the keys and sort builder := strings.Builder{} - unmPaths := make([]string, 0, len(unmanaged)) - for path := range unmanaged { - unmPaths = append(unmPaths, path) + var sortedRelPaths chezmoi.RelPaths + for relPath := range unmanagedRelPaths { + sortedRelPaths = append(sortedRelPaths, relPath) } - sort.Strings(unmPaths) - - for _, path := range unmPaths { - builder.WriteString(path) + sort.Sort(sortedRelPaths) + for _, relPath := range sortedRelPaths { + builder.WriteString(relPath.String()) builder.WriteByte('\n') } return c.writeOutputString(builder.String())
chore
Tidy up managed and unmanaged commands
df18930df0ee9a0205074475dd2e3dc3b32adc53
2024-02-07 15:25:08
Tom Payne
chore: Rename internal module
false
diff --git a/internal/chezmoigit/chezmoigit.go b/internal/chezmoigit/chezmoigit.go new file mode 100644 index 00000000000..791b3405414 --- /dev/null +++ b/internal/chezmoigit/chezmoigit.go @@ -0,0 +1,2 @@ +// Package chezmoigit contains functions for interacting with git. +package chezmoigit diff --git a/internal/git/status.go b/internal/chezmoigit/status.go similarity index 99% rename from internal/git/status.go rename to internal/chezmoigit/status.go index 7d8b5e7a165..6870220c1a5 100644 --- a/internal/git/status.go +++ b/internal/chezmoigit/status.go @@ -1,4 +1,4 @@ -package git +package chezmoigit import ( "bufio" diff --git a/internal/git/status_test.go b/internal/chezmoigit/status_test.go similarity index 99% rename from internal/git/status_test.go rename to internal/chezmoigit/status_test.go index 75a0951a543..ca83916d9bb 100644 --- a/internal/git/status_test.go +++ b/internal/chezmoigit/status_test.go @@ -1,4 +1,4 @@ -package git +package chezmoigit import ( "testing" diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 9e3fc9480bd..27492f294ca 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -27,7 +27,7 @@ import ( "github.com/Masterminds/sprig/v3" "github.com/coreos/go-semver/semver" - gogit "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing/format/diff" "github.com/gregjones/httpcache" "github.com/gregjones/httpcache/diskcache" @@ -51,8 +51,8 @@ import ( "github.com/twpayne/chezmoi/v2/assets/templates" "github.com/twpayne/chezmoi/v2/internal/chezmoi" "github.com/twpayne/chezmoi/v2/internal/chezmoierrors" + "github.com/twpayne/chezmoi/v2/internal/chezmoigit" "github.com/twpayne/chezmoi/v2/internal/chezmoilog" - "github.com/twpayne/chezmoi/v2/internal/git" ) // defaultSentinel is a string value used to indicate that the default value @@ -1436,7 +1436,7 @@ func (c *Config) getTemplateDataMap(cmd *cobra.Command) map[string]any { } // gitAutoAdd adds all changes to the git index and returns the new git status. -func (c *Config) gitAutoAdd() (*git.Status, error) { +func (c *Config) gitAutoAdd() (*chezmoigit.Status, error) { if err := c.run(c.WorkingTreeAbsPath, c.Git.Command, []string{"add", "."}); err != nil { return nil, err } @@ -1444,12 +1444,12 @@ func (c *Config) gitAutoAdd() (*git.Status, error) { if err != nil { return nil, err } - return git.ParseStatusPorcelainV2(output) + return chezmoigit.ParseStatusPorcelainV2(output) } // gitAutoCommit commits all changes in the git index, including generating a // commit message from status. -func (c *Config) gitAutoCommit(cmd *cobra.Command, status *git.Status) error { +func (c *Config) gitAutoCommit(cmd *cobra.Command, status *chezmoigit.Status) error { if status.Empty() { return nil } @@ -1461,7 +1461,7 @@ func (c *Config) gitAutoCommit(cmd *cobra.Command, status *git.Status) error { } // gitAutoPush pushes all changes to the remote if status is not empty. -func (c *Config) gitAutoPush(status *git.Status) error { +func (c *Config) gitAutoPush(status *chezmoigit.Status) error { if status.Empty() { return nil } @@ -1469,7 +1469,7 @@ func (c *Config) gitAutoPush(status *git.Status) error { } // gitCommitMessage returns the git commit message for the given status. -func (c *Config) gitCommitMessage(cmd *cobra.Command, status *git.Status) ([]byte, error) { +func (c *Config) gitCommitMessage(cmd *cobra.Command, status *chezmoigit.Status) ([]byte, error) { funcMap := maps.Clone(c.templateFuncs) maps.Copy(funcMap, map[string]any{ "promptBool": c.promptBoolInteractiveTemplateFunc, @@ -1786,7 +1786,7 @@ func (c *Config) persistentPostRunRootE(cmd *cobra.Command, args []string) error } if annotations.hasTag(modifiesSourceDirectory) { - var status *git.Status + var status *chezmoigit.Status if c.Git.AutoAdd || c.Git.AutoCommit || c.Git.AutoPush { var err error status, err = c.gitAutoAdd() @@ -2088,7 +2088,7 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error workingTreeAbsPath := c.SourceDirAbsPath FOR: for { - gitDirAbsPath := workingTreeAbsPath.JoinString(gogit.GitDirName) + gitDirAbsPath := workingTreeAbsPath.JoinString(git.GitDirName) if _, err := c.baseSystem.Stat(gitDirAbsPath); err == nil { c.WorkingTreeAbsPath = workingTreeAbsPath break FOR diff --git a/internal/cmd/doctorcmd.go b/internal/cmd/doctorcmd.go index 249e5b7c740..88994669200 100644 --- a/internal/cmd/doctorcmd.go +++ b/internal/cmd/doctorcmd.go @@ -25,8 +25,8 @@ import ( "github.com/twpayne/go-xdg/v6" "github.com/twpayne/chezmoi/v2/internal/chezmoi" + "github.com/twpayne/chezmoi/v2/internal/chezmoigit" "github.com/twpayne/chezmoi/v2/internal/chezmoilog" - "github.com/twpayne/chezmoi/v2/internal/git" ) // A checkResult is the result of a check. @@ -583,7 +583,7 @@ func (c *dirCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (c gitStatus = gitStatusError break } - switch status, err := git.ParseStatusPorcelainV2(output); { + switch status, err := chezmoigit.ParseStatusPorcelainV2(output); { case err != nil: gitStatus = gitStatusError case status.Empty(): diff --git a/internal/cmd/generatecmd.go b/internal/cmd/generatecmd.go index 7433cb8e60c..ed6e97b10ca 100644 --- a/internal/cmd/generatecmd.go +++ b/internal/cmd/generatecmd.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" "github.com/twpayne/chezmoi/v2/assets/templates" - "github.com/twpayne/chezmoi/v2/internal/git" + "github.com/twpayne/chezmoi/v2/internal/chezmoigit" ) func (c *Config) newGenerateCmd() *cobra.Command { @@ -36,7 +36,7 @@ func (c *Config) runGenerateCmd(cmd *cobra.Command, args []string) error { if err != nil { return err } - status, err := git.ParseStatusPorcelainV2(output) + status, err := chezmoigit.ParseStatusPorcelainV2(output) if err != nil { return err } diff --git a/internal/git/git.go b/internal/git/git.go deleted file mode 100644 index 09311b6df94..00000000000 --- a/internal/git/git.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package git contains functions for interacting with git. -package git
chore
Rename internal module
9bc4c1b9096459d09caa035347bb16f467cf3385
2025-03-21 04:28:39
Tom Payne
chore: Update tools
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d80ce98f3ba..4b9bc9bc705 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,13 +21,13 @@ env: FIND_TYPOS_VERSION: 0.0.3 # https://github.com/twpayne/find-typos/tags GO_VERSION: 1.24.1 # https://go.dev/doc/devel/release GOFUMPT_VERSION: 0.7.0 # https://github.com/mvdan/gofumpt/releases - GOLANGCI_LINT_VERSION: 1.64.7 # https://github.com/golangci/golangci-lint/releases + GOLANGCI_LINT_VERSION: 1.64.8 # https://github.com/golangci/golangci-lint/releases GOLINES_VERSION: 0.12.2 # https://github.com/segmentio/golines/releases GORELEASER_VERSION: 2.8.1 # https://github.com/goreleaser/goreleaser/releases GOVERSIONINFO_VERSION: 1.4.1 # https://github.com/josephspurrier/goversioninfo/releases PYTHON_VERSION: '3.10' # https://www.python.org/downloads/ RAGE_VERSION: 0.11.1 # https://github.com/str4d/rage/releases - UV_VERSION: 0.6.6 # https://github.com/astral-sh/uv/releases + UV_VERSION: 0.6.9 # https://github.com/astral-sh/uv/releases jobs: changes: runs-on: ubuntu-22.04
chore
Update tools
cd74d0c35b37e7603473117d64069c1a41b9a4d4
2022-04-10 22:55:43
Tom Payne
docs: Document KeepassXC with YubiKey limitations
false
diff --git a/assets/chezmoi.io/docs/user-guide/password-managers/keepassxc.md b/assets/chezmoi.io/docs/user-guide/password-managers/keepassxc.md index 1134c13824a..58903b938c6 100644 --- a/assets/chezmoi.io/docs/user-guide/password-managers/keepassxc.md +++ b/assets/chezmoi.io/docs/user-guide/password-managers/keepassxc.md @@ -25,3 +25,12 @@ called `private-key`, its value is available as: ``` {{ keepassxcAttribute "SSH Key" "private-key" }} ``` + +!!! info + + The KeepassXC CLI does not currently support any persistent login, which + means that you will have to enter your password every time you run chezmoi. + + Support for non-password authentication methods (e.g. YubiKey) is currently + poor. For more information, see [this GitHub + issue](https://github.com/twpayne/chezmoi/issues/2002).
docs
Document KeepassXC with YubiKey limitations
10a0669b756d6b8e1877c3f763d3bcc527d66fa6
2024-06-10 12:44:55
Tom Payne
chore: Ignore whitespace errors in Python virtualenvs
false
diff --git a/internal/cmds/lint-whitespace/main.go b/internal/cmds/lint-whitespace/main.go index a63d51ef7ff..ef530472f0c 100644 --- a/internal/cmds/lint-whitespace/main.go +++ b/internal/cmds/lint-whitespace/main.go @@ -21,6 +21,7 @@ var ( regexp.MustCompile(`\A\.venv\z`), regexp.MustCompile(`\A\.vscode\z`), regexp.MustCompile(`\ACOMMIT\z`), + regexp.MustCompile(`\Aassets/chezmoi\.io/\.venv\z`), regexp.MustCompile(`\Aassets/chezmoi\.io/site\z`), regexp.MustCompile(`\Aassets/scripts/install\.ps1\z`), regexp.MustCompile(`\Acompletions/chezmoi\.ps1\z`),
chore
Ignore whitespace errors in Python virtualenvs
8e6143977777c737fa9b40a0d9e3516def2cfb85
2022-10-20 20:34:28
Tom Payne
docs: Add release history page to reference manual
false
diff --git a/assets/chezmoi.io/.gitignore b/assets/chezmoi.io/.gitignore index a9b0e1bb413..5761d85dcb9 100644 --- a/assets/chezmoi.io/.gitignore +++ b/assets/chezmoi.io/.gitignore @@ -2,6 +2,7 @@ __pycache__ /docs/install.md /docs/links/articles-podcasts-and-videos.md /docs/reference/configuration-file/variables.md +/docs/reference/release-history.md /site /.venv diff --git a/assets/chezmoi.io/docs/hooks.py b/assets/chezmoi.io/docs/hooks.py index d96bfa1fcff..cead9c40455 100644 --- a/assets/chezmoi.io/docs/hooks.py +++ b/assets/chezmoi.io/docs/hooks.py @@ -1,4 +1,5 @@ import os +import os.path import subprocess from mkdocs import utils @@ -13,18 +14,24 @@ ] templates = [ + "index.md", "install.md", "links/articles-podcasts-and-videos.md", "reference/configuration-file/variables.md", + "reference/release-history.md", ] def on_pre_build(config, **kwargs): docs_dir = config['docs_dir'] for src_path in templates: - output = docs_dir + "/" + src_path - template = output + '.tmpl' - data = output + '.yaml' - subprocess.run(['go', 'run', '../../internal/cmds/execute-template', '-data', data, '-output', output, template]) + output_path = docs_dir + "/" + src_path + template_path = output_path + '.tmpl' + data_path = output_path + '.yaml' + args = ['go', 'run', '../../internal/cmds/execute-template'] + if os.path.exists(data_path): + args += ['-data', data_path] + args += ['-output', output_path, template_path] + subprocess.run(args) def on_files(files, config, **kwargs): # remove non-website files @@ -34,7 +41,9 @@ def on_files(files, config, **kwargs): # remove templates and data for src_path in templates: files.remove(files.get_file_from_path(src_path + '.tmpl')) - files.remove(files.get_file_from_path(src_path + '.yaml')) + data_path = src_path + '.yaml' + if data_path in files: + files.remove(files.get_file_from_path(data_path)) return files diff --git a/assets/chezmoi.io/docs/reference/release-history.md.tmpl b/assets/chezmoi.io/docs/reference/release-history.md.tmpl new file mode 100644 index 00000000000..18f92b6cd6e --- /dev/null +++ b/assets/chezmoi.io/docs/reference/release-history.md.tmpl @@ -0,0 +1,17 @@ +# Release history +{{- range $release := gitHubListReleases "twpayne/chezmoi" }} + +## [{{ $release.Name | trimPrefix "v" }}]({{ $release.HTMLURL }}) ({{ $release.PublishedAt | gitHubTimestampFormat "2006-01-02" }}) + +{{ $release.Body + | replaceAllRegex "(?m)^## What's Changed$" "" + | replaceAllRegex "(?m)^## Changelog\\r?$" "" + | replaceAllRegex "(https://github\\.com/twpayne/chezmoi/compare/(\\S+))" "[`$2`]($1)" + | replaceAllRegex "@(\\S+)" "[**$0**](https://github.com/$1)" + | replaceAllRegex "pull request #(\\d+)" "pull request https://github.com/twpayne/chezmoi/pull/$1" + | replaceAllRegex "\\(#(\\d+)[)]" "(https://github.com/twpayne/chezmoi/pull/$1)" + | replaceAllRegex "(https://github\\.com/twpayne/chezmoi/pull/(\\d+))" "[#$2]($1)" + | replaceAllRegex "(?m)^([0-9a-f]{7,})" "* $1" + | replaceAllRegex "(?m)^\\* ([0-9a-f]{7,})" "* [`$1`](https://github.com/twpayne/chezmoi/commit/$1)" +}} +{{- end }} diff --git a/assets/chezmoi.io/mkdocs.yml b/assets/chezmoi.io/mkdocs.yml index d303e4b7ec4..e169fcfa21f 100644 --- a/assets/chezmoi.io/mkdocs.yml +++ b/assets/chezmoi.io/mkdocs.yml @@ -258,6 +258,7 @@ nav: - reference/templates/secret-functions/index.md - secret: reference/templates/secret-functions/secret.md - secretJSON: reference/templates/secret-functions/secretJSON.md + - Release history: reference/release-history.md - Developer: - Developing locally: developer/developing-locally.md - Contributing changes: developer/contributing-changes.md diff --git a/internal/cmds/execute-template/main.go b/internal/cmds/execute-template/main.go index 1229a3371a7..364b25c91f7 100644 --- a/internal/cmds/execute-template/main.go +++ b/internal/cmds/execute-template/main.go @@ -8,10 +8,12 @@ import ( "net/http" "os" "path" + "regexp" "strings" "text/template" "github.com/Masterminds/sprig/v3" + "github.com/google/go-github/v48/github" "github.com/google/renameio/v2/maybe" "gopkg.in/yaml.v3" @@ -23,22 +25,54 @@ var ( outputFilename = flag.String("output", "", "output filename") ) -func gitHubLatestRelease(userRepo string) string { - user, repo, ok := strings.Cut(userRepo, "/") +type gitHubClient struct { + ctx context.Context + client *github.Client +} + +func newGitHubClient(ctx context.Context) *gitHubClient { + return &gitHubClient{ + ctx: ctx, + client: chezmoi.NewGitHubClient(ctx, http.DefaultClient), + } +} + +func (c *gitHubClient) gitHubListReleases(ownerRepo string) []*github.RepositoryRelease { + owner, repo, ok := strings.Cut(ownerRepo, "/") if !ok { - panic(fmt.Errorf("%s: not a user/repo", userRepo)) + panic(fmt.Errorf("%s: not a owner/repo", ownerRepo)) } - ctx := context.Background() + var allRepositoryReleases []*github.RepositoryRelease + opts := &github.ListOptions{ + PerPage: 100, + } + for { + repositoryReleases, resp, err := c.client.Repositories.ListReleases(c.ctx, owner, repo, opts) + if err != nil { + panic(err) + } + allRepositoryReleases = append(allRepositoryReleases, repositoryReleases...) + if resp.NextPage == 0 { + break + } + opts.Page = resp.NextPage + } + return allRepositoryReleases +} - client := chezmoi.NewGitHubClient(ctx, http.DefaultClient) +func (c *gitHubClient) gitHubLatestRelease(ownerRepo string) *github.RepositoryRelease { + owner, repo, ok := strings.Cut(ownerRepo, "/") + if !ok { + panic(fmt.Errorf("%s: not a owner/repo", ownerRepo)) + } - rr, _, err := client.Repositories.GetLatestRelease(ctx, user, repo) + rr, _, err := c.client.Repositories.GetLatestRelease(c.ctx, owner, repo) if err != nil { panic(err) } - return strings.TrimPrefix(rr.GetName(), "v") + return rr } func run() error { @@ -62,7 +96,15 @@ func run() error { templateName := path.Base(flag.Arg(0)) buffer := &bytes.Buffer{} funcMap := sprig.TxtFuncMap() - funcMap["gitHubLatestRelease"] = gitHubLatestRelease + gitHubClient := newGitHubClient(context.Background()) + funcMap["gitHubLatestRelease"] = gitHubClient.gitHubLatestRelease + funcMap["gitHubListReleases"] = gitHubClient.gitHubListReleases + funcMap["gitHubTimestampFormat"] = func(layout string, timestamp github.Timestamp) string { + return timestamp.Format(layout) + } + funcMap["replaceAllRegex"] = func(expr, repl, s string) string { + return regexp.MustCompile(expr).ReplaceAllString(s, repl) + } tmpl, err := template.New(templateName).Funcs(funcMap).ParseFiles(flag.Args()...) if err != nil { return err
docs
Add release history page to reference manual
c8ffaac733c1c7b5131231ffcf8b85f979b4b22d
2025-03-20 06:30:06
Tom Payne
chore: Pre-render license
false
diff --git a/assets/chezmoi.io/docs/docs.go b/assets/chezmoi.io/docs/docs.go index 2bcfa52bf81..3f7e73cb0ed 100644 --- a/assets/chezmoi.io/docs/docs.go +++ b/assets/chezmoi.io/docs/docs.go @@ -6,4 +6,4 @@ import _ "embed" // License is the license. // //go:embed license.md -var License []byte +var License string diff --git a/internal/cmd/license.gen.go b/internal/cmd/license.gen.go new file mode 100644 index 00000000000..28289dcbea5 --- /dev/null +++ b/internal/cmd/license.gen.go @@ -0,0 +1,27 @@ +package cmd + +var license = "" + + "\n" + + " The MIT License (MIT)\n" + + "\n" + + " Copyright (c) 2018-2025 Tom Payne\n" + + "\n" + + " Permission is hereby granted, free of charge, to any person obtaining a copy\n" + + " of this software and associated documentation files (the \"Software\"), to\n" + + " deal in the Software without restriction, including without limitation the\n" + + " rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n" + + " sell copies of the Software, and to permit persons to whom the Software is\n" + + " furnished to do so, subject to the following conditions:\n" + + "\n" + + " The above copyright notice and this permission notice shall be included in\n" + + " all copies or substantial portions of the Software.\n" + + "\n" + + " THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n" + + " IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" + + " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n" + + " AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n" + + " LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n" + + " FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n" + + " IN THE SOFTWARE.\n" + + "\n" + + "" diff --git a/internal/cmd/licensecmd.go b/internal/cmd/licensecmd.go index d859d88f855..8314b7cf5b5 100644 --- a/internal/cmd/licensecmd.go +++ b/internal/cmd/licensecmd.go @@ -1,13 +1,7 @@ package cmd import ( - "bytes" - - "github.com/charmbracelet/glamour" - "github.com/charmbracelet/glamour/styles" "github.com/spf13/cobra" - - "github.com/twpayne/chezmoi/v2/assets/chezmoi.io/docs" ) func (c *Config) newLicenseCmd() *cobra.Command { @@ -28,19 +22,5 @@ func (c *Config) newLicenseCmd() *cobra.Command { } func (c *Config) runLicenseCmd(cmd *cobra.Command, args []string) error { - renderer, err := glamour.NewTermRenderer( - glamour.WithStyles(styles.ASCIIStyleConfig), - glamour.WithWordWrap(80), - ) - if err != nil { - return err - } - - licenseMarkdown := bytes.TrimPrefix(docs.License, []byte("# License\n\n")) - license, err := renderer.RenderBytes(licenseMarkdown) - if err != nil { - return err - } - - return c.writeOutput(license) + return c.writeOutputString(license) } diff --git a/internal/cmds/generate-license/license.go.tmpl b/internal/cmds/generate-license/license.go.tmpl new file mode 100644 index 00000000000..f658c9d82a7 --- /dev/null +++ b/internal/cmds/generate-license/license.go.tmpl @@ -0,0 +1,4 @@ +package cmd + +var license = "" + + {{ . | splitAndQuoteLines }} diff --git a/internal/cmds/generate-license/main.go b/internal/cmds/generate-license/main.go new file mode 100644 index 00000000000..04a269fd06b --- /dev/null +++ b/internal/cmds/generate-license/main.go @@ -0,0 +1,92 @@ +package main + +// FIXME merge this with internal/cmds/generate-helps + +import ( + "bytes" + _ "embed" + "flag" + "fmt" + "go/format" + "os" + "strconv" + "strings" + "text/template" + "unicode" + + "github.com/charmbracelet/glamour" + "github.com/charmbracelet/glamour/styles" + + "github.com/twpayne/chezmoi/v2/assets/chezmoi.io/docs" +) + +//go:embed license.go.tmpl +var licenseGoTmpl string + +var output = flag.String("o", "", "output") + +func run() error { + flag.Parse() + + renderer, err := glamour.NewTermRenderer( + glamour.WithStyles(styles.ASCIIStyleConfig), + glamour.WithWordWrap(80), + ) + if err != nil { + return err + } + + licenseMarkdown := strings.TrimPrefix(docs.License, "# License\n\n") + license, err := renderer.Render(licenseMarkdown) + if err != nil { + return err + } + + licenseGoTemplate, err := template.New("license.go.tmpl").Funcs(template.FuncMap{ + "splitAndQuoteLines": func(s string) string { + lines := strings.Split(s, "\n") + quotedLines := make([]string, len(lines)) + for i, line := range lines { + line = strings.TrimRightFunc(line, unicode.IsSpace) + if i == len(lines)-1 { + quotedLines[i] = strconv.Quote(line) + } else { + quotedLines[i] = strconv.Quote(line + "\n") + } + } + return strings.Join(quotedLines, " +\n") + }, + }).Parse(licenseGoTmpl) + if err != nil { + return err + } + + var buffer bytes.Buffer + if err := licenseGoTemplate.ExecuteTemplate(&buffer, "license.go.tmpl", license); err != nil { + return err + } + + outputBytes := buffer.Bytes() + if formattedOutput, err := format.Source(outputBytes); err == nil { + outputBytes = formattedOutput + } + + if *output == "" || *output == "-" { + if _, err := os.Stdout.Write(outputBytes); err != nil { + return err + } + } else { + if err := os.WriteFile(*output, outputBytes, 0o666); err != nil { + return err + } + } + + return nil +} + +func main() { + if err := run(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/main.go b/main.go index 7d8ee29f83f..82b8c2476c9 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,5 @@ //go:generate go run ./internal/cmds/generate-helps -o internal/cmd/helps.gen.go +//go:generate go run ./internal/cmds/generate-license -o internal/cmd/license.gen.go //go:generate go run . completion bash -o completions/chezmoi-completion.bash //go:generate go run . completion fish -o completions/chezmoi.fish //go:generate go run . completion powershell -o completions/chezmoi.ps1
chore
Pre-render license
b0ea806146a10f298fc7d5e95351d9f1798b20e9
2022-03-24 15:11:16
Tom Payne
chore: Tidy up 1Password docs
false
diff --git a/assets/chezmoi.io/docs/reference/templates/functions/onepassword.md b/assets/chezmoi.io/docs/reference/templates/functions/onepassword.md index d22ce4f5c5c..6c5dd851d7d 100644 --- a/assets/chezmoi.io/docs/reference/templates/functions/onepassword.md +++ b/assets/chezmoi.io/docs/reference/templates/functions/onepassword.md @@ -2,14 +2,15 @@ `onepassword` returns structured data from [1Password](https://1password.com/) using the [1Password -CLI](https://support.1password.com/command-line-getting-started/) (`op`). *uuid* -is passed to `op item get $UUID --format json` and the output from `op`. The -output from `op` is cached so calling `onepassword` multiple times with the same -*uuid* will only invoke `op` once. If the optional *vault-uuid* is supplied, it -will be passed along to the `op item get` call, which can significantly improve -performance. If the optional *account-name* is supplied, it will be passed along -to the `op item get` call, which will help it look in the right account, in case -you have multiple accounts (e.g., personal and work accounts). +CLI](https://support.1password.com/command-line-getting-started/) (`op`). +*uuid* is passed to `op item get $UUID --format json` and the output from `op` +is parsed as JSON. The output from `op` is cached so calling `onepassword` +multiple times with the same *uuid* will only invoke `op` once. If the optional +*vault-uuid* is supplied, it will be passed along to the `op item get` call, +which can significantly improve performance. If the optional *account-name* is +supplied, it will be passed along to the `op item get` call, which will help it +look in the right account, in case you have multiple accounts (e.g., personal +and work accounts). If there is no valid session in the environment, by default you will be interactively prompted to sign in. @@ -27,11 +28,13 @@ interactively prompted to sign in. ``` {{ range (onepassword "$UUID").fields -}} - {{- if and (eq .label "password") (eq .purpose "PASSWORD") }}{{ .value }}{{ end -}} - {{- end }} + {{ if and (eq .label "password") (eq .purpose "PASSWORD") -}} + {{ .value -}} + {{ end -}} + {{ end }} ``` - ??? info + !!! info For 1Password CLI 1.x. @@ -54,7 +57,7 @@ interactively prompted to sign in. the other functions. Testing the output of this function is recommended: ```console - chezmoi execute-template "{{- onepassword \"$UUID\" | toJson -}}" | jq . + $ chezmoi execute-template "{{ onepassword \"$UUID\" | toJson }}" | jq . ``` !!! warning @@ -65,13 +68,6 @@ interactively prompted to sign in. using *account-name*, it is recommended that you use the *account-uuid*. This can be found using `op account list`. - This issue does not exist when using biometric authentication and 1Password + This issue does not occur when using biometric authentication and 1Password 8, or if you allow chezmoi to prompt you for 1Password authentication (`1password.prompt = true`). - -!!! info - - In earlier versions of chezmoi, if *vault-uuid* or *account-name* were - empty strings, they would be added to the resulting `op` command-line - (`--vault ''`). This causes errors in 1Password CLI 2.0, so those arguments - will no longer be added. diff --git a/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDetailsFields.md b/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDetailsFields.md index 339cbbf2fd8..88b71b986f9 100644 --- a/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDetailsFields.md +++ b/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDetailsFields.md @@ -13,7 +13,7 @@ times with the same *uuid* will only invoke `op` once. If the optional *vault-uuid* is supplied, it will be passed along to the `op get` call, which can significantly improve performance. If the optional *account-name* is supplied, it will be passed along to the `op get` call, which will help it look -in the right account, in case you have multiple accounts (e.g., personal and +in the right account, in case you have multiple accounts (e.g. personal and work accounts). !!! example @@ -81,7 +81,7 @@ work accounts). function is recommended: ```console - chezmoi execute-template "{{- onepasswordDetailsFields \"$UUID\" | toJson -}}" | jq . + $ chezmoi execute-template "{{ onepasswordDetailsFields \"$UUID\" | toJson }}" | jq . ``` !!! warning @@ -92,13 +92,6 @@ work accounts). using *account-name*, it is recommended that you use the *account-uuid*. This can be found using `op account list`. - This issue does not exist when using biometric authentication and 1Password + This issue does not occur when using biometric authentication and 1Password 8, or if you allow chezmoi to prompt you for 1Password authentication (`1password.prompt = true`). - -!!! info - - In earlier versions of chezmoi, if *vault-uuid* or *account-name* were - empty strings, they would be added to the resulting `op` command-line - (`--vault ''`). This causes errors in 1Password CLI 2.0, so those arguments - will no longer be added. diff --git a/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDocument.md b/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDocument.md index 9fbed7f6f65..5e402a98764 100644 --- a/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDocument.md +++ b/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDocument.md @@ -2,16 +2,16 @@ `onepasswordDocument` returns a document from [1Password](https://1password.com/) using the [1Password -CLI](https://support.1password.com/command-line-getting-started/) (`op`). *uuid* -is passed to `op get document $UUID` and the output from `op` is returned. The -output from `op` is cached so calling `onepasswordDocument` multiple times with -the same *uuid* will only invoke `op` once. If the optional *vault-uuid* is -supplied, it will be passed along to the `op get` call, which can significantly -improve performance. If the optional *account-name* is supplied, it will be -passed along to the `op get` call, which will help it look in the right account, -in case you have multiple accounts (e.g., personal and work accounts). If there -is no valid session in the environment, by default you will be interactively -prompted to sign in. +CLI](https://support.1password.com/command-line-getting-started/) (`op`). +*uuid* is passed to `op get document $UUID` and the output from `op` is +returned. The output from `op` is cached so calling `onepasswordDocument` +multiple times with the same *uuid* will only invoke `op` once. If the optional +*vault-uuid* is supplied, it will be passed along to the `op get` call, which +can significantly improve performance. If the optional *account-name* is +supplied, it will be passed along to the `op get` call, which will help it look +in the right account, in case you have multiple accounts (e.g., personal and +work accounts). If there is no valid session in the environment, by default you +will be interactively prompted to sign in. !!! example @@ -31,13 +31,6 @@ prompted to sign in. recommended that you use the *account-uuid*. This can be found using `op account list`. - This issue does not exist when using biometric authentication and 1Password + This issue does not occur when using biometric authentication and 1Password 8, or if you allow chezmoi to prompt you for 1Password authentication (`1password.prompt = true`). - -!!! info - - In earlier versions of chezmoi, if *vault-uuid* or *account-name* were - empty strings, they would be added to the resulting `op` command-line - (`--vault ''`). This causes errors in 1Password CLI 2.0, so those arguments - will no longer be added. diff --git a/assets/chezmoi.io/docs/reference/templates/functions/onepasswordItemFields.md b/assets/chezmoi.io/docs/reference/templates/functions/onepasswordItemFields.md index 2da73414462..916f2f166af 100644 --- a/assets/chezmoi.io/docs/reference/templates/functions/onepasswordItemFields.md +++ b/assets/chezmoi.io/docs/reference/templates/functions/onepasswordItemFields.md @@ -1,8 +1,8 @@ -# `onepasswordItemFields` _uuid_ [_vault-uuid_ [*account-name*]] +# `onepasswordItemFields` *uuid* [*vault-uuid* [*account-name*]] `onepasswordItemFields` returns structured data from [1Password](https://1password.com/) using the [1Password -CLI](https://support.1password.com/command-line-getting-started/) (`op`). _uuid_ +CLI](https://support.1password.com/command-line-getting-started/) (`op`). *uuid* is passed to `op item get $UUID --format json`, the output from `op` is parsed as JSON, and each element of `details.sections` are iterated over and any `fields` are returned as a map indexed by each field's `n`. @@ -26,7 +26,7 @@ interactively prompted to sign in. $ op item get abcdefghijklmnopqrstuvwxyz --fields exampleLabel ``` - ??? info + !!! info For 1Password CLI 1.x. @@ -85,7 +85,7 @@ interactively prompted to sign in. } ``` - ??? info + !!! info For 1Password CLI 1.x, the output is this: @@ -139,7 +139,7 @@ interactively prompted to sign in. this function is recommended: ```console - chezmoi execute-template "{{- onepasswordItemFields \"$UUID\" | toJson -}}" | jq . + $ chezmoi execute-template "{{ onepasswordItemFields \"$UUID\" | toJson }}" | jq . ``` !!! warning @@ -150,13 +150,6 @@ interactively prompted to sign in. using *account-name*, it is recommended that you use the *account-uuid*. This can be found using `op account list`. - This issue does not exist when using biometric authentication and 1Password + This issue does not occur when using biometric authentication and 1Password 8, or if you allow chezmoi to prompt you for 1Password authentication (`1password.prompt = true`). - -!!! info - - In earlier versions of chezmoi, if *vault-uuid* or *account-name* were - empty strings, they would be added to the resulting `op` command-line - (`--vault ''`). This causes errors in 1Password CLI 2.0, so those arguments - will no longer be added. diff --git a/assets/chezmoi.io/docs/user-guide/password-managers/1password.md b/assets/chezmoi.io/docs/user-guide/password-managers/1password.md index f6b7807adfe..6c72b8ef20f 100644 --- a/assets/chezmoi.io/docs/user-guide/password-managers/1password.md +++ b/assets/chezmoi.io/docs/user-guide/password-managers/1password.md @@ -6,22 +6,24 @@ expose data as a template function. !!! note - [1Password CLI 2.0](https://developer.1password.com/) has been released. + The[1Password CLI 2.0](https://developer.1password.com/) has been released. Examples will be shown using the changed details for this version and examples for 1Password CLI 1.x will follow. Log in and get a session using: ```console -# For 1Password 2.x. Neither step is necessary with biometric authentication. $ op account add --address $SUBDOMAIN.1password.com --email $EMAIL $ eval $(op signin --account $SUBDOMAIN) ``` -??? info +This is not necessary if you are using biometric authentication. + +!!! info + + For 1Password CLI 1.x, use: ```console - # For 1Password 1.x $ eval $(op signin $SUBDOMAIN.1password.com $EMAIL) ``` @@ -80,11 +82,13 @@ or: ``` {{ range (onepassword "$UUID").fields -}} -{{- if and (eq .label "password") (eq .purpose "PASSWORD") }}{{ .value }}{{ end -}} -{{- end }} +{{ if and (eq .label "password") (eq .purpose "PASSWORD") -}} +{{ .value -}} +{{ end -}} +{{ end }} ``` -??? info +!!! info 1Password CLI 1.x returns a simpler structure: @@ -134,10 +138,10 @@ allows the fields to be queried by key: ``` Additional fields may be obtained with `onePasswordItemFields`; not all objects -in 1Password have item fields, so it is worth testing before using: +in 1Password have item fields. This can be tested with: ```console -chezmoi execute-template "{{- onepasswordItemFields \"$UUID\" | toJson -}}" | jq . +$ chezmoi execute-template "{{ onepasswordItemFields \"$UUID\" | toJson }}" | jq . ``` Documents can be retrieved with: @@ -153,15 +157,15 @@ Documents can be retrieved with: substitution. This removes any trailing newline added by your editor when saving the template. -## 1Password sign-in prompt +## Sign-in prompt chezmoi will verify the availability and validity of a session token in the current environment. If it is missing or expired, you will be interactively prompted to sign-in again. In the past chezmoi used to simply exit with an error when no valid session was -available. If you'd like to restore that behavior, set the following option in -your configuration file: +available. If you'd like to restore this behavior, set the the +`onepassword.prompt` configuration variable to `false`, for example: ```toml title="~/.config/chezmoi/chezmoi.toml" [onepassword] @@ -171,13 +175,5 @@ your configuration file: !!! danger Do not use the prompt on shared machines. A session token verified or - acquired interactively will be passed to the 1Password CLI through a command - line parameter, which is visible to other users of the same system. - -!!! info - - If you're using [1Password CLI - 2.0](https://developer.1password.com/docs/cli/), then the structure of the - data returned by the `onepassword`, `onepasswordDetailsFields`, and - `onePasswordItemFiles` template functions is different and templates will - need to be updated. + acquired interactively will be passed to the 1Password CLI through a + command line parameter, which is visible to other users of the same system.
chore
Tidy up 1Password docs
1d215784c9f54d21bde1996b537320547882f90e
2022-02-23 05:29:07
Tom Payne
chore: Use quotes more consistently
false
diff --git a/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.yaml b/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.yaml index 8e82e5fb263..9df8c876567 100644 --- a/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.yaml +++ b/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.yaml @@ -24,22 +24,22 @@ articles: url: 'https://fedoramagazine.org/take-back-your-dotfiles-with-chezmoi/' - date: '2020-04-17' version: '1.7.17' - lang: "CN" + lang: 'CN' title: '用 Chezmoi 取回你的点文件' url: 'https://blog.csdn.net/F8qG7f9YD02Pe/article/details/105548429' - date: '2020-04-16' version: '1.7.19' - lang: "FR" + lang: 'FR' title: 'Chezmoi, visite guidée' url: 'https://blog.wescale.fr/2020/04/16/chezmoi-visite-guidee/' - date: '2020-04-19' version: '1.7.19' - lang: "FR" + lang: 'FR' title: 'Git & dotfiles : versionner ses fichiers de configuration' url: 'https://www.armandphilippot.com/dotfiles-git-fichiers-configuration/' - date: '2020-04-20' version: '1.8.0' - lang: "FR" + lang: 'FR' title: 'Gestion des dotfiles et des secrets avec chezmoi' url: 'https://blog.arkey.fr/2020/04/01/manage_dotfiles_with_chezmoi.fr/' - date: '2020-04-27' @@ -93,9 +93,9 @@ articles: url: 'https://www.moncefbelyamani.com/automating-the-setup-of-a-new-mac-with-all-your-apps-preferences-and-development-tools/' - date: '2021-01-29' version: '1.8.10' - lang: "CN" - title: "用 Chezmoi 管理配置文件" - url: "https://axionl.me/p/%E5%BD%92%E6%A1%A3-%E7%94%A8-chezmoi-%E7%AE%A1%E7%90%86%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6/" + lang: 'CN' + title: '用 Chezmoi 管理配置文件' + url: 'https://axionl.me/p/%E5%BD%92%E6%A1%A3-%E7%94%A8-chezmoi-%E7%AE%A1%E7%90%86%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6/' - date: '2021-02-06' version: '1.8.10' format: Video @@ -103,12 +103,12 @@ articles: url: 'https://fosdem.org/2021/schedule/event/chezmoi/' - date: '2021-02-07' version: '1.8.10' - lang: "JP" + lang: 'JP' title: 'chezmoi始めた' url: 'https://joe-noh.hatenablog.com/entry/2021/02/07/215733' - date: '2021-02-17' version: '1.8.11' - lang: "JP" + lang: 'JP' title: 'chezmoi で dotfiles を手軽に柔軟にセキュアに管理する' url: 'https://zenn.dev/ryo_kawamata/articles/introduce-chezmoi' - date: '2021-04-01' @@ -117,7 +117,7 @@ articles: url: 'https://johnmathews.is/chezmoi.html' - date: '2021-04-08' version: '2.0.9' - lang: "FR" + lang: 'FR' title: 'Bienvenue chez moi' url: 'https://blogduyax.madyanne.fr/2021/bienvenue-chez-moi/' - date: '2021-05-10' @@ -134,7 +134,7 @@ articles: url: 'https://jonathanbartlett.co.uk/2021/05/14/a-brief-history-of-my-dotfiles.html' - date: '2021-07-15' version: '2.1.2' - lang: "CN" + lang: 'CN' title: '使用Chezmoi管理配置文件' url: 'https://marvinsblog.net/post/2021-07-15-chezmoi-intro/' - date: '2021-07-23' @@ -144,7 +144,7 @@ articles: url: 'https://www.podfeet.com/blog/2021/07/ccatp-693/' - date: '2021-08-04' version: '2.1.2' - lang: "PT" + lang: 'PT' title: 'Como instalar o Chezmoi, um gerenciador de dotfiles, no Ubuntu, Linux Mint, Fedora, Debian' url: 'https://sempreupdate.com.br/como-instalar-o-chezmoi-um-gerenciador-de-dotfiles-no-ubuntu-linux-mint-fedora-debian/' - date: '2021-08-08' @@ -190,7 +190,7 @@ articles: url: 'https://medium.com/@josemrivera/share-credentials-across-machines-using-chezmoi-and-bitwarden-4069dcb6e367' - date: '2021-10-26' version: '2.7.3' - lang: "RU" + lang: 'RU' title: 'Синхронизация системных настроек' url: 'https://habr.com/en/post/585578/' - date: '2021-11-23' @@ -204,7 +204,7 @@ articles: - date: '2021-11-27' version: '2.8.0' format: 'Video' - lang: "TH" + lang: 'TH' title: 'Command ไร 2021-11-27 : ย้าย dotfiles ไป chezmoi' url: 'https://www.youtube.com/watch?v=8ybNfCfnF2Y' - date: '2021-12-01' @@ -234,17 +234,17 @@ articles: url: 'https://www.wazaterm.com/blog/advent-calendar-2021/use-chezmoi-to-guarantee-idempotency-of-terminal' - date: '2022-01-12' version: '2.9.5' - lang: "IT" + lang: 'IT' title: 'Come funzionano i miei Mac' url: 'https://correntedebole.com/come-funzionano-i-miei-mac/' - date: '2022-01-26' version: '2.10.1' - lang: "JP" + lang: 'JP' title: 'chezmoi で dotfiles を管理する' url: 'https://blog.zoncoen.net/2022/01/26/chezmoi/' - date: '2022-02-01' version: '2.10.1' - lang: "JP" + lang: 'JP' title: 'chezmoi で dotfiles を手軽に柔軟にセキュアに管理する' url: 'https://zenn.dev/ryo_kawamata/articles/introduce-chezmoi' - date: '2022-02-02'
chore
Use quotes more consistently
027e3294900c6d33a32e99378da4147b43c855ac
2024-04-04 00:17:11
dependabot[bot]
chore(deps): bump the actions group with 3 updates
false
diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index f2b3aa78727..3a0a7570e9d 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -16,11 +16,11 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - name: go-version id: go-version run: | echo go-version="$(awk '/GO_VERSION:/ { print $2 }' .github/workflows/main.yml | tr -d \')" >> "${GITHUB_OUTPUT}" - - uses: golang/govulncheck-action@7da72f730e37eeaad891fcff0a532d27ed737cd4 + - uses: golang/govulncheck-action@3a32958c2706f7048305d5a2e53633d7e37e97d0 with: go-version-input: ${{ steps.go-version.outputs.go-version }} diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml index a48376be63a..7dc55d39d80 100644 --- a/.github/workflows/installer.yml +++ b/.github/workflows/installer.yml @@ -17,7 +17,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - id: filter uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 with: @@ -36,7 +36,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: reviewdog/action-misspell@5bd7be2fc7ae56a517184f5c4bbcf2fd7afe3927 with: locale: US @@ -50,7 +50,7 @@ jobs: env: BINARY: ${{ matrix.os == 'windows-2022' && 'bin/chezmoi.exe' || 'bin/chezmoi' }} steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - name: test-${{ matrix.os }}-local shell: bash run: | @@ -73,7 +73,7 @@ jobs: env: BINARY: ${{ matrix.os == 'windows-2022' && 'bin/chezmoi.exe' || 'bin/chezmoi' }} steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - name: test-${{ matrix.os }}-local shell: pwsh run: | diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1b5a5474642..310b4d1ef4a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - id: filter uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 with: @@ -56,19 +56,19 @@ jobs: permissions: security-events: write steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 with: fetch-depth: 1 - - uses: github/codeql-action/init@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 + - uses: github/codeql-action/init@1b1aada464948af03b950897e5eb522f92603cc2 with: languages: go - - uses: github/codeql-action/analyze@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 + - uses: github/codeql-action/analyze@1b1aada464948af03b950897e5eb522f92603cc2 misspell: runs-on: ubuntu-22.04 permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: reviewdog/action-misspell@5bd7be2fc7ae56a517184f5c4bbcf2fd7afe3927 with: locale: US @@ -79,7 +79,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - name: test env: CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} @@ -92,7 +92,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - name: test env: CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} @@ -105,7 +105,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: go-version: ${{ env.GO_VERSION }} @@ -140,7 +140,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: go-version: oldstable @@ -173,7 +173,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 with: fetch-depth: 0 - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 @@ -238,7 +238,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 with: fetch-depth: 0 - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 @@ -280,7 +280,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: go-version: ${{ env.GO_VERSION }} @@ -298,7 +298,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: go-version: ${{ env.GO_VERSION }} @@ -324,7 +324,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 with: fetch-depth: 0 - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 @@ -372,7 +372,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: go-version: ${{ env.GO_VERSION }} @@ -414,7 +414,7 @@ jobs: run: snapcraft whoami env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 with: fetch-depth: 0 - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 @@ -442,7 +442,7 @@ jobs: permissions: contents: write steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 with: fetch-depth: 0 - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
chore
bump the actions group with 3 updates
2eaeceb3691eb3c0dda5f3ecb16c35eefd027999
2024-11-14 05:33:38
Tom Payne
chore: Update tools
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9f7fc3f070f..5b5f4540371 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ concurrency: env: ACTIONLINT_VERSION: 1.7.4 # https://github.com/rhysd/actionlint/releases AGE_VERSION: 1.2.0 # https://github.com/FiloSottile/age/releases - CHOCOLATEY_VERSION: 2.3.0 # https://github.com/chocolatey/choco/releases + CHOCOLATEY_VERSION: 2.4.0 # https://github.com/chocolatey/choco/releases EDITORCONFIG_CHECKER_VERSION: 3.0.3 # https://github.com/editorconfig-checker/editorconfig-checker/releases FIND_TYPOS_VERSION: 0.0.3 # https://github.com/twpayne/find-typos/tags GO_VERSION: 1.23.3 # https://go.dev/doc/devel/release @@ -27,7 +27,7 @@ env: GOVERSIONINFO_VERSION: 1.4.1 # https://github.com/josephspurrier/goversioninfo/releases PYTHON_VERSION: '3.10' # https://www.python.org/downloads/ RAGE_VERSION: 0.11.0 # https://github.com/str4d/rage/releases - UV_VERSION: 0.4.30 # https://github.com/astral-sh/uv/releases + UV_VERSION: 0.5.1 # https://github.com/astral-sh/uv/releases jobs: changes: runs-on: ubuntu-22.04
chore
Update tools
33e409b0a5a19a6b75b770310daa8ad7f1d9e46f
2023-03-21 17:20:33
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 3c23b0058b8..5da5f96ae33 100644 --- a/assets/chezmoi.io/docs/links/links.yaml +++ b/assets/chezmoi.io/docs/links/links.yaml @@ -394,3 +394,8 @@ articles: version: 2.31.0 title: Managing dotfiles with chezmoi url: https://moesgaard.dev/posts/2023-02-26-managing-dotfiles-with-chezmoi/ +- date: '2023-03-21' + version: 2.32.0 + title: AWS CLI のプロファイルを chezmoi とBitwarden で管理する + lang: JP + url: https://zenn.dev/nh8939/articles/8a6a4f5eb967a9
docs
Add link to article
d2ca5f0331f896b9500d26bd2edf65de4832582a
2024-04-06 15:08:21
Tom Payne
chore: re-enable lock-threads GitHub Action
false
diff --git a/.github/workflows/lock-threads.yml b/.github/workflows/lock-threads.yml index c3c07d4f4fd..966072b68fd 100644 --- a/.github/workflows/lock-threads.yml +++ b/.github/workflows/lock-threads.yml @@ -1,9 +1,8 @@ name: lock-threads on: - # FIXME renable when https://github.com/dessant/lock-threads/issues/47 is fixed - #schedule: - #- cron: 17 2 * * * + schedule: + - cron: 17 2 * * * workflow_dispatch: {} permissions: @@ -19,6 +18,7 @@ jobs: steps: - uses: dessant/lock-threads@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771 with: + process-only: 'issues, prs' issue-lock-reason: resolved issue-inactive-days: 7 pr-lock-reason: resolved
chore
re-enable lock-threads GitHub Action
6916263f9d9ecd0134c1692f04367f2383d78c5c
2024-11-08 20:37:14
Tom Payne
feat: Add --path-style=all option to managed command
false
diff --git a/assets/chezmoi.io/docs/reference/commands/managed.md b/assets/chezmoi.io/docs/reference/commands/managed.md index b57f5ad907a..d18842de9cf 100644 --- a/assets/chezmoi.io/docs/reference/commands/managed.md +++ b/assets/chezmoi.io/docs/reference/commands/managed.md @@ -10,6 +10,10 @@ the destination directory in alphabetical order. --8<-- "common-flags/exclude.md" +### `-f`, `--format` `json`|`yaml` + +--8<-- "common-flags/format.md" + ### `-i`, `--include` *types* --8<-- "common-flags/include.md" diff --git a/assets/chezmoi.io/snippets/common-flags/path-style.md b/assets/chezmoi.io/snippets/common-flags/path-style.md index 8ccd52380e9..b91a8f9acb9 100644 --- a/assets/chezmoi.io/snippets/common-flags/path-style.md +++ b/assets/chezmoi.io/snippets/common-flags/path-style.md @@ -9,4 +9,5 @@ Print paths in the given style. The default is `relative`. --8<-- [end:no-source-tree] | `source-absolute` | Absolute paths in the source tree directory | | `source-relative` | Relative paths to the source tree directory | +| `all` | All path styles, indexed by relative | --8<-- [end:all] diff --git a/internal/chezmoi/relpath.go b/internal/chezmoi/relpath.go index f36d41aa5ea..6ddcb817042 100644 --- a/internal/chezmoi/relpath.go +++ b/internal/chezmoi/relpath.go @@ -89,9 +89,9 @@ func (p RelPath) Less(other RelPath) bool { return p.relPath < other.relPath } -// MarshalJSON implements encoding.TextMarshaler.MarshalJSON. -func (p RelPath) MarshalJSON() ([]byte, error) { - return FormatJSON.Marshal(p.relPath) +// MarshalText implements encoding.TextMarshaler.MarshalText. +func (p RelPath) MarshalText() ([]byte, error) { + return []byte(p.relPath), nil } // Slice returns a part of p. diff --git a/internal/chezmoi/sourcerelpath.go b/internal/chezmoi/sourcerelpath.go index e942b233422..3e26e4fd503 100644 --- a/internal/chezmoi/sourcerelpath.go +++ b/internal/chezmoi/sourcerelpath.go @@ -61,6 +61,11 @@ func (p SourceRelPath) Less(other SourceRelPath) bool { return p.relPath.Less(other.relPath) } +// MarshalText implements encoding.TextMarshaler.MarshalText. +func (p SourceRelPath) MarshalText() ([]byte, error) { + return []byte(p.relPath.String()), nil +} + // RelPath returns p as a relative path. func (p SourceRelPath) RelPath() RelPath { return p.relPath diff --git a/internal/cmd/config.go b/internal/cmd/config.go index a69b69cf479..fe3e0986801 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -381,6 +381,7 @@ func newConfig(options ...configOption) (*Config, error) { }, managed: managedCmdConfig{ filter: chezmoi.NewEntryTypeFilter(chezmoi.EntryTypesAll, chezmoi.EntryTypesNone), + format: newChoiceFlag(formatJSON, writeDataFormatValues), pathStyle: newChoiceFlag(pathStyleRelative, sourceOrTargetPathStyleValues), }, mergeAll: mergeAllCmdConfig{ diff --git a/internal/cmd/managedcmd.go b/internal/cmd/managedcmd.go index 9df9c6cb1e3..3d4064a8f2b 100644 --- a/internal/cmd/managedcmd.go +++ b/internal/cmd/managedcmd.go @@ -1,6 +1,7 @@ package cmd import ( + "cmp" "fmt" "github.com/spf13/cobra" @@ -10,6 +11,7 @@ import ( type managedCmdConfig struct { filter *chezmoi.EntryTypeFilter + format *choiceFlag pathStyle *choiceFlag tree bool } @@ -29,6 +31,7 @@ func (c *Config) newManagedCmd() *cobra.Command { } managedCmd.Flags().VarP(c.managed.filter.Exclude, "exclude", "x", "Exclude entry types") + managedCmd.Flags().VarP(c.managed.format, "format", "f", "Format") managedCmd.Flags().VarP(c.managed.filter.Include, "include", "i", "Include entry types") managedCmd.Flags().VarP(c.managed.pathStyle, "path-style", "p", "Path style") must(managedCmd.RegisterFlagCompletionFunc("path-style", c.managed.pathStyle.FlagCompletionFunc())) @@ -51,7 +54,13 @@ func (c *Config) runManagedCmd(cmd *cobra.Command, args []string, sourceState *c } } - var paths []fmt.Stringer + type entryPaths struct { + targetRelPath chezmoi.RelPath + Absolute chezmoi.AbsPath `json:"absolute" yaml:"absolute"` + SourceAbsolute chezmoi.AbsPath `json:"sourceAbsolute" yaml:"sourceAbsolute"` + SourceRelative chezmoi.SourceRelPath `json:"sourceRelative" yaml:"sourceRelative"` + } + var allEntryPaths []*entryPaths _ = sourceState.ForEach( func(targetRelPath chezmoi.RelPath, sourceStateEntry chezmoi.SourceStateEntry) error { if !c.managed.filter.IncludeSourceStateEntry(sourceStateEntry) { @@ -80,25 +89,42 @@ func (c *Config) runManagedCmd(cmd *cobra.Command, args []string, sourceState *c } } - var path fmt.Stringer - switch pathStyle := c.managed.pathStyle.String(); pathStyle { - case pathStyleAbsolute: - path = c.DestDirAbsPath.Join(targetRelPath) - case pathStyleRelative: - path = targetRelPath - case pathStyleSourceAbsolute: - path = c.SourceDirAbsPath.Join(sourceStateEntry.SourceRelPath().RelPath()) - case pathStyleSourceRelative: - path = sourceStateEntry.SourceRelPath().RelPath() - default: - return fmt.Errorf("%s: invalid path style", pathStyle) + entryPaths := &entryPaths{ + targetRelPath: targetRelPath, + Absolute: c.DestDirAbsPath.Join(targetRelPath), + SourceAbsolute: c.SourceDirAbsPath.Join(sourceStateEntry.SourceRelPath().RelPath()), + SourceRelative: sourceStateEntry.SourceRelPath(), } - paths = append(paths, path) + allEntryPaths = append(allEntryPaths, entryPaths) return nil }, ) - return c.writePaths(stringersToStrings(paths), writePathsOptions{ - tree: c.managed.tree, - }) + switch pathStyle := c.managed.pathStyle.String(); pathStyle { + case pathStyleAbsolute, pathStyleRelative, pathStyleSourceAbsolute, pathStyleSourceRelative: + paths := make([]string, len(allEntryPaths)) + for i, structuredPath := range allEntryPaths { + switch c.managed.pathStyle.String() { + case pathStyleAbsolute: + paths[i] = structuredPath.Absolute.String() + case pathStyleRelative: + paths[i] = structuredPath.targetRelPath.String() + case pathStyleSourceAbsolute: + paths[i] = structuredPath.SourceAbsolute.String() + case pathStyleSourceRelative: + paths[i] = structuredPath.SourceRelative.String() + } + } + return c.writePaths(paths, writePathsOptions{ + tree: c.managed.tree, + }) + case pathStyleAll: + allEntryPathsMap := make(map[string]*entryPaths, len(allEntryPaths)) + for _, entryPaths := range allEntryPaths { + allEntryPathsMap[entryPaths.targetRelPath.String()] = entryPaths + } + return c.marshal(cmp.Or(c.managed.format.String(), c.Format.String()), allEntryPathsMap) + default: + return fmt.Errorf("%s: invalid path style", pathStyle) + } } diff --git a/internal/cmd/pathstyle.go b/internal/cmd/pathstyle.go index 485258ef42a..ebf474887bf 100644 --- a/internal/cmd/pathstyle.go +++ b/internal/cmd/pathstyle.go @@ -5,6 +5,7 @@ const ( pathStyleRelative = "relative" pathStyleSourceAbsolute = "source-absolute" pathStyleSourceRelative = "source-relative" + pathStyleAll = "all" ) var ( @@ -13,6 +14,7 @@ var ( pathStyleRelative, pathStyleSourceAbsolute, pathStyleSourceRelative, + pathStyleAll, } targetPathStyleValues = []string{ pathStyleAbsolute, diff --git a/internal/cmd/testdata/scripts/completion.txtar b/internal/cmd/testdata/scripts/completion.txtar index a8c3c8e66fc..31a5d1c3893 100644 --- a/internal/cmd/testdata/scripts/completion.txtar +++ b/internal/cmd/testdata/scripts/completion.txtar @@ -140,6 +140,7 @@ relative :4 -- golden/path-style-with-source -- absolute +all relative source-absolute source-relative diff --git a/internal/cmd/testdata/scripts/managed.txtar b/internal/cmd/testdata/scripts/managed.txtar index 743c792bbb7..d6c2790bde1 100644 --- a/internal/cmd/testdata/scripts/managed.txtar +++ b/internal/cmd/testdata/scripts/managed.txtar @@ -78,6 +78,14 @@ chhome home2/user exec chezmoi managed --include=all cmp stdout golden/managed2 +# test chezmoi managed --path-style=all +[!windows] exec chezmoi managed --path-style=all +[!windows] cmpenv stdout golden/managed-all.json + +# test chezmoi managed --path-style=all --format=yaml +[!windows] exec chezmoi managed --path-style=all --format=yaml +[!windows] cmpenv stdout golden/managed-all.yaml + -- golden/managed -- .create .dir @@ -108,6 +116,55 @@ $WORK/home/user/.readonly $WORK/home/user/.remove $WORK/home/user/.symlink $WORK/home/user/.template +-- golden/managed-all.json -- +{ + ".create": { + "absolute": "$WORK/home2/user/.create", + "sourceAbsolute": "$WORK/home2/user/.local/share/chezmoi/create_dot_create.tmpl", + "sourceRelative": "create_dot_create.tmpl" + }, + ".file": { + "absolute": "$WORK/home2/user/.file", + "sourceAbsolute": "$WORK/home2/user/.local/share/chezmoi/modify_dot_file.tmpl", + "sourceRelative": "modify_dot_file.tmpl" + }, + ".symlink": { + "absolute": "$WORK/home2/user/.symlink", + "sourceAbsolute": "$WORK/home2/user/.local/share/chezmoi/symlink_dot_symlink.tmpl", + "sourceRelative": "symlink_dot_symlink.tmpl" + }, + ".template": { + "absolute": "$WORK/home2/user/.template", + "sourceAbsolute": "$WORK/home2/user/.local/share/chezmoi/dot_template.tmpl", + "sourceRelative": "dot_template.tmpl" + }, + "script": { + "absolute": "$WORK/home2/user/script", + "sourceAbsolute": "$WORK/home2/user/.local/share/chezmoi/run_script.tmpl", + "sourceRelative": "run_script.tmpl" + } +} +-- golden/managed-all.yaml -- +.create: + absolute: $WORK/home2/user/.create + sourceAbsolute: $WORK/home2/user/.local/share/chezmoi/create_dot_create.tmpl + sourceRelative: create_dot_create.tmpl +.file: + absolute: $WORK/home2/user/.file + sourceAbsolute: $WORK/home2/user/.local/share/chezmoi/modify_dot_file.tmpl + sourceRelative: modify_dot_file.tmpl +.symlink: + absolute: $WORK/home2/user/.symlink + sourceAbsolute: $WORK/home2/user/.local/share/chezmoi/symlink_dot_symlink.tmpl + sourceRelative: symlink_dot_symlink.tmpl +.template: + absolute: $WORK/home2/user/.template + sourceAbsolute: $WORK/home2/user/.local/share/chezmoi/dot_template.tmpl + sourceRelative: dot_template.tmpl +script: + absolute: $WORK/home2/user/script + sourceAbsolute: $WORK/home2/user/.local/share/chezmoi/run_script.tmpl + sourceRelative: run_script.tmpl -- golden/managed-exclude-encrypted -- .create .dir
feat
Add --path-style=all option to managed command
552d2556aa4b53ecd2677f9ef811376c42fc6c8e
2023-08-06 22:12:18
Tom Payne
chore: Update dependencies
false
diff --git a/go.mod b/go.mod index 965046482dc..584029a9394 100644 --- a/go.mod +++ b/go.mod @@ -44,9 +44,9 @@ require ( github.com/zalando/go-keyring v0.2.3 go.etcd.io/bbolt v1.3.7 go.uber.org/multierr v1.11.0 - golang.org/x/crypto v0.11.0 + golang.org/x/crypto v0.12.0 golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b - golang.org/x/oauth2 v0.10.0 + golang.org/x/oauth2 v0.11.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.11.0 golang.org/x/term v0.11.0 @@ -133,7 +133,7 @@ require ( github.com/yuin/goldmark v1.5.5 // indirect github.com/yuin/goldmark-emoji v1.0.2 // indirect golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.13.0 // indirect + golang.org/x/net v0.14.0 // indirect golang.org/x/text v0.12.0 // indirect golang.org/x/tools v0.11.1 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index d5198034e9c..94bb2d4046f 100644 --- a/go.sum +++ b/go.sum @@ -374,8 +374,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI= golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -391,10 +391,10 @@ golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfS golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.13.0 h1:Nvo8UFsZ8X3BhAC9699Z1j7XQ3rsZnUUm7jfBEk1ueY= -golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= -golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= -golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/oauth2 v0.11.0 h1:vPL4xzxBM4niKCW6g9whtaWVXTJf1U5e4aZxxFx/gbU= +golang.org/x/oauth2 v0.11.0/go.mod h1:LdF7O/8bLR/qWK9DrpXmbHLTouvRHK0SgJl0GmDBchk= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
chore
Update dependencies
6ad68f9a9570d0f59e3c5aa0e8c232186cb6f369
2022-02-12 06:10:18
Tom Payne
docs: Add link to article
false
diff --git a/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.yaml b/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.yaml index 7fcc5d816bd..03c8076dcd4 100644 --- a/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.yaml +++ b/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.yaml @@ -184,6 +184,10 @@ articles: format: Audio/text title: 'PBS 125 of X — Chezmoi on Multiple Computers' url: 'https://pbs.bartificer.net/pbs125' +- date: '2021-10-25' + version: '2.7.3' + title: 'Share credentials across machines using chezmoi and bitwarden' + url: 'https://medium.com/@josemrivera/share-credentials-across-machines-using-chezmoi-and-bitwarden-4069dcb6e367' - date: '2021-10-26' version: '2.7.3' lang: "RU" @@ -248,3 +252,7 @@ articles: lang: 'FR' title: 'Controler ses dotfiles en environnement éphémère' url: 'https://blog.wescale.fr/2022/02/02/controler-ses-dotfiles-en-environnement-ephemere-2/' +- date: '2022-02-12' + version: '2.11.2' + title: 'How To Manage Dotfiles With Chezmoi' + url: 'https://betterprogramming.pub/how-to-manage-dotfiles-with-chezmoi-53cadb36b226'
docs
Add link to article
a33efdc0d661bb9302177478ddf9b7d2cbd6ae5a
2023-02-01 15:51:47
dependabot[bot]
chore(deps): bump actions/cache from 3.2.2 to 3.2.4
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 46c0e510762..c50252a6633 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -86,7 +86,7 @@ jobs: runs-on: macos-12 steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d + - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 with: path: ~/.vagrant.d key: ${{ runner.os }}-vagrant-debian-i386-${{ hashFiles('assets/vagrant/debian11-i386.Vagrantfile') }} @@ -112,7 +112,7 @@ jobs: runs-on: macos-12 steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d + - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 with: path: ~/.vagrant.d key: ${{ runner.os }}-vagrant-freebsd13-${{ hashFiles('assets/vagrant/freebsd13.Vagrantfile') }} @@ -304,7 +304,7 @@ jobs: with: cache: true go-version: ${{ env.GO_VERSION }} - - uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d + - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
chore
bump actions/cache from 3.2.2 to 3.2.4
132d18431695881539e0601b2b0795379035d95b
2022-07-14 03:12:19
Tom Payne
fix: Fix FQDN hostname on FreeBSD
false
diff --git a/pkg/chezmoi/chezmoi.go b/pkg/chezmoi/chezmoi.go index 8c4fbdfe76d..68574e29cd7 100644 --- a/pkg/chezmoi/chezmoi.go +++ b/pkg/chezmoi/chezmoi.go @@ -2,16 +2,20 @@ package chezmoi import ( + "bufio" "bytes" "crypto/sha256" "fmt" "io" "io/fs" + "os" "path/filepath" "regexp" + "runtime" "strings" "github.com/spf13/cobra" + vfs "github.com/twpayne/go-vfs/v4" ) var ( @@ -72,6 +76,8 @@ var ( `\A(after|before|create|dot|empty|encrypted|executable|literal|modify|once|private|readonly|remove|run|symlink)_`, ) fileSuffixRegexp = regexp.MustCompile(`\.(literal|tmpl)\z`) + + whitespaceRx = regexp.MustCompile(`\s+`) ) // knownPrefixedFiles is a set of known filenames with the .chezmoi prefix. @@ -116,6 +122,36 @@ var modeTypeNames = map[fs.FileMode]string{ fs.ModeCharDevice: "char device", } +// FQDNHostname returns the FQDN hostname. +func FQDNHostname(fileSystem vfs.FS) (string, error) { + // First, try os.Hostname. If it returns something that looks like a FQDN + // hostname, or we're on Windows, return it. + osHostname, err := os.Hostname() + if runtime.GOOS == "windows" || (err == nil && strings.Contains(osHostname, ".")) { + return osHostname, err + } + + // Otherwise, if we're on OpenBSD, try /etc/myname. + if runtime.GOOS == "openbsd" { + if fqdnHostname, err := etcMynameFQDNHostname(fileSystem); err == nil && fqdnHostname != "" { + return fqdnHostname, nil + } + } + + // Otherwise, try /etc/hosts. + if fqdnHostname, err := etcHostsFQDNHostname(fileSystem); err == nil && fqdnHostname != "" { + return fqdnHostname, nil + } + + // Otherwise, try /etc/hostname. + if fqdnHostname, err := etcHostnameFQDNHostname(fileSystem); err == nil && fqdnHostname != "" { + return fqdnHostname, nil + } + + // Finally, fall back to whatever os.Hostname returned. + return osHostname, err +} + // FlagCompletionFunc returns a flag completion function. func FlagCompletionFunc(allCompletions []string) func(*cobra.Command, []string, string) ( []string, cobra.ShellCompDirective, @@ -159,6 +195,62 @@ func SuspiciousSourceDirEntry(base string, fileInfo fs.FileInfo, encryptedSuffix } } +// etcHostnameFQDNHostname returns the FQDN hostname from parsing /etc/hostname. +func etcHostnameFQDNHostname(fileSystem vfs.FS) (string, error) { + contents, err := fileSystem.ReadFile("/etc/hostname") + if err != nil { + return "", err + } + s := bufio.NewScanner(bytes.NewReader(contents)) + for s.Scan() { + text := s.Text() + text, _, _ = CutString(text, "#") + if hostname := strings.TrimSpace(text); hostname != "" { + return hostname, nil + } + } + return "", s.Err() +} + +// etcMynameFQDNHostname returns the FQDN hostname from parsing /etc/myname. +// See OpenBSD's myname(5) for details on this file. +func etcMynameFQDNHostname(fileSystem vfs.FS) (string, error) { + contents, err := fileSystem.ReadFile("/etc/myname") + if err != nil { + return "", err + } + s := bufio.NewScanner(bytes.NewReader(contents)) + for s.Scan() { + text := s.Text() + if strings.HasPrefix(text, "#") { + continue + } + if hostname := strings.TrimSpace(text); hostname != "" { + return hostname, nil + } + } + return "", s.Err() +} + +// etcHostsFQDNHostname returns the FQDN hostname from parsing /etc/hosts. +func etcHostsFQDNHostname(fileSystem vfs.FS) (string, error) { + contents, err := fileSystem.ReadFile("/etc/hosts") + if err != nil { + return "", err + } + s := bufio.NewScanner(bytes.NewReader(contents)) + for s.Scan() { + text := s.Text() + text = strings.TrimSpace(text) + text, _, _ = CutString(text, "#") + fields := whitespaceRx.Split(text, -1) + if len(fields) >= 2 && fields[0] == "127.0.1.1" { + return fields[1], nil + } + } + return "", s.Err() +} + // isEmpty returns true if data is empty after trimming whitespace from both // ends. func isEmpty(data []byte) bool { diff --git a/pkg/chezmoi/chezmoi_test.go b/pkg/chezmoi/chezmoi_test.go index 858c016d295..a47e93b546a 100644 --- a/pkg/chezmoi/chezmoi_test.go +++ b/pkg/chezmoi/chezmoi_test.go @@ -2,10 +2,15 @@ package chezmoi import ( "os" + "testing" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/rs/zerolog/pkgerrors" + "github.com/stretchr/testify/assert" + "github.com/twpayne/go-vfs/v4" + + "github.com/twpayne/chezmoi/v2/pkg/chezmoitest" ) func init() { @@ -15,3 +20,88 @@ func init() { }) zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack } + +func TestEtcHostsFQDNHostname(t *testing.T) { + for _, tc := range []struct { + name string + root interface{} + f func(vfs.FS) (string, error) + expected string + }{ + { + name: "etc_hosts", + root: map[string]interface{}{ + "/etc/hosts": chezmoitest.JoinLines( + `# The following lines are desirable for IPv4 capable hosts`, + `127.0.0.1 localhost`, + ``, + `# 127.0.1.1 is often used for the FQDN of the machine`, + `127.0.1.1 thishost.mydomain.org thishost`, + `192.168.1.10 foo.mydomain.org foo`, + `192.168.1.13 bar.mydomain.org bar`, + `146.82.138.7 master.debian.org master`, + `209.237.226.90 www.opensource.org`, + ``, + `# The following lines are desirable for IPv6 capable hosts`, + `::1 localhost ip6-localhost ip6-loopback`, + `ff02::1 ip6-allnodes`, + `ff02::2 ip6-allrouters`, + ), + }, + f: etcHostsFQDNHostname, + expected: "thishost.mydomain.org", + }, + { + name: "etc_hosts_whitespace_and_comments", + root: map[string]interface{}{ + "/etc/hosts": chezmoitest.JoinLines( + " \t127.0.1.1 \tthishost.mydomain.org# comment", + ), + }, + f: etcHostsFQDNHostname, + expected: "thishost.mydomain.org", + }, + { + name: "etc_hosts_missing_canonical_hostname", + root: map[string]interface{}{ + "/etc/hosts": chezmoitest.JoinLines( + `127.0.1.1`, + `127.0.1.1 thishost.mydomain.org`, + ), + }, + f: etcHostsFQDNHostname, + expected: "thishost.mydomain.org", + }, + { + name: "etc_hostname", + root: map[string]interface{}{ + "/etc/hostname": chezmoitest.JoinLines( + `# comment`, + ` hostname.example.com # comment`, + ), + }, + f: etcHostnameFQDNHostname, + expected: "hostname.example.com", + }, + { + name: "etc_myname", + root: map[string]interface{}{ + "/etc/myname": chezmoitest.JoinLines( + "# comment", + "", + "hostname.example.com", + ), + }, + f: etcMynameFQDNHostname, + expected: "hostname.example.com", + }, + } { + t.Run(tc.name, func(t *testing.T) { + chezmoitest.WithTestFS(t, tc.root, func(fileSystem vfs.FS) { + fqdnHostname, err := tc.f(fileSystem) + assert.NoError(t, err) + assert.Equal(t, tc.expected, fqdnHostname) + }) + }) + } +} diff --git a/pkg/chezmoi/chezmoi_unix.go b/pkg/chezmoi/chezmoi_unix.go index 5913b867017..2271189ea6c 100644 --- a/pkg/chezmoi/chezmoi_unix.go +++ b/pkg/chezmoi/chezmoi_unix.go @@ -4,96 +4,16 @@ package chezmoi import ( - "bufio" - "bytes" "io/fs" - "regexp" - "runtime" - "strings" - vfs "github.com/twpayne/go-vfs/v4" "golang.org/x/sys/unix" ) -var whitespaceRx = regexp.MustCompile(`\s+`) - func init() { Umask = fs.FileMode(unix.Umask(0)) unix.Umask(int(Umask)) } -// FQDNHostname returns the FQDN hostname, if it can be determined. -func FQDNHostname(fileSystem vfs.FS) string { - if fqdnHostname, err := etcHostsFQDNHostname(fileSystem); err == nil && fqdnHostname != "" { - return fqdnHostname - } - if runtime.GOOS == "openbsd" { - if fqdnHostname, err := etcMynameFQDNHostname(fileSystem); err == nil && fqdnHostname != "" { - return fqdnHostname - } - } - if fqdnHostname, err := etcHostnameFQDNHostname(fileSystem); err == nil && fqdnHostname != "" { - return fqdnHostname - } - return "" -} - -// etcHostnameFQDNHostname returns the FQDN hostname from parsing /etc/hostname. -func etcHostnameFQDNHostname(fileSystem vfs.FS) (string, error) { - contents, err := fileSystem.ReadFile("/etc/hostname") - if err != nil { - return "", err - } - s := bufio.NewScanner(bytes.NewReader(contents)) - for s.Scan() { - text := s.Text() - text, _, _ = CutString(text, "#") - if hostname := strings.TrimSpace(text); hostname != "" { - return hostname, nil - } - } - return "", s.Err() -} - -// etcMynameFQDNHostname returns the FQDN hostname from parsing /etc/myname. -// See OpenBSD's myname(5) for details on this file. -func etcMynameFQDNHostname(fileSystem vfs.FS) (string, error) { - contents, err := fileSystem.ReadFile("/etc/myname") - if err != nil { - return "", err - } - s := bufio.NewScanner(bytes.NewReader(contents)) - for s.Scan() { - text := s.Text() - if strings.HasPrefix(text, "#") { - continue - } - if hostname := strings.TrimSpace(text); hostname != "" { - return hostname, nil - } - } - return "", s.Err() -} - -// etcHostsFQDNHostname returns the FQDN hostname from parsing /etc/hosts. -func etcHostsFQDNHostname(fileSystem vfs.FS) (string, error) { - contents, err := fileSystem.ReadFile("/etc/hosts") - if err != nil { - return "", err - } - s := bufio.NewScanner(bytes.NewReader(contents)) - for s.Scan() { - text := s.Text() - text = strings.TrimSpace(text) - text, _, _ = CutString(text, "#") - fields := whitespaceRx.Split(text, -1) - if len(fields) >= 2 && fields[0] == "127.0.1.1" { - return fields[1], nil - } - } - return "", s.Err() -} - // isExecutable returns if fileInfo is executable. func isExecutable(fileInfo fs.FileInfo) bool { return fileInfo.Mode().Perm()&0o111 != 0 diff --git a/pkg/chezmoi/chezmoi_unix_test.go b/pkg/chezmoi/chezmoi_unix_test.go index 63bf80fbaf0..c5ac159ef99 100644 --- a/pkg/chezmoi/chezmoi_unix_test.go +++ b/pkg/chezmoi/chezmoi_unix_test.go @@ -4,109 +4,13 @@ package chezmoi import ( - "runtime" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - vfs "github.com/twpayne/go-vfs/v4" "github.com/twpayne/chezmoi/v2/pkg/chezmoitest" ) -func TestFQDNHostname(t *testing.T) { - for _, tc := range []struct { - name string - goos string - root interface{} - expected string - }{ - { - name: "empty", - }, - { - name: "etc_hosts", - root: map[string]interface{}{ - "/etc/hosts": chezmoitest.JoinLines( - `# The following lines are desirable for IPv4 capable hosts`, - `127.0.0.1 localhost`, - ``, - `# 127.0.1.1 is often used for the FQDN of the machine`, - `127.0.1.1 thishost.mydomain.org thishost`, - `192.168.1.10 foo.mydomain.org foo`, - `192.168.1.13 bar.mydomain.org bar`, - `146.82.138.7 master.debian.org master`, - `209.237.226.90 www.opensource.org`, - ``, - `# The following lines are desirable for IPv6 capable hosts`, - `::1 localhost ip6-localhost ip6-loopback`, - `ff02::1 ip6-allnodes`, - `ff02::2 ip6-allrouters`, - ), - }, - expected: "thishost.mydomain.org", - }, - { - name: "etc_hosts_whitespace_and_comments", - root: map[string]interface{}{ - "/etc/hosts": chezmoitest.JoinLines( - " \t127.0.1.1 \tthishost.mydomain.org# comment", - ), - }, - expected: "thishost.mydomain.org", - }, - { - name: "etc_hosts_missing_canonical_hostname", - root: map[string]interface{}{ - "/etc/hosts": chezmoitest.JoinLines( - `127.0.1.1`, - `127.0.1.1 thishost.mydomain.org`, - ), - }, - expected: "thishost.mydomain.org", - }, - { - name: "etc_hostname", - root: map[string]interface{}{ - "/etc/hostname": chezmoitest.JoinLines( - `# comment`, - ` hostname.example.com # comment`, - ), - }, - expected: "hostname.example.com", - }, - { - name: "etc_hosts_and_etc_hostname", - root: map[string]interface{}{ - "/etc/hosts": "127.0.1.1 hostname.example.com hostname\n", - "/etc/hostname": "hostname\n", - }, - expected: "hostname.example.com", - }, - { - name: "etc_myname", - goos: "openbsd", - root: map[string]interface{}{ - "/etc/myname": chezmoitest.JoinLines( - "# comment", - "", - "hostname.example.com", - ), - }, - expected: "hostname.example.com", - }, - } { - t.Run(tc.name, func(t *testing.T) { - if tc.goos != "" && runtime.GOOS != tc.goos { - t.Skipf("skipping %s test on %s", tc.goos, runtime.GOOS) - } - chezmoitest.WithTestFS(t, tc.root, func(fileSystem vfs.FS) { - assert.Equal(t, tc.expected, FQDNHostname(fileSystem)) - }) - }) - } -} - func TestUmask(t *testing.T) { require.Equal(t, chezmoitest.Umask, Umask) } diff --git a/pkg/chezmoi/chezmoi_windows.go b/pkg/chezmoi/chezmoi_windows.go index d350e77373a..359281df077 100644 --- a/pkg/chezmoi/chezmoi_windows.go +++ b/pkg/chezmoi/chezmoi_windows.go @@ -1,30 +1,9 @@ package chezmoi import ( - "errors" "io/fs" - "unicode/utf16" - - vfs "github.com/twpayne/go-vfs/v4" - "golang.org/x/sys/windows" ) -// FQDNHostname returns the machine's fully-qualified DNS domain name, if -// available. -func FQDNHostname(fileSystem vfs.FS) string { - n := uint32(windows.MAX_COMPUTERNAME_LENGTH + 1) - buf := make([]uint16, n) - err := windows.GetComputerNameEx(windows.ComputerNameDnsFullyQualified, &buf[0], &n) - if errors.Is(err, windows.ERROR_MORE_DATA) { - buf = make([]uint16, n) - err = windows.GetComputerNameEx(windows.ComputerNameDnsFullyQualified, &buf[0], &n) - } - if err != nil { - return "" - } - return string(utf16.Decode(buf[0:n])) -} - // isExecutable returns false on Windows. func isExecutable(fileInfo fs.FileInfo) bool { return false diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index 82b068cf127..0c5e73a88d0 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -960,16 +960,13 @@ func (c *Config) defaultTemplateData() map[string]interface{} { } } - fqdnHostname := chezmoi.FQDNHostname(c.fileSystem) - - var hostname string - if rawHostname, err := os.Hostname(); err == nil { - hostname, _, _ = chezmoi.CutString(rawHostname, ".") - } else { + fqdnHostname, err := chezmoi.FQDNHostname(c.fileSystem) + if err != nil { c.logger.Info(). Err(err). - Msg("os.Hostname") + Msg("chezmoi.FQDNHostname") } + hostname, _, _ := chezmoi.CutString(fqdnHostname, ".") kernel, err := chezmoi.Kernel(c.fileSystem) if err != nil {
fix
Fix FQDN hostname on FreeBSD
33e11606b50f770d4780f480ac98770a2c10e855
2021-10-26 02:26:15
Tom Payne
chore: Refine GitHub Actions changes detection
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9f3f6a7ff92..8170510d6f3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,7 @@ jobs: changes: runs-on: ubuntu-20.04 outputs: - go: ${{ steps.filter.output.go }} + code: ${{ steps.filter.output.code }} steps: - name: Checkout uses: actions/checkout@v2 @@ -23,12 +23,13 @@ jobs: uses: dorny/paths-filter@v2 with: filters: | - go: + code: - '**/*.go' - 'go.*' + - 'internal/**' test-archlinux: needs: changes - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' runs-on: ubuntu-20.04 steps: - name: Checkout @@ -38,7 +39,7 @@ jobs: ( cd assets/docker && ./test.sh archlinux ) test-debian-i386: needs: changes - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' runs-on: macos-10.15 env: VAGRANT_BOX: debian11-i386 @@ -57,7 +58,7 @@ jobs: ( cd assets/vagrant && ./test.sh debian11-i386 ) test-fedora: needs: changes - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' runs-on: ubuntu-20.04 steps: - name: Checkout @@ -67,7 +68,7 @@ jobs: ( cd assets/docker && ./test.sh fedora ) test-freebsd: needs: changes - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' runs-on: macos-10.15 env: VAGRANT_BOX: freebsd13 @@ -86,7 +87,7 @@ jobs: ( cd assets/vagrant && ./test.sh freebsd13 ) test-macos: needs: changes - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' runs-on: macos-11 steps: - name: Set up Go @@ -119,7 +120,7 @@ jobs: go test -race ./... test-openbsd: needs: changes - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' runs-on: macos-10.15 env: VAGRANT_BOX: openbsd6 @@ -138,7 +139,7 @@ jobs: ( cd assets/vagrant && ./test.sh openbsd6 ) test-openindiana: needs: changes - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' runs-on: macos-10.15 env: VAGRANT_BOX: openindiana @@ -164,7 +165,7 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - name: Install age - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' 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 - @@ -188,26 +189,26 @@ jobs: run: | go run . --version - name: Test (umask 022) - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' run: | go test -ldflags="-X github.com/twpayne/chezmoi/internal/chezmoitest.umaskStr=0o022" -race ./... - name: Test (umask 002) - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' run: | go test -ldflags="-X github.com/twpayne/chezmoi/internal/chezmoitest.umaskStr=0o002" -race ./... - name: Install release dependencies - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' run: | sudo apt-get update sudo apt-get -yq --no-install-suggests --no-install-recommends install musl-tools snapcraft - name: Build release - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' uses: goreleaser/goreleaser-action@v2 with: version: latest args: release --skip-publish --snapshot - name: Test release - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' run: | # verify that version information is embedded correctly file ./dist/chezmoi-cgo-glibc_linux_amd64/chezmoi | tee /dev/stderr | grep -q "dynamically linked" @@ -216,50 +217,50 @@ jobs: ./dist/chezmoi-cgo-musl_linux_amd64/chezmoi --version | tee /dev/stderr | grep -q "chezmoi version v2" ./dist/chezmoi-nocgo_linux_386/chezmoi --version | tee /dev/stderr | grep -q "chezmoi version v2" - name: Upload artifact chezmoi-darwin-amd64 - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' uses: actions/upload-artifact@v2 with: name: chezmoi-darwin-amd64 path: dist/chezmoi-nocgo_darwin_amd64/chezmoi - name: Upload artifact chezmoi-darwin-arm64 - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' uses: actions/upload-artifact@v2 with: name: chezmoi-darwin-arm64 path: dist/chezmoi-nocgo_darwin_arm64/chezmoi - name: Upload artifact chezmoi-illumos-amd64 - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' uses: actions/upload-artifact@v2 with: name: chezmoi-illumos-amd64 path: dist/chezmoi-nocgo_illumos_amd64/chezmoi - name: Upload artifact chezmoi-linux-amd64 - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' uses: actions/upload-artifact@v2 with: name: chezmoi-linux-amd64 path: dist/chezmoi-cgo-glibc_linux_amd64/chezmoi - name: Upload artifact chezmoi-linux-musl-amd64 - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' uses: actions/upload-artifact@v2 with: name: chezmoi-linux-musl-amd64 path: dist/chezmoi-cgo-musl_linux_amd64/chezmoi - name: Upload artifact chezmoi-solaris-amd64 - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' uses: actions/upload-artifact@v2 with: name: chezmoi-solaris-amd64 path: dist/chezmoi-nocgo_solaris_amd64/chezmoi - name: Upload artifact chezmoi-windows-amd64.exe - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' uses: actions/upload-artifact@v2 with: name: chezmoi-windows-amd64.exe path: dist/chezmoi-nocgo_windows_amd64/chezmoi.exe test-ubuntu-go1-16: needs: changes - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' runs-on: ubuntu-18.04 steps: - name: Set up Go @@ -292,7 +293,7 @@ jobs: go test ./... test-windows: needs: changes - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' runs-on: windows-2019 steps: - name: Set up Go @@ -336,7 +337,7 @@ jobs: go test -race ./... test-voidlinux: needs: changes - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' runs-on: ubuntu-20.04 steps: - name: Checkout @@ -377,7 +378,7 @@ jobs: findtypos -format=github-actions chezmoi . lint: needs: changes - if: needs.changes.outputs.go == 'true' + if: needs.changes.outputs.code == 'true' runs-on: ubuntu-18.04 steps: - name: Checkout
chore
Refine GitHub Actions changes detection
c96a4b779c76b63e8573133795b8528eaacbb81d
2023-09-21 23:32:25
Austin Ziegler
docs: Fix cross-function link references
false
diff --git a/assets/chezmoi.io/docs/reference/templates/github-functions/gitHubLatestTag.md b/assets/chezmoi.io/docs/reference/templates/github-functions/gitHubLatestTag.md index e6c695a153b..34154755801 100644 --- a/assets/chezmoi.io/docs/reference/templates/github-functions/gitHubLatestTag.md +++ b/assets/chezmoi.io/docs/reference/templates/github-functions/gitHubLatestTag.md @@ -5,7 +5,7 @@ bindings](https://pkg.go.dev/github.com/google/go-github/v55/github#RepositoryTag). Calls to `gitHubLatestTag` are cached the same as -[`githubTags`](/reference/templates/functions/gitHubTags.md), so calling +[`githubTags`](/reference/templates/functions/gitHubTags/), so calling `gitHubLatestTag` with the same *owner-repo* will only result in one call to the GitHub API. diff --git a/assets/chezmoi.io/docs/reference/templates/github-functions/gitHubReleases.md b/assets/chezmoi.io/docs/reference/templates/github-functions/gitHubReleases.md index 3d348f83799..33f5fe36edb 100644 --- a/assets/chezmoi.io/docs/reference/templates/github-functions/gitHubReleases.md +++ b/assets/chezmoi.io/docs/reference/templates/github-functions/gitHubReleases.md @@ -22,7 +22,7 @@ Calls to `gitHubReleases` are cached so calling `gitHubReleases` with the same !!! warning The values returned by `gitHubReleases` are not directly queryable via the - [`jq`](/reference/templates/functions/jq.md) function and must instead be + [`jq`](/reference/templates/functions/jq/) function and must instead be converted through JSON: ``` diff --git a/assets/chezmoi.io/docs/reference/templates/github-functions/gitHubTags.md b/assets/chezmoi.io/docs/reference/templates/github-functions/gitHubTags.md index 72066811240..0ec076305e2 100644 --- a/assets/chezmoi.io/docs/reference/templates/github-functions/gitHubTags.md +++ b/assets/chezmoi.io/docs/reference/templates/github-functions/gitHubTags.md @@ -22,7 +22,7 @@ same *owner-repo* will only result in one call to the GitHub API. !!! warning The values returned by `gitHubTags` are not directly queryable via the - [`jq`](/reference/templates/functions/jq.md) function and must instead be + [`jq`](/reference/templates/functions/jq/) function and must instead be converted through JSON: ```
docs
Fix cross-function link references
3bf71faebff7b023cd55dc9dae8387947aad5811
2022-02-06 22:35:46
Tom Payne
chore: Generate articles, podcasts, and videos doc from template with data
false
diff --git a/assets/chezmoi.io/.gitignore b/assets/chezmoi.io/.gitignore index 9596906b18b..85f070598a6 100644 --- a/assets/chezmoi.io/.gitignore +++ b/assets/chezmoi.io/.gitignore @@ -1,2 +1,3 @@ __pycache__ +/docs/links/articles-podcasts-and-videos.md /site diff --git a/assets/chezmoi.io/docs/hooks.py b/assets/chezmoi.io/docs/hooks.py index b95dd4adee2..c3013c959ac 100644 --- a/assets/chezmoi.io/docs/hooks.py +++ b/assets/chezmoi.io/docs/hooks.py @@ -1,17 +1,45 @@ import os -import shutil +import subprocess + +from mkdocs import utils +from mkdocs.structure.files import File + +non_website_paths = [ + "hooks.py", + "reference/commands/commands.go", + "reference/commands/commands_test.go", +] + +templates = [ + "links/articles-podcasts-and-videos.md", +] + +def on_pre_build(config, **kwargs): + docs_dir = config['docs_dir'] + for src_path in templates: + output = docs_dir + "/" + src_path + template = output + '.tmpl' + data = output + '.yaml' + subprocess.run(['go', 'run', '../../internal/cmds/execute-template', '-data', data, '-output', output, template]) + +def on_files(files, config, **kwargs): + # remove non-website files + for src_path in non_website_paths: + files.remove(files.get_file_from_path(src_path)) + + # remove templates and data + for src_path in templates: + files.remove(files.get_file_from_path(src_path + '.tmpl')) + files.remove(files.get_file_from_path(src_path + '.yaml')) + + return files def on_post_build(config, **kwargs): site_dir = config['site_dir'] # copy GitHub pages config - shutil.copy('CNAME', os.path.join(site_dir, 'CNAME')) + utils.copy_file('CNAME', os.path.join(site_dir, 'CNAME')) # copy installation scripts - shutil.copy('../scripts/install.sh', os.path.join(site_dir, 'get')) - shutil.copy('../scripts/install.ps1', os.path.join(site_dir, 'get.ps1')) - - # remove non-website files - os.remove(os.path.join(site_dir, 'hooks.py')) - os.remove(os.path.join(site_dir, 'reference/commands/commands.go')) - os.remove(os.path.join(site_dir, 'reference/commands/commands_test.go')) + utils.copy_file('../scripts/install.sh', os.path.join(site_dir, 'get')) + utils.copy_file('../scripts/install.ps1', os.path.join(site_dir, 'get.ps1')) diff --git a/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md b/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md deleted file mode 100644 index 76e975c0c27..00000000000 --- a/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md +++ /dev/null @@ -1,75 +0,0 @@ -# Articles, podcasts, and videos - -!!! tip - - Recommended article: [Fedora Magazine: Take back your dotfiles with Chezmoi](https://fedoramagazine.org/take-back-your-dotfiles-with-chezmoi/) - -!!! tip - - Recommended video: [chezmoi: manage your dotfiles across multiple, diverse machines, securely](https://fosdem.org/2021/schedule/event/chezmoi/) - -!!! tip - - Recommended podcast: [Managing Dot Files and an Introduction to Chezmoi](https://www.podfeet.com/blog/2021/07/ccatp-693/) - -| Date | Version | Format | Link | -| ---------- | ------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 2022-02-02 | 2.11.0 | Text (FR) | [Controler ses dotfiles en environnement éphémère](https://blog.wescale.fr/2022/02/02/controler-ses-dotfiles-en-environnement-ephemere-2/) | -| 2022-02-01 | 2.10.1 | Text (JP) | [chezmoi で dotfiles を手軽に柔軟にセキュアに管理する](https://zenn.dev/ryo_kawamata/articles/introduce-chezmoi) | -| 2022-01-26 | 2.10.1 | Text (JP) | [chezmoi で dotfiles を管理する](https://blog.zoncoen.net/2022/01/26/chezmoi/) | -| 2022-01-12 | 2.9.5 | Text (IT) | [Come funzionano i miei Mac](https://correntedebole.com/come-funzionano-i-miei-mac/) | -| 2021-12-23 | 2.9.3 | Text | [Use Chezmoi to guarantee idempotency of terminal](https://www.wazaterm.com/blog/advent-calendar-2021/use-chezmoi-to-guarantee-idempotency-of-terminal) | -| 2021-12-20 | 2.9.3 | Text | [How chezmoi Implements Cross-Platform CI](https://gopheradvent.com/calendar/2021/how-chezmoi-implements-cross-platform-ci/) | -| 2021-12-13 | 2.9.3 | Text | [Managing Dotfiles With Chezmoi](https://budimanjojo.com/2021/12/13/managing-dotfiles-with-chezmoi/) | -| 2021-12-08 | 2.9.3 | Video | [How Go makes chezmoi possible](https://www.youtube.com/watch?v=5XiewS8ZbH8&t=1044s) | -| 2021-12-04 | 2.9.2 | Text | [Advanced features of Chezmoi](https://zerokspot.com/weblog/2021/12/04/advanced-chezmoi/) | -| 2021-12-01 | 2.9.1 | Text | [Chezmoi 2](https://johnmathews.is/chezmoi-2.html) | -| 2021-11-27 | 2.8.0 | Video (TH) | [Command ไร 2021-11-27 : ย้าย dotfiles ไป chezmoi](https://www.youtube.com/watch?v=8ybNfCfnF2Y) | -| 2021-11-26 | 2.8.0 | Text | [Weekly Journal 47 - chezmoi, neovim](https://scottbanwart.com/blog/2021/11/weekly-journal-47-chezmoi-neovim/) | -| 2021-11-23 | 2.8.0 | Text | [chezmoi dotfile management](https://www.jacobbolda.com/chezmoi-dotfile-management) | -| 2021-10-26 | 2.7.3 | Text (RU) | [Синхронизация системных настроек](https://habr.com/en/post/585578/) | -| 2021-09-18 | 2.1.2 | Audio/text | [PBS 125 of X — Chezmoi on Multiple Computers](https://pbs.bartificer.net/pbs125) | -| 2021-09-14 | 2.2.0 | Text | [Managing preference plists under Chezmoi](https://zacwe.st/2021/09/14/managing-preference-plists-under-chezmoi/) | -| 2021-09-06 | 2.2.0 | Video | [chezmoi: Organize your dotfiles across multiple computers \| Let's Code](https://www.youtube.com/watch?v=L_Y3s0PS_Cg) | -| 2021-09-06 | 2.2.0 | Text | [chezmoi dotfile management](https://www.jacobbolda.com/chezmoi-dotfile-management) | -| 2021-09-04 | 2.2.0 | Text | [Configuration Management](https://cj.rs/blog/my-setup/chezmoi/) | -| 2021-09-04 | 2.1.2 | Audio/text | [PBS 124 of X — Chezmoi Templates](https://pbs.bartificer.net/pbs124) | -| 2021-08-22 | 2.1.2 | Audio/text | [PBS 123 of X — Backing up and Syncing Dot Files with Chezmoi](https://pbs.bartificer.net/pbs123) | -| 2021-08-08 | 2.1.2 | Audio/text | [PBS 122 of X — Managing Dot Files with Chezmoi](https://pbs.bartificer.net/pbs122) | -| 2021-08-04 | 2.1.2 | Text (PT) | [Como instalar o Chezmoi, um gerenciador de dotfiles, no Ubuntu, Linux Mint, Fedora, Debian](https://sempreupdate.com.br/como-instalar-o-chezmoi-um-gerenciador-de-dotfiles-no-ubuntu-linux-mint-fedora-debian/) | -| 2021-07-23 | 2.1.2 | Audio/text | [PBS 121 of X — Managing Dot Files and an Introduction to Chezmoi](https://www.podfeet.com/blog/2021/07/ccatp-693/) | -| 2021-07-15 | 2.1.2 | Text (CN) | [使用Chezmoi管理配置文件](https://marvinsblog.net/post/2021-07-15-chezmoi-intro/) | -| 2021-05-14 | 2.0.12 | Text | [A brief history of my dotfile management](https://jonathanbartlett.co.uk/2021/05/14/a-brief-history-of-my-dotfiles.html) | -| 2021-05-12 | 2.0.12 | Text | [My Dotfiles Story: A Journey to Chezmoi](https://www.mikekasberg.com/blog/2021/05/12/my-dotfiles-story.html) | -| 2021-05-10 | 2.0.11 | Text | [Development Environment (2021)](https://ideas.offby1.net/posts/development-environment-2021.html) | -| 2021-04-08 | 2.0.9 | Text (FR) | [Bienvenue chez moi](https://blogduyax.madyanne.fr/2021/bienvenue-chez-moi/) | -| 2021-04-01 | 2.0.7 | Text | [ChezMoi](https://johnmathews.is/chezmoi.html) | -| 2021-02-17 | 1.8.11 | Text (JP) | [chezmoi で dotfiles を手軽に柔軟にセキュアに管理する](https://zenn.dev/ryo_kawamata/articles/introduce-chezmoi) | -| 2021-02-07 | 1.8.10 | Text (JP) | [chezmoi始めた](https://joe-noh.hatenablog.com/entry/2021/02/07/215733) | -| 2021-02-06 | 1.8.10 | Video | [chezmoi: manage your dotfiles across multiple, diverse machines, securely](https://fosdem.org/2021/schedule/event/chezmoi/) | -| 2021-01-29 | 1.8.10 | Text (CN) | [[归档] 用 Chezmoi 管理配置文件](https://axionl.me/p/%E5%BD%92%E6%A1%A3-%E7%94%A8-chezmoi-%E7%AE%A1%E7%90%86%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6/) | -| 2021-01-12 | 1.8.10 | Text | [Automating the Setup of a New Mac With All Your Apps, Preferences, and Development Tools](https://www.moncefbelyamani.com/automating-the-setup-of-a-new-mac-with-all-your-apps-preferences-and-development-tools/) | -| 2020-11-06 | 1.8.8 | Text | [Chezmoi – Securely Manage dotfiles across multiple machines](https://computingforgeeks.com/chezmoi-manage-dotfiles-across-multiple-machines/) | -| 2020-11-05 | 1.8.8 | Text | [Using chezmoi to manage dotfiles](https://pashinskikh.com/posts/chezmoi/) | -| 2020-10-05 | 1.8.6 | Text | [Dotfiles with Chezmoi](https://blog.lazkani.io/posts/backup/dotfiles-with-chezmoi/) | -| 2020-10-03 | 1.8.6 | Text | [Chezmoi Merging](https://benoit.srht.site/2020-10-03-chezmoi-merging/) | -| 2020-08-13 | 1.8.3 | Text | [Using BitWarden and Chezmoi to manage SSH keys](https://www.jx0.uk/chezmoi/bitwarden/unix/ssh/2020/08/13/bitwarden-chezmoi-ssh-key.html) | -| 2020-08-09 | 1.8.3 | Text | [Automating and testing dotfiles](https://seds.nl/posts/automating-and-testing-dotfiles/) | -| 2020-08-03 | 1.8.3 | Text | [Automating a Linux in Windows Dev Setup](https://matt.aimonetti.net/posts/2020-08-automating-a-linux-in-windows-dev-setup/) | -| 2020-07-06 | 1.8.3 | Video | [Conf42: chezmoi: Manage your dotfiles across multiple machines, securely](https://www.youtube.com/watch?v=JrCMCdvoMAw) | -| 2020-07-03 | 1.8.3 | Text | [Feeling at home in a LXD container](https://ubuntu.com/blog/feeling-at-home-in-a-lxd-container) | -| 2020-06-15 | 1.8.2 | Text | [Dotfiles management using chezmoi - How I Use Linux Desktop at Work Part5](https://blog.benoitj.ca/2020-06-15-how-i-use-linux-desktop-at-work-part5-dotfiles/) | -| 2020-04-27 | 1.8.0 | Text | [Managing my dotfiles with chezmoi](http://blog.emilieschario.com/post/managing-my-dotfiles-with-chezmoi/) | -| 2020-04-20 | 1.8.0 | Text (FR) | [Gestion des dotfiles et des secrets avec chezmoi](https://blog.arkey.fr/2020/04/01/manage_dotfiles_with_chezmoi.fr/) | -| 2020-04-19 | 1.7.19 | Text (FR) | [Git & dotfiles : versionner ses fichiers de configuration](https://www.armandphilippot.com/dotfiles-git-fichiers-configuration/) | -| 2020-04-16 | 1.7.19 | Text (FR) | [Chezmoi, visite guidée](https://blog.wescale.fr/2020/04/16/chezmoi-visite-guidee/) | -| 2020-04-17 | 1.7.17 | Text (CN) | [用 Chezmoi 取回你的点文件](https://blog.csdn.net/F8qG7f9YD02Pe/article/details/105548429) | -| 2020-04-03 | 1.7.17 | Text | [Fedora Magazine: Take back your dotfiles with Chezmoi](https://fedoramagazine.org/take-back-your-dotfiles-with-chezmoi/) | -| 2020-04-01 | 1.7.17 | Text | [Managing dotfiles and secret with chezmoi](https://blog.arkey.fr/2020/04/01/manage_dotfiles_with_chezmoi/) | -| 2020-03-12 | 1.7.16 | Video | [Managing Dotfiles with ChezMoi](https://www.youtube.com/watch?v=HXx6ugA98Qo) | -| 2019-11-20 | 1.7.2 | Audio/video | [FLOSS weekly episode 556: chezmoi](https://twit.tv/shows/floss-weekly/episodes/556) | -| 2019-01-10 | 0.0.11 | Text | [Linux Fu: The kitchen sync](https://hackaday.com/2019/01/10/linux-fu-the-kitchen-sync/) | - -To add your article to this page please either [open an -issue](https://github.com/twpayne/chezmoi/issues/new/choose) or submit a pull -request that modifies this file (`assets/chezmoi.io/docs/links/media.md`). diff --git a/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.tmpl b/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.tmpl new file mode 100644 index 00000000000..0431a5834ad --- /dev/null +++ b/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.tmpl @@ -0,0 +1,29 @@ +# Articles, podcasts, and videos + +!!! tip + + Recommended article: [Fedora Magazine: Take back your dotfiles with Chezmoi](https://fedoramagazine.org/take-back-your-dotfiles-with-chezmoi/) + +!!! tip + + Recommended video: [chezmoi: manage your dotfiles across multiple, diverse machines, securely](https://fosdem.org/2021/schedule/event/chezmoi/) + +!!! tip + + Recommended podcast: [Managing Dot Files and an Introduction to Chezmoi](https://www.podfeet.com/blog/2021/07/ccatp-693/) + +| Date | Version | Format | Link | +| ---- | ------- | ------ | ---- | +{{- range (mustReverse .articles) }} +{{- $format := index . "format" | default "Text" }} +{{- $lang := index . "lang" | default "EN" }} +{{- if ne $lang "EN" }} +{{- $format = printf "%s (%s)" $format $lang }} +{{- end }} +| {{ .date }} | {{ .version }} | {{ $format }} | [{{ .title }}]({{ .url }}) | +{{- end }} + +To add your article to this page please either [open an +issue](https://github.com/twpayne/chezmoi/issues/new/choose) or submit a pull +request that modifies +`assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.yaml`. diff --git a/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.yaml b/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.yaml new file mode 100644 index 00000000000..7fcc5d816bd --- /dev/null +++ b/assets/chezmoi.io/docs/links/articles-podcasts-and-videos.md.yaml @@ -0,0 +1,250 @@ +articles: +- date: '2019-01-10' + version: '0.0.11' + format: 'Text' + title: 'Linux Fu: The kitchen sync' + url: 'https://hackaday.com/2019/01/10/linux-fu-the-kitchen-sync/' +- date: '2019-11-20' + version: '1.7.2' + format: Audio/video + title: 'FLOSS weekly episode 556: chezmoi' + url: 'https://twit.tv/shows/floss-weekly/episodes/556' +- date: '2020-03-12' + version: '1.7.16' + format: Video + title: 'Managing Dotfiles with ChezMoi' + url: 'https://www.youtube.com/watch?v=HXx6ugA98Qo' +- date: '2020-04-01' + version: '1.7.17' + title: 'Managing dotfiles and secret with chezmoi' + url: 'https://blog.arkey.fr/2020/04/01/manage_dotfiles_with_chezmoi/' +- date: '2020-04-03' + version: '1.7.17' + title: 'Fedora Magazine: Take back your dotfiles with Chezmoi' + url: 'https://fedoramagazine.org/take-back-your-dotfiles-with-chezmoi/' +- date: '2020-04-17' + version: '1.7.17' + lang: "CN" + title: '用 Chezmoi 取回你的点文件' + url: 'https://blog.csdn.net/F8qG7f9YD02Pe/article/details/105548429' +- date: '2020-04-16' + version: '1.7.19' + lang: "FR" + title: 'Chezmoi, visite guidée' + url: 'https://blog.wescale.fr/2020/04/16/chezmoi-visite-guidee/' +- date: '2020-04-19' + version: '1.7.19' + lang: "FR" + title: 'Git & dotfiles : versionner ses fichiers de configuration' + url: 'https://www.armandphilippot.com/dotfiles-git-fichiers-configuration/' +- date: '2020-04-20' + version: '1.8.0' + lang: "FR" + title: 'Gestion des dotfiles et des secrets avec chezmoi' + url: 'https://blog.arkey.fr/2020/04/01/manage_dotfiles_with_chezmoi.fr/' +- date: '2020-04-27' + version: '1.8.0' + title: 'Managing my dotfiles with chezmoi' + url: 'http://blog.emilieschario.com/post/managing-my-dotfiles-with-chezmoi/' +- date: '2020-06-15' + version: '1.8.2' + title: 'Dotfiles management using chezmoi - How I Use Linux Desktop at Work Part5' + url: 'https://blog.benoitj.ca/2020-06-15-how-i-use-linux-desktop-at-work-part5-dotfiles/' +- date: '2020-07-03' + version: '1.8.3' + title: 'Feeling at home in a LXD container' + url: 'https://ubuntu.com/blog/feeling-at-home-in-a-lxd-container' +- date: '2020-07-06' + version: '1.8.3' + format: Video + title: 'Conf42: chezmoi: Manage your dotfiles across multiple machines, securely' + url: 'https://www.youtube.com/watch?v=JrCMCdvoMAw' +- date: '2020-08-03' + version: '1.8.3' + title: 'Automating a Linux in Windows Dev Setup' + url: 'https://matt.aimonetti.net/posts/2020-08-automating-a-linux-in-windows-dev-setup/' +- date: '2020-08-09' + version: '1.8.3' + title: 'Automating and testing dotfiles' + url: 'https://seds.nl/posts/automating-and-testing-dotfiles/' +- date: '2020-08-13' + version: '1.8.3' + title: 'Using BitWarden and Chezmoi to manage SSH keys' + url: 'https://www.jx0.uk/chezmoi/bitwarden/unix/ssh/2020/08/13/bitwarden-chezmoi-ssh-key.html' +- date: '2020-10-03' + version: '1.8.6' + title: 'Chezmoi Merging' + url: 'https://benoit.srht.site/2020-10-03-chezmoi-merging/' +- date: '2020-10-05' + version: '1.8.6' + title: 'Dotfiles with Chezmoi' + url: 'https://blog.lazkani.io/posts/backup/dotfiles-with-chezmoi/' +- date: '2020-11-05' + version: '1.8.8' + title: 'Using chezmoi to manage dotfiles' + url: 'https://pashinskikh.com/posts/chezmoi/' +- date: '2020-11-06' + version: '1.8.8' + title: 'Chezmoi – Securely Manage dotfiles across multiple machines' + url: 'https://computingforgeeks.com/chezmoi-manage-dotfiles-across-multiple-machines/' +- date: '2021-01-12' + version: '1.8.10' + 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/' +- date: '2021-01-29' + version: '1.8.10' + lang: "CN" + title: "用 Chezmoi 管理配置文件" + url: "https://axionl.me/p/%E5%BD%92%E6%A1%A3-%E7%94%A8-chezmoi-%E7%AE%A1%E7%90%86%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6/" +- date: '2021-02-06' + version: '1.8.10' + format: Video + title: 'chezmoi: manage your dotfiles across multiple, diverse machines, securely' + url: 'https://fosdem.org/2021/schedule/event/chezmoi/' +- date: '2021-02-07' + version: '1.8.10' + lang: "JP" + title: 'chezmoi始めた' + url: 'https://joe-noh.hatenablog.com/entry/2021/02/07/215733' +- date: '2021-02-17' + version: '1.8.11' + lang: "JP" + title: 'chezmoi で dotfiles を手軽に柔軟にセキュアに管理する' + url: 'https://zenn.dev/ryo_kawamata/articles/introduce-chezmoi' +- date: '2021-04-01' + version: '2.0.7' + title: 'ChezMoi' + url: 'https://johnmathews.is/chezmoi.html' +- date: '2021-04-08' + version: '2.0.9' + lang: "FR" + title: 'Bienvenue chez moi' + url: 'https://blogduyax.madyanne.fr/2021/bienvenue-chez-moi/' +- date: '2021-05-10' + version: '2.0.11' + title: 'Development Environment (2021)' + url: 'https://ideas.offby1.net/posts/development-environment-2021.html' +- date: '2021-05-12' + version: '2.0.12' + title: 'My Dotfiles Story: A Journey to Chezmoi' + url: 'https://www.mikekasberg.com/blog/2021/05/12/my-dotfiles-story.html' +- date: '2021-05-14' + version: '2.0.12' + title: 'A brief history of my dotfile management' + url: 'https://jonathanbartlett.co.uk/2021/05/14/a-brief-history-of-my-dotfiles.html' +- date: '2021-07-15' + version: '2.1.2' + lang: "CN" + title: '使用Chezmoi管理配置文件' + url: 'https://marvinsblog.net/post/2021-07-15-chezmoi-intro/' +- date: '2021-07-23' + version: '2.1.2' + format: Audio/text + title: 'PBS 121 of X — Managing Dot Files and an Introduction to Chezmoi' + url: 'https://www.podfeet.com/blog/2021/07/ccatp-693/' +- date: '2021-08-04' + version: '2.1.2' + lang: "PT" + title: 'Como instalar o Chezmoi, um gerenciador de dotfiles, no Ubuntu, Linux Mint, Fedora, Debian' + url: 'https://sempreupdate.com.br/como-instalar-o-chezmoi-um-gerenciador-de-dotfiles-no-ubuntu-linux-mint-fedora-debian/' +- date: '2021-08-08' + version: '2.1.2' + format: Audio/text + title: 'PBS 122 of X — Managing Dot Files with Chezmoi' + url: 'https://pbs.bartificer.net/pbs122' +- date: '2021-08-22' + version: '2.1.2' + format: Audio/text + title: 'PBS 123 of X — Backing up and Syncing Dot Files with Chezmoi' + url: 'https://pbs.bartificer.net/pbs123' +- date: '2021-09-04' + version: '2.1.2' + format: Audio/text + title: 'PBS 124 of X — Chezmoi Templates' + url: 'https://pbs.bartificer.net/pbs124' +- date: '2021-09-04' + version: '2.2.0' + title: 'Configuration Management' + url: 'https://cj.rs/blog/my-setup/chezmoi/' +- date: '2021-09-06' + version: '2.2.0' + title: 'chezmoi dotfile management' + url: 'https://www.jacobbolda.com/chezmoi-dotfile-management' +- date: '2021-09-06' + version: '2.2.0' + format: Video + title: 'chezmoi: Organize your dotfiles across multiple computers' + url: 'https://www.youtube.com/watch?v=L_Y3s0PS_Cg' +- date: '2021-09-14' + version: '2.2.0' + title: 'Managing preference plists under Chezmoi' + url: 'https://zacwe.st/2021/09/14/managing-preference-plists-under-chezmoi/' +- date: '2021-09-18' + version: '2.1.2' + format: Audio/text + title: 'PBS 125 of X — Chezmoi on Multiple Computers' + url: 'https://pbs.bartificer.net/pbs125' +- date: '2021-10-26' + version: '2.7.3' + lang: "RU" + title: 'Синхронизация системных настроек' + url: 'https://habr.com/en/post/585578/' +- date: '2021-11-23' + version: '2.8.0' + title: 'chezmoi dotfile management' + url: 'https://www.jacobbolda.com/chezmoi-dotfile-management' +- date: '2021-11-26' + version: '2.8.0' + title: 'Weekly Journal 47 - chezmoi, neovim' + url: 'https://scottbanwart.com/blog/2021/11/weekly-journal-47-chezmoi-neovim/' +- date: '2021-11-27' + version: '2.8.0' + format: 'Video' + lang: "TH" + title: 'Command ไร 2021-11-27 : ย้าย dotfiles ไป chezmoi' + url: 'https://www.youtube.com/watch?v=8ybNfCfnF2Y' +- date: '2021-12-01' + version: '2.9.1' + title: 'Chezmoi 2' + url: 'https://johnmathews.is/chezmoi-2.html' +- date: '2021-12-04' + version: '2.9.2' + title: 'Advanced features of Chezmoi' + url: 'https://zerokspot.com/weblog/2021/12/04/advanced-chezmoi/' +- date: '2021-12-08' + version: '2.9.3' + format: Video + title: 'How Go makes chezmoi possible' + url: 'https://www.youtube.com/watch?v=5XiewS8ZbH8&t=1044s' +- date: '2021-12-13' + version: '2.9.3' + title: 'Managing Dotfiles With Chezmoi' + url: 'https://budimanjojo.com/2021/12/13/managing-dotfiles-with-chezmoi/' +- date: '2021-12-20' + version: '2.9.3' + title: 'How chezmoi Implements Cross-Platform CI' + url: 'https://gopheradvent.com/calendar/2021/how-chezmoi-implements-cross-platform-ci/' +- date: '2021-12-23' + version: '2.9.3' + title: 'Use Chezmoi to guarantee idempotency of terminal' + url: 'https://www.wazaterm.com/blog/advent-calendar-2021/use-chezmoi-to-guarantee-idempotency-of-terminal' +- date: '2022-01-12' + version: '2.9.5' + lang: "IT" + title: 'Come funzionano i miei Mac' + url: 'https://correntedebole.com/come-funzionano-i-miei-mac/' +- date: '2022-01-26' + version: '2.10.1' + lang: "JP" + title: 'chezmoi で dotfiles を管理する' + url: 'https://blog.zoncoen.net/2022/01/26/chezmoi/' +- date: '2022-02-01' + version: '2.10.1' + lang: "JP" + title: 'chezmoi で dotfiles を手軽に柔軟にセキュアに管理する' + url: 'https://zenn.dev/ryo_kawamata/articles/introduce-chezmoi' +- date: '2022-02-02' + version: '2.11.0' + lang: 'FR' + title: 'Controler ses dotfiles en environnement éphémère' + url: 'https://blog.wescale.fr/2022/02/02/controler-ses-dotfiles-en-environnement-ephemere-2/' diff --git a/assets/chezmoi.io/mkdocs.yml b/assets/chezmoi.io/mkdocs.yml index 3ec12c03da5..f305c024141 100644 --- a/assets/chezmoi.io/mkdocs.yml +++ b/assets/chezmoi.io/mkdocs.yml @@ -224,4 +224,6 @@ plugins: docs/templating.md: user-guide/templating.md - mkdocs-simple-hooks: hooks: + on_pre_build: "docs.hooks:on_pre_build" + on_files: "docs.hooks:on_files" on_post_build: "docs.hooks:on_post_build"
chore
Generate articles, podcasts, and videos doc from template with data
240f7ecddb78cd250e555b054a1c9892088eab97
2021-11-20 06:08:24
Tom Payne
feat: Make .chezmoidata.<format> and .chezmoitemplates available in .chezmoiignore
false
diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index 307d0ee976d..10bc62caebc 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -676,6 +676,8 @@ states do not change while chezmoi is running. All files and directories in the source state whose name begins with `.` are ignored by default, unless they are one of the special files listed here. +`.chezmoidata.<format>` and `.chezmoitemplates` are read before all other files +so that they can be used in templates. --- diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go index c83388cd19a..514c40afdb3 100644 --- a/internal/chezmoi/sourcestate.go +++ b/internal/chezmoi/sourcestate.go @@ -684,7 +684,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error { // Read all source entries. allSourceStateEntries := make(map[RelPath][]SourceStateEntry) - if err := WalkDir(s.system, s.sourceDirAbsPath, func(sourceAbsPath AbsPath, info fs.FileInfo, err error) error { + if err := WalkSourceDir(s.system, s.sourceDirAbsPath, func(sourceAbsPath AbsPath, info fs.FileInfo, err error) error { if err != nil { return err } @@ -719,16 +719,8 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error { case strings.HasPrefix(info.Name(), externalName): return s.addExternal(sourceAbsPath) case info.Name() == ignoreName: - // .chezmoiignore is interpreted as a template. we walk the - // filesystem in alphabetical order, so, luckily for us, - // .chezmoidata will be read before .chezmoiignore, so data in - // .chezmoidata is available to be used in .chezmoiignore. Unluckily - // for us, .chezmoitemplates will be read afterwards so partial - // templates will not be available in .chezmoiignore. return s.addPatterns(s.ignore, sourceAbsPath, parentSourceRelPath) case info.Name() == removeName: - // The comment about .chezmoiignore and templates applies to - // .chezmoiremove too. removePatterns := newPatternSet() if err := s.addPatterns(removePatterns, sourceAbsPath, sourceRelPath); err != nil { return err @@ -1039,7 +1031,7 @@ func (s *SourceState) addTemplateData(sourceAbsPath AbsPath) error { // addTemplatesDir adds all templates in templateDir to s. func (s *SourceState) addTemplatesDir(templatesDirAbsPath AbsPath) error { - return WalkDir(s.system, templatesDirAbsPath, func(templateAbsPath AbsPath, info fs.FileInfo, err error) error { + return WalkSourceDir(s.system, templatesDirAbsPath, func(templateAbsPath AbsPath, info fs.FileInfo, err error) error { switch { case err != nil: return err diff --git a/internal/chezmoi/sourcestate_test.go b/internal/chezmoi/sourcestate_test.go index 616b62bc756..f9249576768 100644 --- a/internal/chezmoi/sourcestate_test.go +++ b/internal/chezmoi/sourcestate_test.go @@ -1515,6 +1515,50 @@ func TestSourceStateTargetRelPaths(t *testing.T) { } } +func TestWalkSourceDir(t *testing.T) { + sourceDirAbsPath := NewAbsPath("/home/user/.local/share/chezmoi") + root := map[string]interface{}{ + sourceDirAbsPath.String(): map[string]interface{}{ + ".chezmoi.toml.tmpl": "", + ".chezmoidata.json": "", + ".chezmoidata.toml": "", + ".chezmoidata.yaml": "", + ".chezmoiexternal.yaml": "", + ".chezmoiignore": "", + ".chezmoiremove": "", + ".chezmoitemplates": &vfst.Dir{Perm: 0o777}, + ".chezmoiversion": "", + "dot_file": "", + }, + } + expectedAbsPaths := []AbsPath{ + sourceDirAbsPath, + sourceDirAbsPath.JoinString(".chezmoidata.json"), + sourceDirAbsPath.JoinString(".chezmoidata.toml"), + sourceDirAbsPath.JoinString(".chezmoidata.yaml"), + sourceDirAbsPath.JoinString(".chezmoitemplates"), + sourceDirAbsPath.JoinString(".chezmoi.toml.tmpl"), + sourceDirAbsPath.JoinString(".chezmoiexternal.yaml"), + sourceDirAbsPath.JoinString(".chezmoiignore"), + sourceDirAbsPath.JoinString(".chezmoiremove"), + sourceDirAbsPath.JoinString(".chezmoiversion"), + sourceDirAbsPath.JoinString("dot_file"), + } + + var actualAbsPaths []AbsPath + chezmoitest.WithTestFS(t, root, func(fileSystem vfs.FS) { + system := NewRealSystem(fileSystem) + require.NoError(t, WalkSourceDir(system, sourceDirAbsPath, func(absPath AbsPath, info fs.FileInfo, err error) error { + if err != nil { + return err + } + actualAbsPaths = append(actualAbsPaths, absPath) + return nil + })) + }) + assert.Equal(t, expectedAbsPaths, actualAbsPaths) +} + // applyAll updates targetDir in targetSystem to match s. func (s *SourceState) applyAll(targetSystem, destSystem System, persistentState PersistentState, targetDir AbsPath, options ApplyOptions) error { for _, targetRelPath := range s.TargetRelPaths() { diff --git a/internal/chezmoi/system.go b/internal/chezmoi/system.go index 1650e232452..327bf832e07 100644 --- a/internal/chezmoi/system.go +++ b/internal/chezmoi/system.go @@ -4,6 +4,7 @@ import ( "errors" "io/fs" "os/exec" + "sort" vfs "github.com/twpayne/go-vfs/v4" ) @@ -130,27 +131,101 @@ func MkdirAll(system System, absPath AbsPath, perm fs.FileMode) error { } } -// Walk walks rootAbsPath in system, alling walkFn for each file or directory in +// Walk walks rootAbsPath in system, alling walkFunc for each file or directory in // the tree, including rootAbsPath. // // Walk does not follow symlinks. -func Walk(system System, rootAbsPath AbsPath, walkFn func(absPath AbsPath, info fs.FileInfo, err error) error) error { +func Walk(system System, rootAbsPath AbsPath, walkFunc func(absPath AbsPath, info fs.FileInfo, err error) error) error { return vfs.Walk(system.UnderlyingFS(), rootAbsPath.String(), func(absPath string, info fs.FileInfo, err error) error { - return walkFn(NewAbsPath(absPath).ToSlash(), info, err) + return walkFunc(NewAbsPath(absPath).ToSlash(), info, err) }) } -// WalkDir walks the file tree rooted at rootAbsPath in system, calling walkFn -// for each file or directory in the tree, including rootAbsPath. +// A WalkSourceDirFunc is a function called for every in a source directory. +type WalkSourceDirFunc func(AbsPath, fs.FileInfo, error) error + +// WalkSourceDir walks the source directory rooted at sourceDirAbsPath in +// system, calling walkFunc for each file or directory in the tree, including +// sourceDirAbsPath. +// +// WalkSourceDir does not follow symbolic links found in directories, but if +// sourceDirAbsPath itself is a symbolic link, its target will be walked. // -// WalkDir does not follow symbolic links found in directories, but if -// rootAbsPath itself is a symbolic link, its target will be walked. -func WalkDir(system System, rootAbsPath AbsPath, walkFn func(absPath AbsPath, info fs.FileInfo, err error) error) error { - return fs.WalkDir(system.UnderlyingFS(), rootAbsPath.String(), func(path string, dirEntry fs.DirEntry, err error) error { - var info fs.FileInfo - if err == nil { - info, err = dirEntry.Info() +// Directory entries .chezmoidata.<format> and .chezmoitemplates are visited +// before all other entries. All other entries are visited in alphabetical +// order. +func WalkSourceDir(system System, sourceDirAbsPath AbsPath, walkFunc WalkSourceDirFunc) error { + info, err := system.Stat(sourceDirAbsPath) + if err != nil { + err = walkFunc(sourceDirAbsPath, nil, err) + } else { + err = walkSourceDir(system, sourceDirAbsPath, info, walkFunc) + } + if errors.Is(err, fs.SkipDir) { + return nil + } + return err +} + +// sourceDirEntryOrder defines the order in which entries are visited in the +// 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{ + ".chezmoidata.json": -2, + ".chezmoidata.toml": -2, + ".chezmoidata.yaml": -2, + ".chezmoitemplates": -1, +} + +// walkSourceDir is a helper function for WalkSourceDir. +func walkSourceDir(system System, name AbsPath, info fs.FileInfo, walkFunc WalkSourceDirFunc) error { + switch err := walkFunc(name, info, nil); { + case info.IsDir() && errors.Is(err, fs.SkipDir): + return nil + case err != nil: + return err + case !info.IsDir(): + return nil + } + + dirEntries, err := system.ReadDir(name) + if err != nil { + err = walkFunc(name, info, err) + if err != nil { + return err + } + } + + sort.Slice(dirEntries, func(i, j int) bool { + nameI := dirEntries[i].Name() + nameJ := dirEntries[j].Name() + orderI := sourceDirEntryOrder[nameI] + orderJ := sourceDirEntryOrder[nameJ] + switch { + case orderI < orderJ: + return true + case orderI == orderJ: + return nameI < nameJ + default: + return false } - return walkFn(NewAbsPath(path).ToSlash(), info, err) }) + + for _, dirEntry := range dirEntries { + info, err := dirEntry.Info() + if err != nil { + err = walkFunc(name, nil, err) + if err != nil { + return err + } + } + if err := walkSourceDir(system, name.JoinString(dirEntry.Name()), info, walkFunc); err != nil { + if errors.Is(err, fs.SkipDir) { + break + } + return err + } + } + + return nil } diff --git a/internal/cmd/doctorcmd.go b/internal/cmd/doctorcmd.go index 7e5f5b76285..45873cf20f5 100644 --- a/internal/cmd/doctorcmd.go +++ b/internal/cmd/doctorcmd.go @@ -475,7 +475,7 @@ func (c *suspiciousEntriesCheck) Name() string { func (c *suspiciousEntriesCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) { // FIXME check that config file templates are in root var suspiciousEntries []string - switch err := chezmoi.WalkDir(system, c.dirname, func(absPath chezmoi.AbsPath, info fs.FileInfo, err error) error { + switch err := chezmoi.WalkSourceDir(system, c.dirname, func(absPath chezmoi.AbsPath, info fs.FileInfo, err error) error { if err != nil { return err } diff --git a/internal/cmd/testdata/scripts/templatedata.txt b/internal/cmd/testdata/scripts/templatedata.txt index e697625d185..438ead6c709 100644 --- a/internal/cmd/testdata/scripts/templatedata.txt +++ b/internal/cmd/testdata/scripts/templatedata.txt @@ -10,5 +10,22 @@ stdout dot_file.tmpl [linux] chezmoi execute-template '{{ .chezmoi.kernel.ostype }}' [linux] stdout Linux +chhome home2/user + +# test that .chezmoidata.<format> and .chezmoitemplates are available in .chezmoiignore +chezmoi apply +exists $HOME/.file1 +! exists $HOME/.file2 + -- home/user/.local/share/chezmoi/dot_file.tmpl -- {{ .chezmoi.sourceFile }} +-- home2/user/.local/share/chezmoi/.chezmoidata.toml -- +filename = ".file2" +-- home2/user/.local/share/chezmoi/.chezmoitemplates/ignore -- +{{ .filename }} +-- home2/user/.local/share/chezmoi/.chezmoiignore -- +{{ template "ignore" . }} +-- home2/user/.local/share/chezmoi/dot_file1 -- +# contents of .file1 +-- home2/user/.local/share/chezmoi/dot_file2 -- +# contents of .file2 diff --git a/internal/cmd/unmanagedcmd.go b/internal/cmd/unmanagedcmd.go index bf98f2266c8..3ec179c7077 100644 --- a/internal/cmd/unmanagedcmd.go +++ b/internal/cmd/unmanagedcmd.go @@ -25,7 +25,7 @@ func (c *Config) newUnmanagedCmd() *cobra.Command { func (c *Config) runUnmanagedCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error { builder := strings.Builder{} - if err := chezmoi.WalkDir(c.destSystem, c.DestDirAbsPath, func(destAbsPath chezmoi.AbsPath, info fs.FileInfo, err error) error { + if err := chezmoi.WalkSourceDir(c.destSystem, c.DestDirAbsPath, func(destAbsPath chezmoi.AbsPath, info fs.FileInfo, err error) error { if err != nil { return err }
feat
Make .chezmoidata.<format> and .chezmoitemplates available in .chezmoiignore
d4ab9cc66ad4ea47742c61f17bb16f823a35de9a
2024-11-01 18:26:03
dependabot[bot]
chore(deps): bump github/codeql-action in the actions group
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 48d379f0d29..3b76b4546e1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -62,10 +62,10 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: fetch-depth: 1 - - uses: github/codeql-action/init@e2b3eafc8d227b0241d48be5f425d47c2d750a13 + - uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd with: languages: go - - uses: github/codeql-action/analyze@e2b3eafc8d227b0241d48be5f425d47c2d750a13 + - uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd misspell: runs-on: ubuntu-22.04 permissions:
chore
bump github/codeql-action in the actions group
1418f74ab40bbee807a1438ec0bbdb6c85f24a74
2024-01-25 22:48:45
Tom Payne
docs: Fix broken release history page
false
diff --git a/assets/chezmoi.io/docs/reference/release-history.md.tmpl b/assets/chezmoi.io/docs/reference/release-history.md.tmpl index fdf80eaa676..235e6cd487d 100644 --- a/assets/chezmoi.io/docs/reference/release-history.md.tmpl +++ b/assets/chezmoi.io/docs/reference/release-history.md.tmpl @@ -1,8 +1,9 @@ # Release history {{- $releases := gitHubListReleases "twpayne/chezmoi" }} +{{- $latestRelease := index $releases 0 }} -[Upcoming changes](https://github.com/twpayne/chezmoi/compare/{{ $releases | index 0 | .Name }}...master) +[Upcoming changes](https://github.com/twpayne/chezmoi/compare/{{ $latestRelease.Name }}...master) {{- $lastReleaseIndex := sub (len $releases) 1 }} {{- range $index, $release := $releases }}
docs
Fix broken release history page
c883e2082db510634799bae60852bf90ee50d6f8
2022-01-29 23:06:47
Tom Payne
chore: Tidy up GoPass template functions
false
diff --git a/pkg/cmd/gopasstemplatefuncs.go b/pkg/cmd/gopasstemplatefuncs.go index d5095169a9c..f3def98c7c9 100644 --- a/pkg/cmd/gopasstemplatefuncs.go +++ b/pkg/cmd/gopasstemplatefuncs.go @@ -26,19 +26,7 @@ type gopassConfig struct { rawCache map[string][]byte } -func (c *Config) gopassOutput(args ...string) ([]byte, error) { - name := c.Gopass.Command - cmd := exec.Command(name, args...) - cmd.Stdin = c.stdin - cmd.Stderr = c.stderr - output, err := c.baseSystem.IdempotentCmdOutput(cmd) - if err != nil { - return nil, err - } - return output, nil -} - -func (c *Config) gopassRawTemplateFunc(id string) string { +func (c *Config) gopassTemplateFunc(id string) string { if !c.Gopass.versionOK { if err := c.gopassVersionCheck(); err != nil { returnTemplateError(err) @@ -47,26 +35,29 @@ func (c *Config) gopassRawTemplateFunc(id string) string { c.Gopass.versionOK = true } - if output, ok := c.Gopass.rawCache[id]; ok { - return string(output) + if password, ok := c.Gopass.cache[id]; ok { + return password } - args := []string{"show", "--noparsing", id} + args := []string{"show", "--password", id} output, err := c.gopassOutput(args...) if err != nil { returnTemplateError(fmt.Errorf("%s: %w", shellQuoteCommand(c.Gopass.Command, args), err)) return "" } - if c.Gopass.rawCache == nil { - c.Gopass.rawCache = make(map[string][]byte) + passwordBytes, _, _ := chezmoi.CutBytes(output, []byte{'\n'}) + password := string(passwordBytes) + + if c.Gopass.cache == nil { + c.Gopass.cache = make(map[string]string) } - c.Gopass.rawCache[id] = output + c.Gopass.cache[id] = password - return string(output) + return password } -func (c *Config) gopassTemplateFunc(id string) string { +func (c *Config) gopassRawTemplateFunc(id string) string { if !c.Gopass.versionOK { if err := c.gopassVersionCheck(); err != nil { returnTemplateError(err) @@ -75,26 +66,35 @@ func (c *Config) gopassTemplateFunc(id string) string { c.Gopass.versionOK = true } - if password, ok := c.Gopass.cache[id]; ok { - return password + if output, ok := c.Gopass.rawCache[id]; ok { + return string(output) } - args := []string{"show", "--password", id} + args := []string{"show", "--noparsing", id} output, err := c.gopassOutput(args...) if err != nil { returnTemplateError(fmt.Errorf("%s: %w", shellQuoteCommand(c.Gopass.Command, args), err)) return "" } - passwordBytes, _, _ := chezmoi.CutBytes(output, []byte{'\n'}) - password := string(passwordBytes) - - if c.Gopass.cache == nil { - c.Gopass.cache = make(map[string]string) + if c.Gopass.rawCache == nil { + c.Gopass.rawCache = make(map[string][]byte) } - c.Gopass.cache[id] = password + c.Gopass.rawCache[id] = output - return password + return string(output) +} + +func (c *Config) gopassOutput(args ...string) ([]byte, error) { + name := c.Gopass.Command + cmd := exec.Command(name, args...) + cmd.Stdin = c.stdin + cmd.Stderr = c.stderr + output, err := c.baseSystem.IdempotentCmdOutput(cmd) + if err != nil { + return nil, err + } + return output, nil } func (c *Config) gopassVersionCheck() error {
chore
Tidy up GoPass template functions
f0be985c99116cb5b4f0e6e5d30b239c75ccb070
2022-06-23 05:57:35
Tom Payne
chore: Skip zip tests on Windows
false
diff --git a/pkg/cmd/testdata/scripts/archivezip.txt b/pkg/cmd/testdata/scripts/archivezip.txt index d1bbd84f8ad..04c061af8ac 100644 --- a/pkg/cmd/testdata/scripts/archivezip.txt +++ b/pkg/cmd/testdata/scripts/archivezip.txt @@ -1,3 +1,4 @@ +[windows] skip 'windows line endings confuse cmp and diff' [!exec:unzip] skip 'unzip not found in $PATH' mksourcedir diff --git a/pkg/cmd/testdata/scripts/externalzip.txt b/pkg/cmd/testdata/scripts/externalzip.txt index cfd4e0fae50..c32f3f66331 100644 --- a/pkg/cmd/testdata/scripts/externalzip.txt +++ b/pkg/cmd/testdata/scripts/externalzip.txt @@ -1,3 +1,4 @@ +[windows] skip 'zip may not support the --symlinks option' [!exec:zip] skip 'zip not found in $PATH' symlink archive/dir/symlink -> file exec zip -r --symlinks www/archive.zip archive
chore
Skip zip tests on Windows
e4eded8ff9202cdf341bcf1929ead622cb3ac127
2024-10-22 05:38:14
Tom Payne
chore: Use struct value for options
false
diff --git a/internal/cmd/catcmd.go b/internal/cmd/catcmd.go index 0014943424b..ca2c68fa134 100644 --- a/internal/cmd/catcmd.go +++ b/internal/cmd/catcmd.go @@ -27,7 +27,7 @@ func (c *Config) newCatCmd() *cobra.Command { } func (c *Config) runCatCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error { - targetRelPaths, err := c.targetRelPaths(sourceState, args, nil) + targetRelPaths, err := c.targetRelPaths(sourceState, args, targetRelPathsOptions{}) if err != nil { return err } diff --git a/internal/cmd/chattrcmd.go b/internal/cmd/chattrcmd.go index a2c60223cc1..677aa59a4b6 100644 --- a/internal/cmd/chattrcmd.go +++ b/internal/cmd/chattrcmd.go @@ -150,7 +150,7 @@ func (c *Config) runChattrCmd(cmd *cobra.Command, args []string, sourceState *ch return err } - targetRelPaths, err := c.targetRelPaths(sourceState, args[1:], &targetRelPathsOptions{ + targetRelPaths, err := c.targetRelPaths(sourceState, args[1:], targetRelPathsOptions{ mustNotBeExternal: true, recursive: c.chattr.recursive, }) diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 2e4ffa1337b..3164bb409c4 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -649,7 +649,7 @@ func (c *Config) applyArgs( return err } default: - targetRelPaths, err = c.targetRelPaths(sourceState, args, &targetRelPathsOptions{ + targetRelPaths, err = c.targetRelPaths(sourceState, args, targetRelPathsOptions{ recursive: options.recursive, }) if err != nil { @@ -2536,7 +2536,7 @@ func (c *Config) setEnvironmentVariables() error { // sourceAbsPaths returns the source absolute paths for each target path in // args. func (c *Config) sourceAbsPaths(sourceState *chezmoi.SourceState, args []string) ([]chezmoi.AbsPath, error) { - targetRelPaths, err := c.targetRelPaths(sourceState, args, &targetRelPathsOptions{ + targetRelPaths, err := c.targetRelPaths(sourceState, args, targetRelPathsOptions{ mustBeInSourceState: true, }) if err != nil { @@ -2569,7 +2569,7 @@ type targetRelPathsOptions struct { func (c *Config) targetRelPaths( sourceState *chezmoi.SourceState, args []string, - options *targetRelPathsOptions, + options targetRelPathsOptions, ) (chezmoi.RelPaths, error) { targetRelPaths := make(chezmoi.RelPaths, 0, len(args)) for _, arg := range args { @@ -2585,24 +2585,22 @@ func (c *Config) targetRelPaths( if sourceStateEntry == nil { return nil, fmt.Errorf("%s: not managed", arg) } - if options != nil { - if options.mustBeInSourceState { - if _, ok := sourceStateEntry.(*chezmoi.SourceStateRemove); ok { - return nil, fmt.Errorf("%s: not in source state", arg) - } + if options.mustBeInSourceState { + if _, ok := sourceStateEntry.(*chezmoi.SourceStateRemove); ok { + return nil, fmt.Errorf("%s: not in source state", arg) } - if options.mustNotBeExternal { - targetStateEntry, err := sourceStateEntry.TargetStateEntry(c.destSystem, c.DestDirAbsPath.Join(targetRelPath)) - if err != nil { - return nil, err - } - if targetStateEntry.SourceAttr().External { - return nil, fmt.Errorf("%s: is an external", arg) - } + } + if options.mustNotBeExternal { + targetStateEntry, err := sourceStateEntry.TargetStateEntry(c.destSystem, c.DestDirAbsPath.Join(targetRelPath)) + if err != nil { + return nil, err + } + if targetStateEntry.SourceAttr().External { + return nil, fmt.Errorf("%s: is an external", arg) } } targetRelPaths = append(targetRelPaths, targetRelPath) - if options != nil && options.recursive { + if options.recursive { parentRelPath := targetRelPath // FIXME we should not call s.TargetRelPaths() here - risk of // accidentally quadratic diff --git a/internal/cmd/destroycmd.go b/internal/cmd/destroycmd.go index 1e8ae43d41c..e1323f8d70c 100644 --- a/internal/cmd/destroycmd.go +++ b/internal/cmd/destroycmd.go @@ -36,7 +36,7 @@ func (c *Config) newDestroyCmd() *cobra.Command { } func (c *Config) runDestroyCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error { - targetRelPaths, err := c.targetRelPaths(sourceState, args, &targetRelPathsOptions{ + targetRelPaths, err := c.targetRelPaths(sourceState, args, targetRelPathsOptions{ recursive: c.destroy.recursive, }) if err != nil { diff --git a/internal/cmd/editcmd.go b/internal/cmd/editcmd.go index 15c8a30e469..b5868973ae4 100644 --- a/internal/cmd/editcmd.go +++ b/internal/cmd/editcmd.go @@ -77,7 +77,7 @@ func (c *Config) runEditCmd(cmd *cobra.Command, args []string) error { return err } - targetRelPaths, err := c.targetRelPaths(sourceState, args, &targetRelPathsOptions{ + targetRelPaths, err := c.targetRelPaths(sourceState, args, targetRelPathsOptions{ mustBeInSourceState: true, }) if err != nil { diff --git a/internal/cmd/forgetcmd.go b/internal/cmd/forgetcmd.go index 7ce64f4e9a8..7af2f182c2c 100644 --- a/internal/cmd/forgetcmd.go +++ b/internal/cmd/forgetcmd.go @@ -28,7 +28,7 @@ func (c *Config) newForgetCmd() *cobra.Command { } func (c *Config) runForgetCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error { - targetRelPaths, err := c.targetRelPaths(sourceState, args, nil) + targetRelPaths, err := c.targetRelPaths(sourceState, args, targetRelPathsOptions{}) if err != nil { return err } diff --git a/internal/cmd/mergecmd.go b/internal/cmd/mergecmd.go index 17d95663477..ee85b9ccfe2 100644 --- a/internal/cmd/mergecmd.go +++ b/internal/cmd/mergecmd.go @@ -37,7 +37,7 @@ func (c *Config) newMergeCmd() *cobra.Command { } func (c *Config) runMergeCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error { - targetRelPaths, err := c.targetRelPaths(sourceState, args, &targetRelPathsOptions{ + targetRelPaths, err := c.targetRelPaths(sourceState, args, targetRelPathsOptions{ mustBeInSourceState: true, recursive: true, }) diff --git a/internal/cmd/readdcmd.go b/internal/cmd/readdcmd.go index 674c174030e..3521bc4043d 100644 --- a/internal/cmd/readdcmd.go +++ b/internal/cmd/readdcmd.go @@ -71,7 +71,7 @@ func (c *Config) runReAddCmd(cmd *cobra.Command, args []string, sourceState *che ) } else { var err error - targetRelPaths, err = c.targetRelPaths(sourceState, args, &targetRelPathsOptions{ + targetRelPaths, err = c.targetRelPaths(sourceState, args, targetRelPathsOptions{ recursive: c.reAdd.recursive, }) if err != nil {
chore
Use struct value for options
7f8fd8a52b49dae47eb5691d2b5a3430ee5d0d7b
2022-10-20 20:34:28
Tom Payne
chore: Tweak variable name to match GitHub nomenclature
false
diff --git a/pkg/cmd/githubtemplatefuncs.go b/pkg/cmd/githubtemplatefuncs.go index 584e8cc3aba..382796063df 100644 --- a/pkg/cmd/githubtemplatefuncs.go +++ b/pkg/cmd/githubtemplatefuncs.go @@ -54,8 +54,8 @@ func (c *Config) gitHubKeysTemplateFunc(user string) []*github.Key { return allKeys } -func (c *Config) gitHubLatestReleaseTemplateFunc(userRepo string) *github.RepositoryRelease { - owner, repo, err := gitHubSplitOwnerRepo(userRepo) +func (c *Config) gitHubLatestReleaseTemplateFunc(ownerRepo string) *github.RepositoryRelease { + owner, repo, err := gitHubSplitOwnerRepo(ownerRepo) if err != nil { panic(err) }
chore
Tweak variable name to match GitHub nomenclature
2653e693c670833ced5d6d0501cac34d7b295f76
2022-06-20 02:10:35
Tom Payne
chore: Fix release workflow
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e4a1ae5a03f..6bf78db40e8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -395,13 +395,11 @@ jobs: run: | sudo apt-get update sudo apt-get -yq --no-install-suggests --no-install-recommends install musl-tools snapcraft + - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - uses: actions/setup-go@b22fbbc2921299758641fab08929b4ac52b32923 with: cache: true go-version: ${{ env.GO_VERSION }} - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - with: - fetch-depth: 0 - name: snapcraft-login env: SNAPCRAFT_LOGIN: ${{ secrets.SNAPCRAFT_LOGIN }}
chore
Fix release workflow
371703e93f0c54dad81f7cfbea2906ece15a7428
2024-01-14 00:42:36
Tom Payne
chore: Update GitHub Actions
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1bf688f7f20..3e1acf74cbb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -180,31 +180,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@c7d193f32edcb7bfad88892161225aeda64e9392 + uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 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@c7d193f32edcb7bfad88892161225aeda64e9392 + uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 with: name: chezmoi-darwin-arm64 path: dist/chezmoi-nocgo_darwin_arm64/chezmoi - name: upload-artifact-chezmoi-linux-amd64 if: github.event_name == 'push' || needs.changes.outputs.code == 'true' - uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 + uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 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@c7d193f32edcb7bfad88892161225aeda64e9392 + uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 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@c7d193f32edcb7bfad88892161225aeda64e9392 + uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 with: name: chezmoi-windows-amd64 path: dist/chezmoi-nocgo_windows_amd64_v1/chezmoi.exe @@ -272,7 +272,7 @@ jobs: - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: go-version: ${{ env.GO_VERSION }} - - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
chore
Update GitHub Actions
03e997982f2172da3571b6086dd8bf6ab4600448
2021-12-26 05:11:53
Elan Ruusamäe
chore: Add collapsible details to bug report template
false
diff --git a/.github/ISSUE_TEMPLATE/03_bug_report.md b/.github/ISSUE_TEMPLATE/03_bug_report.md index b82c8f7cfba..b4b9978fd04 100644 --- a/.github/ISSUE_TEMPLATE/03_bug_report.md +++ b/.github/ISSUE_TEMPLATE/03_bug_report.md @@ -26,10 +26,14 @@ $ chezmoi --verbose <your-command> ## Output of `chezmoi doctor` +<details> + ```console $ chezmoi doctor ``` +</details> + ## Additional context Add any other context about the problem here.
chore
Add collapsible details to bug report template
f2f13ea162e8d04140d66fa2067de08ef3843310
2024-07-15 19:27:23
Tom Payne
chore: Update Github Actions
false
diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml index fd21539a1d0..18dd41f5978 100644 --- a/.github/workflows/installer.yml +++ b/.github/workflows/installer.yml @@ -37,7 +37,7 @@ jobs: contents: read steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - - uses: reviewdog/action-misspell@278e1b3c7dd09d2827fa080919a40db73ccafe24 + - uses: reviewdog/action-misspell@ef8b22c1cca06c8d306fc6be302c3dab0f6ca12f with: locale: US ignore: ackward diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fd8afdcf96a..711bc914139 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -70,7 +70,7 @@ jobs: contents: read steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - - uses: reviewdog/action-misspell@278e1b3c7dd09d2827fa080919a40db73ccafe24 + - uses: reviewdog/action-misspell@ef8b22c1cca06c8d306fc6be302c3dab0f6ca12f with: locale: US ignore: ackward,importas
chore
Update Github Actions
285b8a3c4e1d7cf311635272e24f0f6db8d7629b
2024-03-01 04:34:08
Tom Payne
chore: Update dependencies
false
diff --git a/go.mod b/go.mod index 68aa4a1fc29..f7a8ee28c94 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/twpayne/chezmoi/v2 -go 1.21 +go 1.21.4 + +toolchain go1.22.0 require ( filippo.io/age v1.1.1 @@ -8,7 +10,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.1.0 github.com/Masterminds/sprig/v3 v3.2.3 github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 - github.com/Shopify/ejson v1.4.1 + github.com/Shopify/ejson v1.5.0 github.com/alecthomas/assert/v2 v2.6.0 github.com/aws/aws-sdk-go-v2 v1.25.2 github.com/aws/aws-sdk-go-v2/config v1.27.4 @@ -21,7 +23,7 @@ require ( github.com/coreos/go-semver v0.3.1 github.com/fsnotify/fsnotify v1.7.0 github.com/go-git/go-git/v5 v5.11.0 - github.com/google/go-github/v59 v59.0.0 + github.com/google/go-github/v60 v60.0.0 github.com/google/renameio/v2 v2.0.0 github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 github.com/itchyny/gojq v0.12.14 @@ -45,7 +47,7 @@ require ( github.com/zalando/go-keyring v0.2.3 github.com/zricethezav/gitleaks/v8 v8.18.2 go.etcd.io/bbolt v1.3.9 - golang.org/x/crypto v0.19.0 + golang.org/x/crypto v0.20.0 golang.org/x/oauth2 v0.17.0 golang.org/x/sync v0.6.0 golang.org/x/sys v0.17.0 diff --git a/go.sum b/go.sum index b316c60fd55..79f46539521 100644 --- a/go.sum +++ b/go.sum @@ -44,8 +44,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= -github.com/Shopify/ejson v1.4.1 h1:zGGojGJNTdIWza/kOT8gd2HKCg3ZkSi3CZ1ZX70NHsw= -github.com/Shopify/ejson v1.4.1/go.mod h1:VZMUtDzvBW/PAXRUF5fzp1ffb1ucT8MztrZXXLYZurw= +github.com/Shopify/ejson v1.5.0 h1:SDV5HmQlpn3hSUiw9HV0nOj9tpzup5i0OV71ioLYkpw= +github.com/Shopify/ejson v1.5.0/go.mod h1:a4+JLWuTe9+tTofPBGWZoqzf0af6eQKGmFqbxoMSARc= github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU= github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek= @@ -191,8 +191,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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/v59 v59.0.0 h1:7h6bgpF5as0YQLLkEiVqpgtJqjimMYhBkD4jT5aN3VA= -github.com/google/go-github/v59 v59.0.0/go.mod h1:rJU4R0rQHFVFDOkqGWxfLNo6vEk4dv40oDjhV/gH6wM= +github.com/google/go-github/v60 v60.0.0 h1:oLG98PsLauFvvu4D/YPxq374jhSxFYdzQGNCyONLfn8= +github.com/google/go-github/v60 v60.0.0/go.mod h1:ByhX2dP9XT9o/ll2yXAu2VD8l5eNVg8hD4Cr0S/LmQk= 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= @@ -208,8 +208,8 @@ github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56 github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU= github.com/googleapis/google-cloud-go-testing v0.0.0-20210719221736-1c9a4c676720 h1:zC34cGQu69FG7qzJ3WiKW244WfhDC3xxYMeNOX2gtUQ= github.com/googleapis/google-cloud-go-testing v0.0.0-20210719221736-1c9a4c676720/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= -github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 h1:l5lAOZEym3oK3SQ2HBHWsJUfbNBiTXJDeW2QDxw9AQ0= -github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g= +github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8= github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0= @@ -378,17 +378,15 @@ github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNX github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= 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/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= -github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w= -github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= -github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY= +github.com/smarty/assertions v1.15.0/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec= +github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY= +github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= @@ -435,8 +433,8 @@ github.com/twpayne/go-xdg/v6 v6.1.2 h1:KbfCsAP4bBR5+dzfTIh/M9onOPCSqlYsIER79IKwt 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= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= -github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA= -github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli v1.22.14 h1:ebbhrRiGK2i4naQJr+1Xj92HXZCrK7MsyTS/ob3HnAk= +github.com/urfave/cli v1.22.14/go.mod h1:X0eDS6pD6Exaclxm99NJ3FiCDRED7vIHpx2mDOHLvkA= github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1 h1:+dBg5k7nuTE38VVdoroRsT0Z88fmvdYrI2EjzJst35I= github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1/go.mod h1:nmuySobZb4kFgFy6BptpXp/BBw+xFSyvVPP6auoJB4k= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= @@ -480,8 +478,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= +golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= 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 54433094db6..1437ad2ea92 100644 --- a/internal/chezmoi/github.go +++ b/internal/chezmoi/github.go @@ -5,7 +5,7 @@ import ( "net/http" "os" - "github.com/google/go-github/v59/github" + "github.com/google/go-github/v60/github" "golang.org/x/oauth2" ) diff --git a/internal/cmd/doctorcmd.go b/internal/cmd/doctorcmd.go index 9a156759acd..09c765fe9eb 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/v59/github" + "github.com/google/go-github/v60/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 7e527cc59d3..b64083a7dcf 100644 --- a/internal/cmd/githubtemplatefuncs.go +++ b/internal/cmd/githubtemplatefuncs.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/google/go-github/v59/github" + "github.com/google/go-github/v60/github" "github.com/twpayne/chezmoi/v2/internal/chezmoi" ) diff --git a/internal/cmd/upgradecmd.go b/internal/cmd/upgradecmd.go index b0e6354ddad..fe8cd13cd2e 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/v59/github" + "github.com/google/go-github/v60/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 d9322c90235..5020d97a147 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/v59/github" + "github.com/google/go-github/v60/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 22ef5524957..f7c52acde06 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/v59/github" + "github.com/google/go-github/v60/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 e9e3d06ab04..367f6b20b69 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/v59/github" + "github.com/google/go-github/v60/github" "github.com/google/renameio/v2/maybe" "gopkg.in/yaml.v3"
chore
Update dependencies
1195746474ac1b6c4afa3074e8d2670116cbc739
2021-02-07 07:15:40
Tom Payne
docs: Update MEDIA.md
false
diff --git a/chezmoi2/cmd/docs.gen.go b/chezmoi2/cmd/docs.gen.go index 408ab3c1cc2..896f13b81c2 100644 --- a/chezmoi2/cmd/docs.gen.go +++ b/chezmoi2/cmd/docs.gen.go @@ -1951,6 +1951,7 @@ func init() { "| 2020-07-03 | 1.8.3 | Text | [Feeling at home in a LXD container](https://ubuntu.com/blog/feeling-at-home-in-a-lxd-container) |\n" + "| 2020-06-15 | 1.8.2 | Text | [Dotfiles management using chezmoi - How I Use Linux Desktop at Work Part5](https://blog.benoitj.ca/2020-06-15-how-i-use-linux-desktop-at-work-part5-dotfiles/) |\n" + "| 2020-04-27 | 1.8.0 | Text | [Managing my dotfiles with chezmoi](http://blog.emilieschario.com/post/managing-my-dotfiles-with-chezmoi/) |\n" + + "| 2020-04-20 | 1.8.0 | Text (FR) | [Gestion des dotfiles et des secrets avec chezmoi](https://blog.arkey.fr/2020/04/01/manage_dotfiles_with_chezmoi.fr/) |\n" + "| 2020-04-19 | 1.7.19 | Text (FR) | [Git & dotfiles : versionner ses fichiers de configuration](https://www.armandphilippot.com/dotfiles-git-fichiers-configuration/) |\n" + "| 2020-04-16 | 1.7.19 | Text (FR) | [Chezmoi, visite guidée](https://blog.wescale.fr/2020/04/16/chezmoi-visite-guidee/) |\n" + "| 2020-04-03 | 1.7.17 | Text | [Fedora Magazine: Take back your dotfiles with Chezmoi](https://fedoramagazine.org/take-back-your-dotfiles-with-chezmoi/) |\n" + diff --git a/cmd/docs.gen.go b/cmd/docs.gen.go index 67e5e2fff9f..2bdb97e31fe 100644 --- a/cmd/docs.gen.go +++ b/cmd/docs.gen.go @@ -1951,6 +1951,7 @@ func init() { "| 2020-07-03 | 1.8.3 | Text | [Feeling at home in a LXD container](https://ubuntu.com/blog/feeling-at-home-in-a-lxd-container) |\n" + "| 2020-06-15 | 1.8.2 | Text | [Dotfiles management using chezmoi - How I Use Linux Desktop at Work Part5](https://blog.benoitj.ca/2020-06-15-how-i-use-linux-desktop-at-work-part5-dotfiles/) |\n" + "| 2020-04-27 | 1.8.0 | Text | [Managing my dotfiles with chezmoi](http://blog.emilieschario.com/post/managing-my-dotfiles-with-chezmoi/) |\n" + + "| 2020-04-20 | 1.8.0 | Text (FR) | [Gestion des dotfiles et des secrets avec chezmoi](https://blog.arkey.fr/2020/04/01/manage_dotfiles_with_chezmoi.fr/) |\n" + "| 2020-04-19 | 1.7.19 | Text (FR) | [Git & dotfiles : versionner ses fichiers de configuration](https://www.armandphilippot.com/dotfiles-git-fichiers-configuration/) |\n" + "| 2020-04-16 | 1.7.19 | Text (FR) | [Chezmoi, visite guidée](https://blog.wescale.fr/2020/04/16/chezmoi-visite-guidee/) |\n" + "| 2020-04-03 | 1.7.17 | Text | [Fedora Magazine: Take back your dotfiles with Chezmoi](https://fedoramagazine.org/take-back-your-dotfiles-with-chezmoi/) |\n" + diff --git a/docs/MEDIA.md b/docs/MEDIA.md index 060e496a915..a37c579b78d 100644 --- a/docs/MEDIA.md +++ b/docs/MEDIA.md @@ -22,6 +22,7 @@ Recommended podcast: [FLOSS weekly episode 556: chezmoi](https://twit.tv/shows/f | 2020-07-03 | 1.8.3 | Text | [Feeling at home in a LXD container](https://ubuntu.com/blog/feeling-at-home-in-a-lxd-container) | | 2020-06-15 | 1.8.2 | Text | [Dotfiles management using chezmoi - How I Use Linux Desktop at Work Part5](https://blog.benoitj.ca/2020-06-15-how-i-use-linux-desktop-at-work-part5-dotfiles/) | | 2020-04-27 | 1.8.0 | Text | [Managing my dotfiles with chezmoi](http://blog.emilieschario.com/post/managing-my-dotfiles-with-chezmoi/) | +| 2020-04-20 | 1.8.0 | Text (FR) | [Gestion des dotfiles et des secrets avec chezmoi](https://blog.arkey.fr/2020/04/01/manage_dotfiles_with_chezmoi.fr/) | | 2020-04-19 | 1.7.19 | Text (FR) | [Git & dotfiles : versionner ses fichiers de configuration](https://www.armandphilippot.com/dotfiles-git-fichiers-configuration/) | | 2020-04-16 | 1.7.19 | Text (FR) | [Chezmoi, visite guidée](https://blog.wescale.fr/2020/04/16/chezmoi-visite-guidee/) | | 2020-04-03 | 1.7.17 | Text | [Fedora Magazine: Take back your dotfiles with Chezmoi](https://fedoramagazine.org/take-back-your-dotfiles-with-chezmoi/) |
docs
Update MEDIA.md
dba574df75e08849a7386039085003bdd94157f1
2024-02-17 02:25:20
Tom Payne
chore: Improve logging and error messages for spawned processes
false
diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 7f6cb81bd24..2b5fa96775b 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -2337,7 +2337,10 @@ func (c *Config) run(dir chezmoi.AbsPath, name string, args []string) error { cmd.Stdin = c.stdin cmd.Stdout = c.stdout cmd.Stderr = c.stderr - return c.baseSystem.RunCmd(cmd) + if err := chezmoilog.LogCmdRun(c.logger, cmd); err != nil { + return fmt.Errorf("%s: %w", name, err) + } + return nil } // runEditor runs the configured editor with args.
chore
Improve logging and error messages for spawned processes
f539253a4579b4e837793d8660acbaf5f44d93a2
2022-08-02 12:37:10
dependabot[bot]
chore(deps): bump actions/cache from 3.0.4 to 3.0.5
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 38826bc3a93..af412729a4d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -78,7 +78,7 @@ jobs: runs-on: macos-12 steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - - uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d + - uses: actions/cache@0865c47f36e68161719c5b124609996bb5c40129 with: path: ~/.vagrant.d key: ${{ runner.os }}-vagrant-debian-i386-${{ hashFiles('assets/vagrant/debian11-i386.Vagrantfile') }} @@ -104,7 +104,7 @@ jobs: runs-on: macos-12 steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - - uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d + - uses: actions/cache@0865c47f36e68161719c5b124609996bb5c40129 with: path: ~/.vagrant.d key: ${{ runner.os }}-vagrant-freebsd13-${{ hashFiles('assets/vagrant/freebsd13.Vagrantfile') }} @@ -150,7 +150,7 @@ jobs: runs-on: macos-12 steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - - uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d + - uses: actions/cache@0865c47f36e68161719c5b124609996bb5c40129 with: path: ~/.vagrant.d key: ${{ runner.os }}-vagrant-openbsd7-${{ hashFiles('assets/vagrant/openbsd7.Vagrantfile') }} @@ -266,7 +266,7 @@ jobs: with: cache: true go-version: 1.17.x - - uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d + - uses: actions/cache@0865c47f36e68161719c5b124609996bb5c40129 with: path: ~/go/pkg/mod key: ${{ runner.os }}-ubuntu-go-1-17-${{ hashFiles('**/go.sum') }} @@ -307,7 +307,7 @@ jobs: with: cache: true go-version: ${{ env.GO_VERSION }} - - uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d + - uses: actions/cache@0865c47f36e68161719c5b124609996bb5c40129 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
chore
bump actions/cache from 3.0.4 to 3.0.5
2c47d160bce8183b17b3fc0181afcf69d30a0d7d
2021-12-23 00:39:50
Tom Payne
docs: Add asdf installation instructions
false
diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 5193220c86f..7ded4a92347 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -67,6 +67,7 @@ Install chezmoi with a single command. | Windows | Scoop | `scoop bucket add twpayne https://github.com/twpayne/scoop-bucket && scoop install chezmoi` | | Windows | Chocolatey | `choco install chezmoi` | | FreeBSD | pkg | `pkg install chezmoi` | +| *multiple* | asdf | `asdf plugin add chezmoi && asdf install chezmoi <version>` | --- diff --git a/docs/RELATED.md b/docs/RELATED.md index 73d3d50aeb5..34d152629fd 100644 --- a/docs/RELATED.md +++ b/docs/RELATED.md @@ -3,6 +3,7 @@ <!--- toc ---> * [`github.com/alker0/chezmoi.vim`](#githubcomalker0chezmoivim) * [`github.com/hussainweb/ansible-role-chezmoi`](#githubcomhussainwebansible-role-chezmoi) +* [`github.com/joke/asdf-chezmoi`](#githubcomjokeasdf-chezmoi) * [`github.com/tcaxle/drapeau`](#githubcomtcaxledrapeau) * [`github.com/tuh8888/chezmoi.el`](#githubcomtuh8888chezmoiel) * [`github.com/Lilja/vim-chezmoi`](#githubcomliljavim-chezmoi) @@ -22,6 +23,12 @@ Installs chezmoi on Ubuntu and Debian servers. --- +## [`github.com/joke/asdf-chezmoi`](https://github.com/joke/asdf-chezmoi) + +chezmoi plugin for asdf version manager. + +--- + ## [`github.com/tcaxle/drapeau`](https://github.com/tcaxle/drapeau) An add-on to synchronise your colorschemes across systems and allow easy
docs
Add asdf installation instructions
efc8ddce480c35fae3c435797dc2114c556baf5c
2024-11-14 05:33:38
Tom Payne
chore: Update dependencies
false
diff --git a/go.mod b/go.mod index 675d12e058b..55c876cec74 100644 --- a/go.mod +++ b/go.mod @@ -12,12 +12,12 @@ require ( 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.2 - github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.4 + github.com/aws/aws-sdk-go-v2/config v1.28.3 + github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.5 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.0 + github.com/charmbracelet/bubbletea v1.2.2 github.com/charmbracelet/glamour v0.8.0 github.com/coreos/go-semver v0.3.1 github.com/fsnotify/fsnotify v1.8.0 @@ -46,12 +46,12 @@ require ( github.com/zricethezav/gitleaks/v8 v8.21.2 go.etcd.io/bbolt v1.3.11 go.uber.org/automaxprocs v1.6.0 - golang.org/x/crypto v0.28.0 - golang.org/x/crypto/x509roots/fallback v0.0.0-20241104001025-71ed71b4faf9 - golang.org/x/oauth2 v0.23.0 - golang.org/x/sync v0.8.0 - golang.org/x/sys v0.26.0 - golang.org/x/term v0.25.0 + golang.org/x/crypto v0.29.0 + golang.org/x/crypto/x509roots/fallback v0.0.0-20241107225453-6018723c7405 + golang.org/x/oauth2 v0.24.0 + golang.org/x/sync v0.9.0 + golang.org/x/sys v0.27.0 + golang.org/x/term v0.26.0 gopkg.in/ini.v1 v1.67.0 gopkg.in/yaml.v3 v3.0.1 howett.net/plist v1.0.1 @@ -69,18 +69,18 @@ require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.3.0 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/ProtonMail/go-crypto v1.1.0 // 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.43 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.17.44 // 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/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.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.32.4 // indirect github.com/aws/smithy-go v1.22.0 // indirect @@ -90,7 +90,7 @@ require ( 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/term v0.2.0 // 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 github.com/cyphar/filepath-securejoin v0.3.4 // indirect @@ -155,10 +155,10 @@ require ( github.com/yuin/goldmark-emoji v1.0.4 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect - golang.org/x/net v0.30.0 // indirect - golang.org/x/text v0.19.0 // indirect - golang.org/x/tools v0.26.0 // indirect + golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect + golang.org/x/net v0.31.0 // indirect + golang.org/x/text v0.20.0 // indirect + golang.org/x/tools v0.27.0 // indirect google.golang.org/protobuf v1.35.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index ed7ad4f01a1..26ff31069c0 100644 --- a/go.sum +++ b/go.sum @@ -53,8 +53,8 @@ github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSC github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/ProtonMail/go-crypto v1.1.0 h1:OnlSGxXflfrWJESDsGQOmACNQRM9IflG3q8XTrOqvbE= -github.com/ProtonMail/go-crypto v1.1.0/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= +github.com/ProtonMail/go-crypto v1.1.2 h1:A7JbD57ThNqh7XjmHE+PXpQ3Dqt3BrSAC0AL0Go3KS0= +github.com/ProtonMail/go-crypto v1.1.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/Shopify/ejson v1.5.3 h1:2TfdPKTkHXADrvxQrW+mOpl+btx0kDn4/kjzOQ1gIH8= github.com/Shopify/ejson v1.5.3/go.mod h1:bVvQ3MaBCfMOkIp1rWZcot3TruYXCc7qUUbI1tjs/YM= github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= @@ -73,10 +73,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.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.2 h1:FLvWA97elBiSPdIol4CXfIAY1wlq3KzoSgkMuZSuSe8= -github.com/aws/aws-sdk-go-v2/config v1.28.2/go.mod h1:hNmQsKfUqpKz2yfnZUB60GCemPmeqAalVTui0gOxjAE= -github.com/aws/aws-sdk-go-v2/credentials v1.17.43 h1:SEGdVOOE1Wyr2XFKQopQ5GYjym3nYHcphesdt78rNkY= -github.com/aws/aws-sdk-go-v2/credentials v1.17.43/go.mod h1:3aiza5kSyAE4eujSanOkSkAmX/RnVqslM+GRQ/Xvv4c= +github.com/aws/aws-sdk-go-v2/config v1.28.3 h1:kL5uAptPcPKaJ4q0sDUjUIdueO18Q7JDzl64GpVwdOM= +github.com/aws/aws-sdk-go-v2/config v1.28.3/go.mod h1:SPEn1KA8YbgQnwiJ/OISU4fz7+F6Fe309Jf0QTsRCl4= +github.com/aws/aws-sdk-go-v2/credentials v1.17.44 h1:qqfs5kulLUHUEXlHEZXLJkgGoF3kkUeFUTVA585cFpU= +github.com/aws/aws-sdk-go-v2/credentials v1.17.44/go.mod h1:0Lm2YJ8etJdEdw23s+q/9wTpOeo2HhNE97XcRa7T8MA= 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= @@ -89,10 +89,10 @@ github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 h1:TToQNkv 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.4 h1:YQheBh+MS27cJG1K6VO3A6AzNhkq8ETp1g7l0KMcdss= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.4/go.mod h1:FTCjaQxTVVQqLQ4ktBsLNZPnJ9pVLkJ6F0qVwtALaxk= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.4 h1:BqE3NRG6bsODh++VMKMsDmFuJTHrdD4rJZqHjDeF6XI= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.4/go.mod h1:wrMCEwjFPms+V86TCQQeOxQF/If4vT44FGIOFiMC2ck= +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.32.4 h1:yDxvkz3/uOKfxnv8YhzOi9m+2OGIxF+on3KOISbK5IU= @@ -119,8 +119,8 @@ 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.0 h1:WYHclJaFDOz4dPxiGx7owwb8P4000lYPcuXPIALS5Z8= -github.com/charmbracelet/bubbletea v1.2.0/go.mod h1:viLoDL7hG4njLJSKU2gw7kB3LSEmWsrM80rO1dBJWBI= +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/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= @@ -131,8 +131,8 @@ github.com/charmbracelet/x/ansi v0.4.5 h1:LqK4vwBNaXw2AyGIICa5/29Sbdq58GbGdFngSe github.com/charmbracelet/x/ansi v0.4.5/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= 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.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0= -github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0= +github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= +github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys= github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4= @@ -515,30 +515,30 @@ go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= -golang.org/x/crypto/x509roots/fallback v0.0.0-20241104001025-71ed71b4faf9 h1:4cEcP5+OjGppY79LCQ5Go2B1Boix2x0v6pvA01P3FoA= -golang.org/x/crypto/x509roots/fallback v0.0.0-20241104001025-71ed71b4faf9/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8= -golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY= -golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= +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/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= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= -golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= +golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= -golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= -golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= +golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= +golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -556,31 +556,31 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457 h1:zf5N6UOrA487eEFacMePxjXAJctxKmyjKUsjA11Uzuk= golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= +golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= -golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= +golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o= +golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
chore
Update dependencies
7e63edec4291a7ff6c14781d20b6217929a56880
2021-10-21 05:17:05
Tom Payne
chore: Bump github.com/twpayne/go-shell to v0.3.1
false
diff --git a/go.mod b/go.mod index 807259b1b66..444246b5efb 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( github.com/spf13/cobra v1.2.1 github.com/spf13/viper v1.9.0 github.com/stretchr/testify v1.7.0 - github.com/twpayne/go-shell v0.3.0 + github.com/twpayne/go-shell v0.3.1 github.com/twpayne/go-vfs/v4 v4.0.0 github.com/twpayne/go-xdg/v6 v6.0.0 github.com/xanzy/ssh-agent v0.3.1 // indirect diff --git a/go.sum b/go.sum index 28400cecc96..153299d3d95 100644 --- a/go.sum +++ b/go.sum @@ -429,8 +429,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/twpayne/go-shell v0.3.0 h1:nhDM9cQTqWwA0jGPOnqzsw8lke2jcKpvxDgnDO8Lq9o= -github.com/twpayne/go-shell v0.3.0/go.mod h1:H/gzux0DOH5jsjQSHXs6rs2Onxy+V4j6ycZTOulC0l8= +github.com/twpayne/go-shell v0.3.1 h1:JIC6cyDpG/p8mRnFUleH07roi90q0J9QC8PnvtmYLRo= +github.com/twpayne/go-shell v0.3.1/go.mod h1:H/gzux0DOH5jsjQSHXs6rs2Onxy+V4j6ycZTOulC0l8= github.com/twpayne/go-vfs/v3 v3.0.0 h1:rMFBISZVhSowKeX1BxL8utM64V7CuUw9/rfekPdS7to= github.com/twpayne/go-vfs/v3 v3.0.0/go.mod h1:JKfJtOC57Wqo7xYxFRKSqdXwyj3AhfyRrDxSE/XiAVA= github.com/twpayne/go-vfs/v4 v4.0.0 h1:NMq6wg8GZlX7IsgRZw5j0RiT/Q4qXzCsuxYYdK3T70c=
chore
Bump github.com/twpayne/go-shell to v0.3.1
637a64ea81e3e4d5533c9f471fa3db788a9b9d4f
2023-01-31 00:46:13
dependabot[bot]
chore(deps): bump actions/upload-artifact from 3.1.1 to 3.1.2
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 34f1bccb227..800e4cb15c4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -210,31 +210,31 @@ jobs: args: release --skip-publish --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@83fd05a356d7e2593de66fc9913b3002723633cb + uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce 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@83fd05a356d7e2593de66fc9913b3002723633cb + uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce with: name: chezmoi-darwin-arm64 path: dist/chezmoi-nocgo_darwin_arm64/chezmoi - name: upload-artifact-chezmoi-linux-amd64 if: github.event_name == 'push' || needs.changes.outputs.code == 'true' - uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb + uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce 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@83fd05a356d7e2593de66fc9913b3002723633cb + uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce 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@83fd05a356d7e2593de66fc9913b3002723633cb + uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce with: name: chezmoi-windows-amd64 path: dist/chezmoi-nocgo_windows_amd64_v1/chezmoi.exe
chore
bump actions/upload-artifact from 3.1.1 to 3.1.2
f3ef8be2c359628a1a51a551f6f9a539fddbcb0a
2022-03-20 04:27:27
Tom Payne
docs: Improve FAQ entry on source state filenames
false
diff --git a/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/design.md b/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/design.md index c2b02faeba1..b46c15a9d10 100644 --- a/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/design.md +++ b/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/design.md @@ -103,17 +103,21 @@ entries might not be usable with symlinks. In symlink mode, running `chezmoi add` does not immediately replace the targets with a symlink. You must run `chezmoi apply` to create the symlinks. -## Can I change how chezmoi's source state is represented on disk? +## Why does chezmoi use weird filenames? -There are a number of criticisms of how chezmoi's source state is represented -on disk: +There are a number of criticisms of how chezmoi uses filenames: -1. Not all possible file permissions can be represented. -2. The long source file names are weird and verbose. +1. The long source file names are weird and verbose. +2. Not all possible file permissions can be represented. 3. Everything is in a single directory, which can end up containing many entries. -chezmoi's source state representation is a deliberate, practical compromise. +chezmoi's decision to store metadata in filenames is a deliberate, practical, +compromise. + +Firstly, almost all programs store metadata in filenames: the filename's +extension. chezmoi extends this to storing metadata in attributes in the +filename's prefix as well. The `dot_` attribute makes it transparent which dotfiles are managed by chezmoi and which files are ignored by chezmoi. chezmoi ignores all files and
docs
Improve FAQ entry on source state filenames
83f01eb563a3ed1d9596a90f0d3f975d110090ca
2022-09-14 04:48:49
Tom Payne
fix: Only read source state if needed in source-path command
false
diff --git a/pkg/cmd/sourcepathcmd.go b/pkg/cmd/sourcepathcmd.go index 3edc594594f..4ed13e35abb 100644 --- a/pkg/cmd/sourcepathcmd.go +++ b/pkg/cmd/sourcepathcmd.go @@ -5,8 +5,6 @@ import ( "strings" "github.com/spf13/cobra" - - "github.com/twpayne/chezmoi/v2/pkg/chezmoi" ) func (c *Config) newSourcePathCmd() *cobra.Command { @@ -16,17 +14,22 @@ func (c *Config) newSourcePathCmd() *cobra.Command { Long: mustLongHelp("source-path"), Example: example("source-path"), ValidArgsFunction: c.targetValidArgs, - RunE: c.makeRunEWithSourceState(c.runSourcePathCmd), + RunE: c.runSourcePathCmd, } return sourcePathCmd } -func (c *Config) runSourcePathCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error { +func (c *Config) runSourcePathCmd(cmd *cobra.Command, args []string) error { if len(args) == 0 { return c.writeOutputString(c.SourceDirAbsPath.String() + "\n") } + sourceState, err := c.newSourceState(cmd.Context()) + if err != nil { + return err + } + sourceAbsPaths, err := c.sourceAbsPaths(sourceState, args) if err != nil { return err diff --git a/pkg/cmd/testdata/scripts/issue2354.txtar b/pkg/cmd/testdata/scripts/issue2354.txtar new file mode 100644 index 00000000000..c9ae77c44d5 --- /dev/null +++ b/pkg/cmd/testdata/scripts/issue2354.txtar @@ -0,0 +1,6 @@ +# test that chezmoi source-path does not read the source state if not needed +exec chezmoi source-path +stdout ${CHEZMOISOURCEDIR@R} + +-- home/user/.local/share/chezmoi/.chezmoiexternal.json -- +invalid JSON file
fix
Only read source state if needed in source-path command
9e6d5369ef808968118560b6f2b6a09a8220375d
2025-02-17 04:09:33
Austin Ziegler
chore: Upgrade Mermaid version
false
diff --git a/assets/chezmoi.io/docs/extra/refresh_on_toggle_dark_light.js b/assets/chezmoi.io/docs/extra/refresh_on_toggle_dark_light.js index c72afd7743d..ca39c59194d 100644 --- a/assets/chezmoi.io/docs/extra/refresh_on_toggle_dark_light.js +++ b/assets/chezmoi.io/docs/extra/refresh_on_toggle_dark_light.js @@ -1,10 +1,14 @@ -var paletteSwitcher1 = document.getElementById("__palette_1"); -var paletteSwitcher2 = document.getElementById("__palette_2"); +// The light palette is always the first palette. In some cases, it is numbered +// as __palette_0 and in others it is numbered as __palette_1. The dark palette +// is numbered as __palette_1 or __palette_2, depending on the index used for +// the light palette. +var paletteSwitcherLight = document.getElementById("__palette_0"); +var paletteSwitcherDark = document.getElementById("__palette_1"); -paletteSwitcher1.addEventListener("change", function () { - location.reload(); -}); +if (!paletteSwitcherLight) { + paletteSwitcherLight = paletteSwitcherDark; + paletteSwitcherDark = document.getElementById("__palette_2"); +} -paletteSwitcher2.addEventListener("change", function () { - location.reload(); -}); +paletteSwitcherLight.addEventListener("change", () => location.reload()); +paletteSwitcherDark.addEventListener("change", () => location.reload()); diff --git a/assets/chezmoi.io/mkdocs.yml b/assets/chezmoi.io/mkdocs.yml index 39b93ead4e7..0a0e01a86b0 100644 --- a/assets/chezmoi.io/mkdocs.yml +++ b/assets/chezmoi.io/mkdocs.yml @@ -380,8 +380,9 @@ hooks: plugins: - mermaid2: + version: 11.4.1 arguments: - # test if its __palette_1 (dark) or __palette_2 (light) + # test if its __palette_0/1 (dark) or __palette_1/2 (light) theme: | ^(JSON.parse(__md_get("__palette").index == 1)) ? 'dark' : 'light' - search diff --git a/uv.lock b/uv.lock index a393d4096b2..1fe3739a0cc 100644 --- a/uv.lock +++ b/uv.lock @@ -187,13 +187,16 @@ wheels = [ [[package]] name = "jsbeautifier" -version = "1.15.1" +version = "1.15.3" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "editorconfig" }, { name = "six" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/69/3e/dd37e1a7223247e3ef94714abf572415b89c4e121c4af48e9e4c392e2ca0/jsbeautifier-1.15.1.tar.gz", hash = "sha256:ebd733b560704c602d744eafc839db60a1ee9326e30a2a80c4adb8718adc1b24", size = 75606 } +sdist = { url = "https://files.pythonhosted.org/packages/cf/74/a37cc6fe8ab3f217657d345dfba0612758807536dca5ca5d2f6a81e3623d/jsbeautifier-1.15.3.tar.gz", hash = "sha256:5f1baf3d4ca6a615bb5417ee861b34b77609eeb12875555f8bbfabd9bf2f3457", size = 75261 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c5/09/cabdf2ed67ba8281ed2025e322c2fc9502a135f756c0a3a3eb60c12eb4fa/jsbeautifier-1.15.3-py3-none-any.whl", hash = "sha256:b207a15ab7529eee4a35ae7790e9ec4e32a2b5026d51e2d0386c3a65e6ecfc91", size = 94706 }, +] [[package]] name = "markdown"
chore
Upgrade Mermaid version
ac0edf90e416fcf8c01c8628025c1089a9b9c706
2025-03-07 06:11:07
Tom Payne
chore: Update tools
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 652c56b8701..e4e99d7afb2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ env: GOVERSIONINFO_VERSION: 1.4.1 # https://github.com/josephspurrier/goversioninfo/releases PYTHON_VERSION: '3.10' # https://www.python.org/downloads/ RAGE_VERSION: 0.11.1 # https://github.com/str4d/rage/releases - UV_VERSION: 0.6.4 # https://github.com/astral-sh/uv/releases + UV_VERSION: 0.6.5 # https://github.com/astral-sh/uv/releases jobs: changes: runs-on: ubuntu-22.04
chore
Update tools
86e6b2831aba6860dde12bb3d01d2804063d8754
2022-12-22 23:24:01
Tom Payne
feat: Add --path-style=source-{absolute,relative} option to managed command
false
diff --git a/assets/chezmoi.io/docs/reference/commands/managed.md b/assets/chezmoi.io/docs/reference/commands/managed.md index 928cee0c21b..65463f01dc2 100644 --- a/assets/chezmoi.io/docs/reference/commands/managed.md +++ b/assets/chezmoi.io/docs/reference/commands/managed.md @@ -4,7 +4,7 @@ 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. -## `-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`. @@ -18,5 +18,5 @@ directory. The default is `relative`. $ chezmoi managed -i dirs $ chezmoi managed -i dirs,files $ chezmoi managed -i files ~/.config - $ chezmoi managed --exclude=encrypted + $ chezmoi managed --exclude=encrypted --path-style=source-relative ``` diff --git a/pkg/cmd/managedcmd.go b/pkg/cmd/managedcmd.go index d85cdfd26ed..1377edfaba1 100644 --- a/pkg/cmd/managedcmd.go +++ b/pkg/cmd/managedcmd.go @@ -53,7 +53,7 @@ func (c *Config) runManagedCmd(cmd *cobra.Command, args []string, sourceState *c } } - var targetRelPaths chezmoi.RelPaths + var paths []string _ = sourceState.ForEach(func(targetRelPath chezmoi.RelPath, sourceStateEntry chezmoi.SourceStateEntry) error { if !c.managed.filter.IncludeSourceStateEntry(sourceStateEntry) { return nil @@ -81,19 +81,25 @@ func (c *Config) runManagedCmd(cmd *cobra.Command, args []string, sourceState *c } } - targetRelPaths = append(targetRelPaths, targetRelPath) - return nil - }) - - sort.Sort(targetRelPaths) - builder := strings.Builder{} - for _, targetRelPath := range targetRelPaths { + var path string switch c.managed.pathStyle { case pathStyleAbsolute: - fmt.Fprintln(&builder, c.DestDirAbsPath.Join(targetRelPath)) + path = c.DestDirAbsPath.Join(targetRelPath).String() case pathStyleRelative: - fmt.Fprintln(&builder, targetRelPath) + path = targetRelPath.String() + case pathStyleSourceAbsolute: + path = c.SourceDirAbsPath.Join(sourceStateEntry.SourceRelPath().RelPath()).String() + case pathStyleSourceRelative: + path = sourceStateEntry.SourceRelPath().RelPath().String() } + paths = append(paths, path) + return nil + }) + + sort.Strings(paths) + builder := strings.Builder{} + for _, path := range paths { + fmt.Fprintln(&builder, path) } return c.writeOutputString(builder.String()) } diff --git a/pkg/cmd/pathstyle.go b/pkg/cmd/pathstyle.go index ec46619acb3..1d846b0740f 100644 --- a/pkg/cmd/pathstyle.go +++ b/pkg/cmd/pathstyle.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "strings" "github.com/twpayne/chezmoi/v2/pkg/chezmoi" ) @@ -9,14 +10,18 @@ import ( type pathStyle string const ( - pathStyleAbsolute pathStyle = "absolute" - pathStyleRelative pathStyle = "relative" + pathStyleAbsolute pathStyle = "absolute" + pathStyleRelative pathStyle = "relative" + pathStyleSourceAbsolute pathStyle = "source-absolute" + pathStyleSourceRelative pathStyle = "source-relative" ) var ( pathStyleStrings = []string{ pathStyleAbsolute.String(), pathStyleRelative.String(), + pathStyleSourceAbsolute.String(), + pathStyleSourceRelative.String(), } pathStyleFlagCompletionFunc = chezmoi.FlagCompletionFunc(pathStyleStrings) @@ -39,5 +44,5 @@ func (p pathStyle) String() string { // Type implements github.com/spf13/pflag.Value.Type. func (p pathStyle) Type() string { - return "absolute|relative" + return strings.Join(pathStyleStrings, "|") } diff --git a/pkg/cmd/testdata/scripts/managed.txtar b/pkg/cmd/testdata/scripts/managed.txtar index 1908e33b84d..99c46e8a9d6 100644 --- a/pkg/cmd/testdata/scripts/managed.txtar +++ b/pkg/cmd/testdata/scripts/managed.txtar @@ -64,6 +64,14 @@ cmp stdout golden/managed-with-absent-args [!windows] exec chezmoi managed --path-style=absolute [!windows] cmpenv stdout golden/managed-absolute +# test chezmoi managed --path-style=source-absolute +exec chezmoi managed --path-style=source-absolute +cmpenv stdout golden/managed-source-absolute + +# test chezmoi managed --path-style=source-relative +exec chezmoi managed --path-style=source-relative +cmp stdout golden/managed-source-relative + chhome home2/user # test that chezmoi managed does not evaluate templates @@ -186,6 +194,36 @@ $WORK/home/user/.template .symlink -- golden/managed-include-templates -- .template +-- golden/managed-source-absolute -- +${CHEZMOISOURCEDIR}/create_dot_create +${CHEZMOISOURCEDIR}/dot_dir +${CHEZMOISOURCEDIR}/dot_dir/exact_subdir +${CHEZMOISOURCEDIR}/dot_dir/exact_subdir/file +${CHEZMOISOURCEDIR}/dot_dir/file +${CHEZMOISOURCEDIR}/dot_file +${CHEZMOISOURCEDIR}/dot_remove +${CHEZMOISOURCEDIR}/dot_template.tmpl +${CHEZMOISOURCEDIR}/empty_dot_empty +${CHEZMOISOURCEDIR}/encrypted_dot_encrypted +${CHEZMOISOURCEDIR}/executable_dot_executable +${CHEZMOISOURCEDIR}/private_dot_private +${CHEZMOISOURCEDIR}/readonly_dot_readonly +${CHEZMOISOURCEDIR}/symlink_dot_symlink +-- golden/managed-source-relative -- +create_dot_create +dot_dir +dot_dir/exact_subdir +dot_dir/exact_subdir/file +dot_dir/file +dot_file +dot_remove +dot_template.tmpl +empty_dot_empty +encrypted_dot_encrypted +executable_dot_executable +private_dot_private +readonly_dot_readonly +symlink_dot_symlink -- golden/managed-with-absent-args -- .dir .dir/file
feat
Add --path-style=source-{absolute,relative} option to managed command
dfcd55e2b55460a9e6edfe52f915feca0e4e09fc
2025-01-05 05:57:37
Tom Payne
chore: Fix potential clean-up issue in test
false
diff --git a/internal/chezmoi/persistentstate_test.go b/internal/chezmoi/persistentstate_test.go index e5d69c0d702..4cdc1c08f27 100644 --- a/internal/chezmoi/persistentstate_test.go +++ b/internal/chezmoi/persistentstate_test.go @@ -18,6 +18,7 @@ func testPersistentState(t *testing.T, constructor func() PersistentState) { ) s1 := constructor() + defer s1.Close() assert.NoError(t, s1.Delete(bucket1, value)) @@ -42,6 +43,8 @@ func testPersistentState(t *testing.T, constructor func() PersistentState) { })) s2 := constructor() + defer s2.Close() + assert.NoError(t, s1.CopyTo(s2)) actualValue, err = s2.Get(bucket1, key) assert.NoError(t, err)
chore
Fix potential clean-up issue in test
313d232471ec8ebde09d4eb6c8517f0d338cd069
2024-04-17 18:40:41
momantech
chore: Fix function names in comments
false
diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go index a5648d5fbd7..48c0d9d26f9 100644 --- a/internal/chezmoi/sourcestate.go +++ b/internal/chezmoi/sourcestate.go @@ -2191,7 +2191,7 @@ func (s *SourceState) newSourceStateFileEntryFromSymlink( }, nil } -// populateImplicitDirs creates implicit parent directories for externalRelPath. +// populateImplicitParentDirs creates implicit parent directories for externalRelPath. func (s *SourceState) populateImplicitParentDirs( externalRelPath RelPath, external *External, diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index d26a1746786..7026c8385f8 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -138,7 +138,7 @@ func example(command string) string { return help.example } -// extractHelps returns the helps parse from r. +// extractHelp returns the helps parse from r. func extractHelp(command string, data []byte, longHelpTermRenderer, exampleTermRenderer *glamour.TermRenderer) (*help, error) { type stateType int const ( diff --git a/internal/cmd/util.go b/internal/cmd/util.go index 4c8eee25160..2609eb63c33 100644 --- a/internal/cmd/util.go +++ b/internal/cmd/util.go @@ -130,7 +130,7 @@ func upperSnakeCaseToCamelCase(s string) string { return strings.Join(words, "") } -// upperSnakeCaseToCamelCaseKeys returns m with all keys converted from +// upperSnakeCaseToCamelCaseMap returns m with all keys converted from // UPPER_SNAKE_CASE to camelCase. func upperSnakeCaseToCamelCaseMap[V any](m map[string]V) map[string]V { result := make(map[string]V)
chore
Fix function names in comments
b64f2bc121d1097b91cf608fc38aff9e6b0368c0
2023-10-11 00:58:54
Tom Payne
feat: Add env config var as an alternative to scriptEnv
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 3ad788ae3f0..fa51bef177c 100644 --- a/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml +++ b/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml @@ -19,6 +19,9 @@ sections: description: Destination directory encryption: description: Encryption type, either `age` or `gpg` + env: + type: object + description: Extra environment variables for scripts and commands format: default: '`json`' description: Format for data output, either `json` or `yaml` diff --git a/assets/chezmoi.io/docs/reference/target-types.md b/assets/chezmoi.io/docs/reference/target-types.md index 05c515ef392..91c22df2d51 100644 --- a/assets/chezmoi.io/docs/reference/target-types.md +++ b/assets/chezmoi.io/docs/reference/target-types.md @@ -94,7 +94,7 @@ directory that exists and is a directory. chezmoi sets a number of `CHEZMOI*` environment variables when running scripts, corresponding to commonly-used template data variables. Extra environment -variables can be set in the `scriptEnv` configuration variable. +variables can be set in the `env` or `scriptEnv` configuration variables. ### Scripts on Windows diff --git a/internal/cmd/config.go b/internal/cmd/config.go index ec02306baf9..b7db4cd707f 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -100,6 +100,7 @@ type ConfigFile struct { CacheDirAbsPath chezmoi.AbsPath `json:"cacheDir" mapstructure:"cacheDir" yaml:"cacheDir"` Color autoBool `json:"color" mapstructure:"color" yaml:"color"` Data map[string]any `json:"data" mapstructure:"data" yaml:"data"` + Env map[string]string `json:"env" mapstructure:"env" yaml:"env"` Format writeDataFormat `json:"format" mapstructure:"format" yaml:"format"` DestDirAbsPath chezmoi.AbsPath `json:"destDir" mapstructure:"destDir" yaml:"destDir"` GitHub gitHubConfig `json:"gitHub" mapstructure:"gitHub" yaml:"gitHub"` @@ -2124,7 +2125,16 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error os.Setenv(key, valueStr) } } - for key, value := range c.ScriptEnv { + var env map[string]string + switch { + case len(c.Env) != 0 && len(c.ScriptEnv) != 0: + return errors.New("only one of env or scriptEnv may be set") + case len(c.Env) != 0: + env = c.Env + case len(c.ScriptEnv) != 0: + env = c.ScriptEnv + } + for key, value := range env { if strings.HasPrefix(key, "CHEZMOI_") { c.errorf("warning: %s: overriding reserved environment variable", key) } diff --git a/internal/cmd/testdata/scripts/issue3268.txtar b/internal/cmd/testdata/scripts/issue3268.txtar index b33956e7f21..d0f7eed1709 100644 --- a/internal/cmd/testdata/scripts/issue3268.txtar +++ b/internal/cmd/testdata/scripts/issue3268.txtar @@ -4,9 +4,32 @@ exec chezmoi execute-template '{{ output "chezmoi-test-command" }}' stdout 'CHEZMOI_SOURCE_DIR=.*/\.local/share/chezmoi\s?$' +chhome home2/user + +# test that chezmoi sets environment variables from env +exec chezmoi execute-template '{{ env "VAR" }}' +stdout VALUE + +chhome home3/user + +# test that env and scriptEnv cannot both be set +! exec chezmoi execute-template '' +stderr 'only one of env or scriptEnv may be set' + -- bin/chezmoi-test-command -- #!/bin/sh echo CHEZMOI_SOURCE_DIR=${CHEZMOI_SOURCE_DIR} -- bin/chezmoi-test-command.cmd -- @echo CHEZMOI_SOURCE_DIR=%CHEZMOI_SOURCE_DIR% +-- home2/user/.config/chezmoi/chezmoi.json -- +{ + "env": { + "VAR": "VALUE" + } +} +-- home3/user/.config/chezmoi/chezmoi.yaml -- +env: + VAR: VALUE +scriptEnv: + VAR: VALUE
feat
Add env config var as an alternative to scriptEnv
851efe3ce0c038cc3404a37dcc7a92d986940fe6
2022-07-22 11:52:20
Tom Payne
fix: Fix dropping of input when prompting for multiple values from piped stdin
false
diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index 232ec050e78..3b68df5d5f4 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -182,9 +182,10 @@ type Config struct { homeDirAbsPath chezmoi.AbsPath encryption chezmoi.Encryption - stdin io.Reader - stdout io.Writer - stderr io.Writer + stdin io.Reader + stdout io.Writer + stderr io.Writer + bufioReader *bufio.Reader tempDirs map[string]chezmoi.AbsPath @@ -1842,7 +1843,10 @@ func (c *Config) readLine(prompt string) (string, error) { if err != nil { return "", err } - line, err := bufio.NewReader(c.stdin).ReadString('\n') + if c.bufioReader == nil { + c.bufioReader = bufio.NewReader(c.stdin) + } + line, err := c.bufioReader.ReadString('\n') if err != nil { return "", err }
fix
Fix dropping of input when prompting for multiple values from piped stdin
52ef7cec7e2a31febeff846e7ecdda7aad5ece67
2025-02-13 03:48:30
Tom Payne
chore: Update tools
false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 77d76cc684f..20ec3c3e78e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,13 +21,13 @@ env: FIND_TYPOS_VERSION: 0.0.3 # https://github.com/twpayne/find-typos/tags GO_VERSION: 1.23.6 # https://go.dev/doc/devel/release GOFUMPT_VERSION: 0.7.0 # https://github.com/mvdan/gofumpt/releases - GOLANGCI_LINT_VERSION: 1.63.4 # https://github.com/golangci/golangci-lint/releases + GOLANGCI_LINT_VERSION: 1.64.2 # https://github.com/golangci/golangci-lint/releases GOLINES_VERSION: 0.12.2 # https://github.com/segmentio/golines/releases - GORELEASER_VERSION: 2.6.1 # https://github.com/goreleaser/goreleaser/releases + GORELEASER_VERSION: 2.7.0 # https://github.com/goreleaser/goreleaser/releases GOVERSIONINFO_VERSION: 1.4.1 # https://github.com/josephspurrier/goversioninfo/releases PYTHON_VERSION: '3.10' # https://www.python.org/downloads/ RAGE_VERSION: 0.11.1 # https://github.com/str4d/rage/releases - UV_VERSION: 0.5.29 # https://github.com/astral-sh/uv/releases + UV_VERSION: 0.5.30 # https://github.com/astral-sh/uv/releases jobs: changes: runs-on: ubuntu-22.04 diff --git a/.golangci.yml b/.golangci.yml index ab0145fa87c..3b94a8f1e85 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -66,7 +66,6 @@ linters: - stylecheck - tagalign - tagliatelle - - tenv - testableexamples - testifylint - thelper diff --git a/internal/cmd/gopasstemplatefuncs.go b/internal/cmd/gopasstemplatefuncs.go index 60fca9f902b..b04e13bb62b 100644 --- a/internal/cmd/gopasstemplatefuncs.go +++ b/internal/cmd/gopasstemplatefuncs.go @@ -109,7 +109,7 @@ func (c *Config) builtinGopassClient() (*api.Gopass, error) { } return c.Gopass.passwordCache[filename], nil }) - c.Gopass.ctx = ctx + c.Gopass.ctx = ctx //nolint:fatcontext c.Gopass.client, c.Gopass.clientErr = api.New(c.Gopass.ctx) return c.Gopass.client, c.Gopass.clientErr }
chore
Update tools
b9d55e09dbadd0888b8914f1ad316a203e94d08c
2022-11-30 07:21:24
Evgeny
docs: Update stat.md to reference os.Stat
false
diff --git a/assets/chezmoi.io/docs/reference/templates/functions/stat.md b/assets/chezmoi.io/docs/reference/templates/functions/stat.md index c341a2849e5..df57fe5774d 100644 --- a/assets/chezmoi.io/docs/reference/templates/functions/stat.md +++ b/assets/chezmoi.io/docs/reference/templates/functions/stat.md @@ -1,10 +1,10 @@ # `stat` *name* -`stat` runs `stat(2)` on *name*. If *name* exists it returns structured data. -If *name* does not exist then it returns a false value. If `stat(2)` returns -any other error then it raises an error. The structured value returned if -*name* exists contains the fields `name`, `size`, `mode`, `perm`, `modTime`, -and `isDir`. +`stat` runs [`os.Stat`](https://pkg.go.dev/os#File.Stat) on *name*. If *name* +exists it returns structured data. If *name* does not exist then it returns a +false value. If `os.Stat` returns any other error then it raises an error. The +structured value returned if *name* exists contains the fields `name`, `size`, +`mode`, `perm`, `modTime`, and `isDir`. `stat` is not hermetic: its return value depends on the state of the filesystem at the moment the template is executed. Exercise caution when using it in your
docs
Update stat.md to reference os.Stat
cdc101da6ca1667f501771698b05b50e3d6ea13a
2021-11-02 03:40:47
Tom Payne
chore: Update dependencies
false
diff --git a/go.mod b/go.mod index 6c08b8b09ce..4681f6fe4a5 100644 --- a/go.mod +++ b/go.mod @@ -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.1 // indirect + github.com/yuin/goldmark v1.4.2 // 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-20211015210444-4f30a5c0130f // indirect - golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 - golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 + golang.org/x/net v0.0.0-20211029224645-99673261e6eb // indirect + golang.org/x/oauth2 v0.0.0-20211028175245-ba495a64dcb5 + golang.org/x/sys v0.0.0-20211031064116-611d5d643895 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 @@ -52,10 +52,10 @@ require ( require ( github.com/Microsoft/go-winio v0.5.1 // indirect - github.com/godbus/dbus/v5 v5.0.5 // indirect + github.com/godbus/dbus/v5 v5.0.6 // indirect github.com/google/gops v0.3.22 github.com/mattn/go-isatty v0.0.14 // indirect - github.com/shopspring/decimal v1.3.0 // indirect + github.com/shopspring/decimal v1.3.1 // indirect github.com/stretchr/objx v0.3.0 // indirect golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect golang.org/x/text v0.3.7 // indirect diff --git a/go.sum b/go.sum index d5143ccdc06..d97bdc0889a 100644 --- a/go.sum +++ b/go.sum @@ -196,6 +196,8 @@ github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.5 h1:9Eg0XUhQxtkV8ykTMKtMMYY72g4NgxtRq4jgh4Ih5YM= github.com/godbus/dbus/v5 v5.0.5/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus/v5 v5.0.6 h1:mkgN1ofwASrYnJ5W6U/BxG15eXXXjirgZc7CLqkcaro= +github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= @@ -503,6 +505,8 @@ github.com/shirou/gopsutil/v3 v3.21.9/go.mod h1:YWp/H8Qs5fVmf17v7JNZzA0mPJ+mS2e9 github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.0 h1:KK3gWIXskZ2O1U/JNTisNcvH+jveJxZYrjbTsrbbnh8= github.com/shopspring/decimal v1.3.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +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/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= @@ -565,6 +569,8 @@ github.com/yuin/goldmark v1.3.3/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= 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-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= @@ -694,6 +700,8 @@ golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211029224645-99673261e6eb h1:pirldcYWx7rx7kE5r+9WsOXPXK0+WH5+uZ7uPmJ44uM= +golang.org/x/net v0.0.0-20211029224645-99673261e6eb/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= @@ -712,6 +720,8 @@ golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 h1:B333XXssMuKQeBwiNODx4TupZy7bf4sxFZnN2ZOcvUE= golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211028175245-ba495a64dcb5 h1:v79phzBz03tsVCUTbvTBmmC3CUXF5mKYt7DA4ZVldpM= +golang.org/x/oauth2 v0.0.0-20211028175245-ba495a64dcb5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -796,6 +806,8 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjq golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 h1:2B5p2L5IfGiD7+b9BOoRMC6DgObAVZV+Fsp050NqXik= golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211031064116-611d5d643895 h1:iaNpwpnrgL5jzWS0vCNnfa8HqzxveCFpFx3uC/X4Tps= +golang.org/x/sys v0.0.0-20211031064116-611d5d643895/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=
chore
Update dependencies
267f30f6ef190053434090fd398a488c1487c7a8
2021-12-02 10:41:01
Tom Payne
chore: Bump Void Linux docker image version
false
diff --git a/assets/docker/voidlinux.Dockerfile b/assets/docker/voidlinux.Dockerfile index 8e585a8ff04..0511dad1ee5 100644 --- a/assets/docker/voidlinux.Dockerfile +++ b/assets/docker/voidlinux.Dockerfile @@ -1,4 +1,4 @@ -FROM voidlinux/voidlinux:latest +FROM ghcr.io/void-linux/void-linux:20211130rc01-full-x86_64 RUN \ xbps-install --sync --update --yes && \
chore
Bump Void Linux docker image version
24db084983f39c746da83c67ea4e7d07544e9430
2022-07-20 02:06:02
Tom Payne
docs: Prioritize package installation over curl | sh installation
false
diff --git a/assets/chezmoi.io/docs/install.md.tmpl b/assets/chezmoi.io/docs/install.md.tmpl index 7f7e8bd60bc..c344be78126 100644 --- a/assets/chezmoi.io/docs/install.md.tmpl +++ b/assets/chezmoi.io/docs/install.md.tmpl @@ -3,48 +3,6 @@ The latest version of chezmoi is {{ $version }}. -## One-line binary install - -Install the correct binary for your operating system and architecture in `./bin` -with a single command: - -=== "curl" - - ```sh - sh -c "$(curl -fsLS https://chezmoi.io/get)" - ``` - -=== "wget" - - ```sh - sh -c "$(wget -qO- https://chezmoi.io/get)" - ``` - -=== "PowerShell" - - ```powershell - (irm -useb https://chezmoi.io/get.ps1) | powershell -c - - ``` - -!!! hint - - If you already have a dotfiles repo using chezmoi on GitHub at - `https://github.com/$GITHUB_USERNAME/dotfiles` then you can install - chezmoi and your dotfiles with the single command: - - ```sh - sh -c "$(curl -fsLS https://chezmoi.io/get)" -- init --apply $GITHUB_USERNAME - ``` - -!!! hint - - To install the chezmoi binary in a different directory, use the `-b` option, - for example: - - ```sh - sh -c "$(curl -fsLS https://chezmoi.io/get)" -- -b $HOME/.local/bin - ``` - ## One-line package install Install chezmoi with your package manager with a single command: @@ -157,6 +115,48 @@ Install chezmoi with your package manager with a single command: pkg install application/chezmoi ``` +## One-line binary install + +Install the correct binary for your operating system and architecture in `./bin` +with a single command: + +=== "curl" + + ```sh + sh -c "$(curl -fsLS https://chezmoi.io/get)" + ``` + +=== "wget" + + ```sh + sh -c "$(wget -qO- https://chezmoi.io/get)" + ``` + +=== "PowerShell" + + ```powershell + (irm -useb https://chezmoi.io/get.ps1) | powershell -c - + ``` + +!!! hint + + If you already have a dotfiles repo using chezmoi on GitHub at + `https://github.com/$GITHUB_USERNAME/dotfiles` then you can install + chezmoi and your dotfiles with the single command: + + ```sh + sh -c "$(curl -fsLS https://chezmoi.io/get)" -- init --apply $GITHUB_USERNAME + ``` + +!!! hint + + To install the chezmoi binary in a different directory, use the `-b` option, + for example: + + ```sh + sh -c "$(curl -fsLS https://chezmoi.io/get)" -- -b $HOME/.local/bin + ``` + ## Download a pre-built Linux package Download a package for your distribution and architecture.
docs
Prioritize package installation over curl | sh installation