chezmoi is written in Go and development happens on GitHub. The rest of this document assumes that you've checked out chezmoi locally.
chezmoi is a standard Go project, using standard Go tooling, with a few extra tools. Install these extra tools with:
make install-tools
Build chezmoi:
go build .
Run all tests:
go test ./...
Run chezmoi:
go run .
Bug reports, bug fixes, and documentation improvements are always welcome. Please open an issue or create a pull request with your report, fix, or improvement.
If you want to make a more significant change, please first open an issue to discuss the change that you want to make. Dave Cheney gives a good rationale as to why this is important.
All changes are made via pull requests. In your pull request, please make sure that:
-
All existing tests pass.
-
There are appropriate additional tests that demonstrate that your PR works as intended.
-
The documentation is updated, if necessary. For new features you should add an entry in
docs/HOWTO.mdand a complete description indocs/REFERENCE.md. -
The code is correctly formatted, according to gofumports. You can ensure this by running
make format. -
The code passes
go vetandgolangci-lint. You can ensure this by runningmake lint. -
The commit messages match chezmoi's convention, specifically that they begin with a capitalized verb in the imperative and give a short description of what the commit does. Detailed information or justification can be optionally included in the body of the commit message.
-
Commits are logically separate, with no merge or "fixup" commits.
-
The branch applies cleanly to
master.
Releases are managed with goreleaser.
To create a new release, push a tag, eg:
git tag -a v0.1.0 -m "First release"
git push origin v0.1.0
To run a local "snapshot" build without publishing:
make test-release
If you plan to package chezmoi for your distibution, then note:
-
Please set the version number, git commit, and build time in the binary. This is done by passing the linker flags:
-X github.com/twpayne/chezmoi/cmd.VersionStr={{ .Version }} -X github.com/twpayne/chezmoi/cmd.Commit={{ .Commit }} -X github.com/twpayne/chezmoi/cmd.Date={{ .Date }} -
Please enable CGO, if possible. chezmoi can be built and run without CGO, but the
.chezmoi.grouptemplate variable may not be set on some systems. -
chezmoi includes a
docscommand which prints its documentation. By default, the docs are embedded in the binary. You can disable this behaviour, and have chezmoi read its docs from the filesystem by building with thenoembeddocsbuild tag and setting the directory where chezmoi can find them with the-X github.com/twpayne/chezmoi/cmd.DocDir={{ .PathToDocs }}linker flag. For example:go build -tags noembeddocs -ldflags "-X github.com/twpayne/chezmoi/cmd.DocsDir=/usr/share/doc/chezmoi" .To disable the
docscommand completely, use thenodocsbuild tag. -
chezmoi includes an
upgradecommand which attempts to self-upgrade. You can remove this command completely by building chezmoi with thenoupgradebuild tag. -
chezmoi includes shell completions in the
completionsdirectory. Please include these in the package and install them in the shell-appropriate directory, if possible.