Skip to content

Commit

Permalink
chore: Move core packages back to internal
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Jul 30, 2023
1 parent e649df2 commit ad2ab65
Show file tree
Hide file tree
Showing 457 changed files with 165 additions and 164 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- 'assets/scripts/**'
- 'assets/vagrant/**'
- 'go.*'
- 'pkg/**'
- 'internal/**'
codeql:
needs: changes
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
Expand Down Expand Up @@ -252,13 +252,13 @@ jobs:
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
go test -ldflags="-X github.com/twpayne/chezmoi/v2/pkg/chezmoitest.umaskStr=0o022" -race ./...
go test -ldflags="-X github.com/twpayne/chezmoi/v2/internal/chezmoitest.umaskStr=0o022" -race ./...
- name: test-umask-002
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
go test -ldflags="-X github.com/twpayne/chezmoi/v2/pkg/chezmoitest.umaskStr=0o002" -race ./...
go test -ldflags="-X github.com/twpayne/chezmoi/v2/internal/chezmoitest.umaskStr=0o002" -race ./...
- name: test-install.sh
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
run: |
Expand Down
16 changes: 8 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ linters-settings:
- github\.com/go-git/go-git/v5/plumbing/format/diff\.File
- github\.com/go-git/go-git/v5/plumbing/format/diff\.Patch
- 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\.Format
- github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.PersistentState
- 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
- github\.com/twpayne/chezmoi/v2/internal/chezmoi\.ActualStateEntry
- github\.com/twpayne/chezmoi/v2/internal/chezmoi\.Encryption
- github\.com/twpayne/chezmoi/v2/internal/chezmoi\.Format
- github\.com/twpayne/chezmoi/v2/internal/chezmoi\.PersistentState
- github\.com/twpayne/chezmoi/v2/internal/chezmoi\.SourceStateOrigin
- github\.com/twpayne/chezmoi/v2/internal/chezmoi\.SourceStateEntry
- github\.com/twpayne/chezmoi/v2/internal/chezmoi\.System
- github\.com/twpayne/chezmoi/v2/internal/chezmoi\.TargetStateEntry
- github\.com/twpayne/go-vfs/v4\.FS
- stdlib
misspell:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ rm-dist:

.PHONY: test
test:
${GO} test -ldflags="-X github.com/twpayne/chezmoi/v2/pkg/chezmoitest.umaskStr=0o022" ./...
${GO} test -ldflags="-X github.com/twpayne/chezmoi/v2/pkg/chezmoitest.umaskStr=0o002" ./...
${GO} test -ldflags="-X github.com/twpayne/chezmoi/v2/internal/chezmoitest.umaskStr=0o022" ./...
${GO} test -ldflags="-X github.com/twpayne/chezmoi/v2/internal/chezmoitest.umaskStr=0o002" ./...

.PHONY: test-docker
test-docker:
Expand Down
27 changes: 14 additions & 13 deletions assets/chezmoi.io/docs/developer/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ You can generate Go documentation for chezmoi's source code with `go doc`, for
example:

```console
$ go doc -all -u github.com/twpayne/chezmoi/v2/pkg/chezmoi
$ go doc -all -u github.com/twpayne/chezmoi/v2/internal/chezmoi
```

You can also [browse chezmoi's generated documentation
Expand All @@ -17,12 +17,12 @@ online](https://pkg.go.dev/github.com/twpayne/chezmoi/v2).

The important directories in chezmoi are:

| Directory | Contents |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `assets/chezmoi.io/docs/` | The documentation single source of truth. Help text, examples, and the [chezmoi.io](https://chezmoi.io) website are generated from the files in this directory |
| `pkg/chezmoi/` | chezmoi's core functionality |
| `pkg/cmd/` | Code for the `chezmoi` command |
| `pkg/cmd/testdata/scripts/` | High-level tests of chezmoi's commands using [`testscript`](https://pkg.go.dev/github.com/rogpeppe/go-internal/testscript)
| Directory | Contents |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `assets/chezmoi.io/docs/` | The documentation single source of truth. Help text, examples, and the [chezmoi.io](https://chezmoi.io) website are generated from the files in this directory |
| `internal/chezmoi/` | chezmoi's core functionality |
| `internal/cmd/` | Code for the `chezmoi` command |
| `internal/cmd/testdata/scripts/` | High-level tests of chezmoi's commands using [`testscript`](https://pkg.go.dev/github.com/rogpeppe/go-internal/testscript)

## Key concepts

Expand All @@ -36,7 +36,7 @@ represented directly in chezmoi's code.
chezmoi uses the generic term *entry* to describe something that it manages.
Entries can be files, directories, symlinks, scripts, amongst other things.

## `pkg/chezmoi/` directory
## `internal/chezmoi/` directory

All of chezmoi's interaction with the operating system is abstracted through
the `System` interface. A `System` includes functionality to read and write
Expand Down Expand Up @@ -99,10 +99,10 @@ its persistent state. chezmoi can then detect if a third party has updated a
target since chezmoi last wrote it by comparing the actual state entry in the
target state with the entry state in the persistent state.

## `pkg/cmd/` directory
## `internal/cmd/` directory

`pkg/cmd/*cmd.go` contains the code for each individual command and
`pkg/cmd/*templatefuncs.go` contain the template functions.
`internal/cmd/*cmd.go` contains the code for each individual command and
`internal/cmd/*templatefuncs.go` contain the template functions.

Commands are defined as methods on the `Config` struct. The `Config` struct is
large, containing all configuration values read from the config file, command
Expand Down Expand Up @@ -163,12 +163,13 @@ integration tests use the
[`github.com/alecthomas/assert/v2`](https://pkg.go.dev/github.com/alecthomas/assert)
framework. End-to-end tests use
[`github.com/rogpeppe/go-internal/testscript`](https://pkg.go.dev/github.com/rogpeppe/go-internal/testscript)
with the test scripts themselves in `pkg/cmd/testdata/scripts/$TEST_NAME.txtar`.
with the test scripts themselves in
`internal/cmd/testdata/scripts/$TEST_NAME.txtar`.

You can run individual end-to-end tests with

```console
$ go test ./pkg/cmd -run=TestScript/$TEST_NAME
$ go test ./internal/cmd -run=TestScript/$TEST_NAME
```

Tests should, if at all possible, run unmodified on all operating systems
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/alecthomas/assert/v2"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

func TestNewAbsPathFromExtPath(t *testing.T) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"filippo.io/age/armor"
"go.uber.org/multierr"

"github.com/twpayne/chezmoi/v2/pkg/chezmoilog"
"github.com/twpayne/chezmoi/v2/internal/chezmoilog"
)

// An AgeEncryption uses age for encryption and decryption. See
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"filippo.io/age"
"github.com/alecthomas/assert/v2"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

func TestAgeEncryption(t *testing.T) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/alecthomas/assert/v2"

"github.com/twpayne/chezmoi/v2/pkg/archivetest"
"github.com/twpayne/chezmoi/v2/internal/archivetest"
)

func TestWalkArchive(t *testing.T) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/alecthomas/assert/v2"

"github.com/twpayne/chezmoi/v2/pkg/archivetest"
"github.com/twpayne/chezmoi/v2/internal/archivetest"
)

func TestArchiveReaderSystemTar(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-vfs/v4/vfst"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

var _ PersistentState = &BoltPersistentState{}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/rs/zerolog/pkgerrors"
"github.com/twpayne/go-vfs/v4"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

func init() {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/alecthomas/assert/v2"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

func TestUmask(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pkg/chezmoi/data_test.go → internal/chezmoi/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-vfs/v4/vfst"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

func TestKernel(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package chezmoi
import (
"github.com/rs/zerolog"

"github.com/twpayne/chezmoi/v2/pkg/chezmoilog"
"github.com/twpayne/chezmoi/v2/internal/chezmoilog"
)

// A DebugEncryption logs all calls to an Encryption.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/rs/zerolog"
vfs "github.com/twpayne/go-vfs/v4"

"github.com/twpayne/chezmoi/v2/pkg/chezmoilog"
"github.com/twpayne/chezmoi/v2/internal/chezmoilog"
)

// A DebugSystem logs all calls to a System.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/coreos/go-semver/semver"
vfs "github.com/twpayne/go-vfs/v4"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

var _ System = &DumpSystem{}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/rs/zerolog"

"github.com/twpayne/chezmoi/v2/pkg/chezmoilog"
"github.com/twpayne/chezmoi/v2/internal/chezmoilog"
)

// An EntryStateType is an entry state type.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
vfs "github.com/twpayne/go-vfs/v4"
"go.uber.org/multierr"

"github.com/twpayne/chezmoi/v2/pkg/chezmoilog"
"github.com/twpayne/chezmoi/v2/internal/chezmoilog"
)

// An ExternalDiffSystem is a DiffSystem that uses an external diff tool.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"go.uber.org/multierr"

"github.com/twpayne/chezmoi/v2/pkg/chezmoilog"
"github.com/twpayne/chezmoi/v2/internal/chezmoilog"
)

// A GPGEncryption uses gpg for encryption and decryption. See https://gnupg.org/.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/alecthomas/assert/v2"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

func TestGPGEncryption(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/alecthomas/assert/v2"
vfs "github.com/twpayne/go-vfs/v4"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

func TestPatternSet(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
vfs "github.com/twpayne/go-vfs/v4"
"go.uber.org/multierr"

"github.com/twpayne/chezmoi/v2/pkg/chezmoilog"
"github.com/twpayne/chezmoi/v2/internal/chezmoilog"
)

// A RealSystemOption sets an option on a RealSystem.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/alecthomas/assert/v2"
vfs "github.com/twpayne/go-vfs/v4"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

var _ System = &RealSystem{}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"

"github.com/twpayne/chezmoi/v2/pkg/chezmoilog"
"github.com/twpayne/chezmoi/v2/internal/chezmoilog"
)

// An ExternalType is a type of external source.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
vfs "github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-vfs/v4/vfst"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

func TestSourceStateAdd(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/rs/zerolog"

"github.com/twpayne/chezmoi/v2/pkg/chezmoilog"
"github.com/twpayne/chezmoi/v2/internal/chezmoilog"
)

// A SourceAttr contains attributes of the source.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-vfs/v4/vfst"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

func TestConcurrentWalkSourceDir(t *testing.T) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
vfs "github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-vfs/v4/vfst"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

func TestTargetStateEntryApply(t *testing.T) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/coreos/go-semver/semver"
vfs "github.com/twpayne/go-vfs/v4"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

var _ System = &TarWriterSystem{}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/alecthomas/assert/v2"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

func TestTemplateParseAndExecute(t *testing.T) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/klauspost/compress/zip"
vfs "github.com/twpayne/go-vfs/v4"

"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)

var _ System = &ZIPWriterSystem{}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"

"github.com/twpayne/chezmoi/v2/pkg/chezmoi"
"github.com/twpayne/chezmoi/v2/internal/chezmoi"
)

type BoolInputModel struct {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"

"github.com/twpayne/chezmoi/v2/pkg/chezmoi"
"github.com/twpayne/chezmoi/v2/internal/chezmoi"
)

type ChoiceInputModel struct {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-vfs/v4/vfst"

"github.com/twpayne/chezmoi/v2/pkg/chezmoilog"
"github.com/twpayne/chezmoi/v2/internal/chezmoilog"
)

var ageRecipientRx = regexp.MustCompile(`(?m)^Public key: ([0-9a-z]+)\s*$`)
Expand Down
File renamed without changes.
Loading

0 comments on commit ad2ab65

Please sign in to comment.