diff --git a/README.md b/README.md index a20759b..467dbd6 100644 --- a/README.md +++ b/README.md @@ -427,6 +427,7 @@ ggman comes with the following builtin aliases: ### 1.21.0 (Upcoming) - Various internal performance tweaks +- make spellchecker happy - Update to `go 1.22` - Update to goprogram `0.5.0` - Update dependencies diff --git a/cmd/canon.go b/cmd/canon.go index 87646d9..eac9c2b 100644 --- a/cmd/canon.go +++ b/cmd/canon.go @@ -1,10 +1,13 @@ package cmd +//spellchecker:words github ggman import ( "github.com/tkw1536/ggman" "github.com/tkw1536/ggman/env" ) +//spellchecker:words CANSPEC CANFILE + // Canon is the 'ggman canon' command. // // The 'ggman canon' command prints to standard output the canonical version of the URL passed as the first argument. diff --git a/cmd/canon_test.go b/cmd/canon_test.go index bbbfea8..d2c24db 100644 --- a/cmd/canon_test.go +++ b/cmd/canon_test.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words testing github ggman internal mockenv import ( "testing" @@ -11,7 +12,7 @@ func TestCommandCanon(t *testing.T) { tests := []struct { name string - workdir string + workDir string args []string wantCode uint8 @@ -101,7 +102,7 @@ func TestCommandCanon(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - code, stdout, stderr := mock.Run(Canon, tt.workdir, "", tt.args...) + code, stdout, stderr := mock.Run(Canon, tt.workDir, "", tt.args...) if code != tt.wantCode { t.Errorf("Code = %d, wantCode = %d", code, tt.wantCode) } diff --git a/cmd/clone.go b/cmd/clone.go index ee9fe34..936ea2a 100644 --- a/cmd/clone.go +++ b/cmd/clone.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words errors github ggman goprogram exit parser import ( "errors" "fmt" diff --git a/cmd/clone_test.go b/cmd/clone_test.go index d49da66..3a50e04 100644 --- a/cmd/clone_test.go +++ b/cmd/clone_test.go @@ -1,11 +1,14 @@ package cmd +//spellchecker:words testing github ggman internal mockenv import ( "testing" "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words GGROOT + func TestCommandClone(t *testing.T) { mock := mockenv.NewMockEnv(t) @@ -14,7 +17,7 @@ func TestCommandClone(t *testing.T) { tests := []struct { name string - workdir string + workDir string args []string wantCode uint8 @@ -111,7 +114,7 @@ func TestCommandClone(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - code, stdout, stderr := mock.Run(Clone, tt.workdir, "", tt.args...) + code, stdout, stderr := mock.Run(Clone, tt.workDir, "", tt.args...) if code != tt.wantCode { t.Errorf("Code = %d, wantCode = %d", code, tt.wantCode) } diff --git a/cmd/comps.go b/cmd/comps.go index 63e6d93..82c33d1 100644 --- a/cmd/comps.go +++ b/cmd/comps.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words github ggman import ( "github.com/tkw1536/ggman" "github.com/tkw1536/ggman/env" diff --git a/cmd/comps_test.go b/cmd/comps_test.go index 67f4b31..70e0e34 100644 --- a/cmd/comps_test.go +++ b/cmd/comps_test.go @@ -1,11 +1,14 @@ package cmd +//spellchecker:words testing github ggman internal mockenv import ( "testing" "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words workdir + func TestCommandComps(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/cmd/env.go b/cmd/env.go index 4c9c8c8..968b4eb 100644 --- a/cmd/env.go +++ b/cmd/env.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words github alessio shellescape ggman goprogram exit pkglib collection import ( "github.com/alessio/shellescape" "github.com/tkw1536/ggman" diff --git a/cmd/env_test.go b/cmd/env_test.go index 0a12e98..305b453 100644 --- a/cmd/env_test.go +++ b/cmd/env_test.go @@ -1,11 +1,14 @@ package cmd +//spellchecker:words testing github ggman internal mockenv import ( "testing" "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words workdir GGROOT + func TestCommandEnv(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/cmd/exec.go b/cmd/exec.go index 420bf41..111a87a 100644 --- a/cmd/exec.go +++ b/cmd/exec.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words exec github alessio shellescape ggman goprogram exit parser pkglib sema status stream import ( "os/exec" @@ -13,6 +14,8 @@ import ( "github.com/tkw1536/pkglib/stream" ) +//spellchecker:words positionals compat + // Exec is the 'ggman exec' command. // // Exec executes an external command for every repository known to ggman. @@ -75,14 +78,14 @@ func (exe) Description() ggman.Description { } } -var ErrExecParalllelNegative = exit.Error{ +var ErrExecParallelNegative = exit.Error{ ExitCode: exit.ExitCommandArguments, Message: "argument for `--parallel` must be non-negative", } func (e exe) AfterParse() error { if e.Parallel < 0 { - return ErrExecParalllelNegative + return ErrExecParallelNegative } return nil } diff --git a/cmd/exec_test.go b/cmd/exec_test.go index 4e80ee8..d80da53 100644 --- a/cmd/exec_test.go +++ b/cmd/exec_test.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words exec runtime testing github ggman internal mockenv import ( "os/exec" "runtime" @@ -8,6 +9,8 @@ import ( "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words workdir GGROOT + func setupExecTest(t *testing.T) (mock *mockenv.MockEnv) { mock = mockenv.NewMockEnv(t) diff --git a/cmd/fetch.go b/cmd/fetch.go index 1d0c8d4..94aa0cb 100644 --- a/cmd/fetch.go +++ b/cmd/fetch.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words github ggman goprogram exit import ( "github.com/tkw1536/ggman" "github.com/tkw1536/ggman/env" diff --git a/cmd/fetch_test.go b/cmd/fetch_test.go index 68bc332..8be44c4 100644 --- a/cmd/fetch_test.go +++ b/cmd/fetch_test.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words testing github ggman internal mockenv testutil import ( "fmt" "testing" @@ -8,6 +9,8 @@ import ( "github.com/tkw1536/ggman/internal/testutil" ) +//spellchecker:words workdir + func TestCommandFetch(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/cmd/find_branch.go b/cmd/find_branch.go index dda603b..ff4b4e1 100644 --- a/cmd/find_branch.go +++ b/cmd/find_branch.go @@ -1,11 +1,14 @@ package cmd +//spellchecker:words github ggman goprogram exit import ( "github.com/tkw1536/ggman" "github.com/tkw1536/ggman/env" "github.com/tkw1536/goprogram/exit" ) +//spellchecker:words positionals + // FindBranch is the 'ggman find-branch' command. // // The 'find-branch' command lists all repositories that contain a branch with the provided name. diff --git a/cmd/find_branch_test.go b/cmd/find_branch_test.go index b6f77df..6b7906f 100644 --- a/cmd/find_branch_test.go +++ b/cmd/find_branch_test.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words testing github config ggman internal mockenv import ( "testing" @@ -8,6 +9,8 @@ import ( "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words GGROOT workdir + func TestCommandFindBranch(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/cmd/fix.go b/cmd/fix.go index d8f3ab5..a255e1c 100644 --- a/cmd/fix.go +++ b/cmd/fix.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words sync github ggman goprogram exit import ( "sync" @@ -8,6 +9,8 @@ import ( "github.com/tkw1536/goprogram/exit" ) +//spellchecker:words canonicalizes canonicalization + // Fix is the 'ggman fix' command. // // The 'ggman fix' command canonicalizes the urls of all remotes of a repository. diff --git a/cmd/fix_test.go b/cmd/fix_test.go index 638928e..75932e6 100644 --- a/cmd/fix_test.go +++ b/cmd/fix_test.go @@ -1,11 +1,14 @@ package cmd +//spellchecker:words testing github ggman internal mockenv import ( "testing" "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words GGROOT workdir + func TestCommandFix(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/cmd/ggman/ggman.go b/cmd/ggman/ggman.go index 0f7310a..25faa8a 100644 --- a/cmd/ggman/ggman.go +++ b/cmd/ggman/ggman.go @@ -98,8 +98,11 @@ // When a subcommand succeeds, ggman exits with code 0. // When something goes wrong, it instead exits with a non-zero exit code. // Exit codes are defined by the ExitCode type in the github.com/tkw1536/ggman package. +// +//spellchecker:words main package main +//spellchecker:words runtime debug github ggman goprogram exit pkglib stream import ( "fmt" "os" @@ -113,6 +116,8 @@ import ( "github.com/tkw1536/pkglib/stream" ) +//spellchecker:words unsynced GGROOT GGNORM CANFILE shellrc workdir + // the main ggman program that will contain everything var ggmanExe = ggman.NewProgram() diff --git a/cmd/ggman/ggman_test.go b/cmd/ggman/ggman_test.go index 39d989b..5f9c93c 100644 --- a/cmd/ggman/ggman_test.go +++ b/cmd/ggman/ggman_test.go @@ -1,5 +1,7 @@ +//spellchecker:words main package main +//spellchecker:words testing github ggman internal mockenv pkglib docfmt import ( "testing" @@ -7,10 +9,12 @@ import ( "github.com/tkw1536/pkglib/docfmt" ) +//spellchecker:words doccheck + // This test runs every command once with the --help flag // // This tests that the Description() functions do not fail. -// This also checks that all the docstrings are valid if the doccheck flag is specified. +// This also checks that all the doc strings are valid if the doccheck flag is specified. func Test_main_docs(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/cmd/here.go b/cmd/here.go index dbd1a6d..b64971d 100644 --- a/cmd/here.go +++ b/cmd/here.go @@ -1,10 +1,13 @@ package cmd +//spellchecker:words github ggman import ( "github.com/tkw1536/ggman" "github.com/tkw1536/ggman/env" ) +//spellchecker:words worktree + // Here is the 'ggman here' command. // // 'ggman here' prints the path to the root of the repository in the current working directory to standard output. diff --git a/cmd/here_test.go b/cmd/here_test.go index 94a4d1a..1760937 100644 --- a/cmd/here_test.go +++ b/cmd/here_test.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words path filepath testing github ggman internal mockenv import ( "os" "path/filepath" @@ -8,6 +9,8 @@ import ( "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words workdir GGROOT + func TestCommandHere(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/cmd/license.go b/cmd/license.go index 1e3b85f..5f0f7e5 100644 --- a/cmd/license.go +++ b/cmd/license.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words github ggman constants legal import ( "github.com/tkw1536/ggman" "github.com/tkw1536/ggman/constants/legal" diff --git a/cmd/license_test.go b/cmd/license_test.go index 7e49053..7d2074e 100644 --- a/cmd/license_test.go +++ b/cmd/license_test.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words testing github ggman constants legal internal mockenv import ( "fmt" "testing" @@ -9,6 +10,8 @@ import ( "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words workdir + func TestCommandLicense(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/cmd/link.go b/cmd/link.go index 7389260..12cecf0 100644 --- a/cmd/link.go +++ b/cmd/link.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words path filepath github ggman goprogram exit pkglib import ( "os" "path/filepath" @@ -10,6 +11,8 @@ import ( "github.com/tkw1536/pkglib/fsx" ) +//spellchecker:words positionals + // Link is the 'ggman link' command. // // The 'ggman link' symlinks the repository in the path passed as the first argument where it would have been cloned to inside 'ggman root'. diff --git a/cmd/link_test.go b/cmd/link_test.go index 39b2d43..f79cf3e 100644 --- a/cmd/link_test.go +++ b/cmd/link_test.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words testing github ggman internal mockenv import ( "fmt" "testing" @@ -7,6 +8,8 @@ import ( "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words workdir GGROOT + func TestCommandLink(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/cmd/ls.go b/cmd/ls.go index d3b44cb..2073801 100644 --- a/cmd/ls.go +++ b/cmd/ls.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words github ggman goprogram exit import ( "github.com/tkw1536/ggman" "github.com/tkw1536/ggman/env" diff --git a/cmd/ls_test.go b/cmd/ls_test.go index 63f7457..635764a 100644 --- a/cmd/ls_test.go +++ b/cmd/ls_test.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words path filepath testing github ggman internal mockenv import ( "os" "path/filepath" @@ -8,6 +9,8 @@ import ( "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words workdir GGROOT wrld + var testInputFile = ` ; this and the following lines are ignored # gitlab.com/hello/world diff --git a/cmd/lsr.go b/cmd/lsr.go index 61024e3..d4f01cb 100644 --- a/cmd/lsr.go +++ b/cmd/lsr.go @@ -1,11 +1,14 @@ package cmd +//spellchecker:words github ggman goprogram exit import ( "github.com/tkw1536/ggman" "github.com/tkw1536/ggman/env" "github.com/tkw1536/goprogram/exit" ) +//spellchecker:words canonicalized CANFILE + // Lsr is the 'ggman lsr' command. // // When called, the ggman ls command prints a list of remotes of all locally cloned repositories to standard output. diff --git a/cmd/lsr_test.go b/cmd/lsr_test.go index 45e04aa..4b83dd3 100644 --- a/cmd/lsr_test.go +++ b/cmd/lsr_test.go @@ -1,11 +1,14 @@ package cmd +//spellchecker:words testing github ggman internal mockenv import ( "testing" "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words workdir + func TestCommandLsr(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/cmd/pull.go b/cmd/pull.go index c2e4cb0..9857d59 100644 --- a/cmd/pull.go +++ b/cmd/pull.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words github ggman goprogram exit import ( "github.com/tkw1536/ggman" "github.com/tkw1536/ggman/env" diff --git a/cmd/pull_test.go b/cmd/pull_test.go index e97e01e..ce8c75f 100644 --- a/cmd/pull_test.go +++ b/cmd/pull_test.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words testing github ggman internal mockenv testutil import ( "fmt" "testing" @@ -8,6 +9,8 @@ import ( "github.com/tkw1536/ggman/internal/testutil" ) +//spellchecker:words workdir + func TestCommandPull(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/cmd/relocate.go b/cmd/relocate.go index 78e6c77..2cab165 100644 --- a/cmd/relocate.go +++ b/cmd/relocate.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words errors path filepath github alessio shellescape ggman goprogram exit pkglib import ( "errors" "io/fs" diff --git a/cmd/relocate_test.go b/cmd/relocate_test.go index 298762a..51a01cf 100644 --- a/cmd/relocate_test.go +++ b/cmd/relocate_test.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words path filepath testing github ggman internal mockenv import ( "os" "path/filepath" @@ -8,9 +9,11 @@ import ( "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words workdir GGROOT + func TestCommandRelocate(t *testing.T) { - symlink := func(oldname, newname string) { - err := os.Symlink(oldname, newname) + symlink := func(oldName, newName string) { + err := os.Symlink(oldName, newName) if err != nil { panic(err) } diff --git a/cmd/shellrc.go b/cmd/shellrc.go index 558c9bd..55b312d 100644 --- a/cmd/shellrc.go +++ b/cmd/shellrc.go @@ -1,11 +1,14 @@ package cmd +//spellchecker:words embed github ggman import ( _ "embed" "github.com/tkw1536/ggman" ) +//spellchecker:words shellrc + // Shellrc is the 'ggman shellrc' command. // // The 'ggman shellrc' command prints aliases to be used for shell profiles in conjunction with ggman. diff --git a/cmd/shellrc_test.go b/cmd/shellrc_test.go index e9e8d79..d95c980 100644 --- a/cmd/shellrc_test.go +++ b/cmd/shellrc_test.go @@ -1,11 +1,14 @@ package cmd +//spellchecker:words testing github ggman internal mockenv import ( "testing" "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words shellrc + func TestCommandShellRC(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/cmd/sweep.go b/cmd/sweep.go index 69117bc..4e0a6c1 100644 --- a/cmd/sweep.go +++ b/cmd/sweep.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words github ggman internal walker goprogram exit import ( "github.com/tkw1536/ggman" "github.com/tkw1536/ggman/env" @@ -7,6 +8,8 @@ import ( "github.com/tkw1536/goprogram/exit" ) +//spellchecker:words GGROOT + // Sweep is the 'ggman sweep' command. // // The sweep command can be used to identify non-git directories within the GGROOT directory which are empty, or contain only subdirectories which are empty recursively. diff --git a/cmd/sweep_test.go b/cmd/sweep_test.go index d7e0182..417a6ac 100644 --- a/cmd/sweep_test.go +++ b/cmd/sweep_test.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words path filepath testing github ggman internal mockenv import ( "os" "path/filepath" @@ -8,6 +9,8 @@ import ( "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words GGROOT workdir + func TestCommandSweep(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/cmd/web.go b/cmd/web.go index 418e86d..444cc62 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words path filepath github ggman internal goprogram exit golang maps slices browser import ( "path/filepath" @@ -13,6 +14,8 @@ import ( "github.com/pkg/browser" ) +//spellchecker:words CANSPEC godoc localgodoc reclone urlweb positionals GGROOT worktree weburl workdir + // Web is the 'ggman web' command. // // It attempts to open the url of the current repository in a browser. @@ -74,7 +77,7 @@ type urlweb struct { Positionals struct { Base string `positional-arg-name:"BASE" description:"if provided, replace the first component with the provided base url. alternatively you can use one of the predefined base URLs. use \"--list-bases\" to see a list of predefined base URLs"` } `positional-args:"true"` - List bool `short:"l" long:"list-bases" descrioption:"print a list of all predefined base URLs"` + List bool `short:"l" long:"list-bases" description:"print a list of all predefined base URLs"` ForceRepoHere bool `short:"f" long:"force-repo-here" description:"pretend there is a repository in the current path and use the path relative to the GGROOT directory as the remote url"` Branch bool `short:"b" long:"branch" description:"if provided, include the HEAD reference in the resolved URL"` @@ -302,11 +305,11 @@ func (uw urlweb) getRemoteURLFake(context ggman.Context) (root string, remote st } // determine the relative path to the root directory - relpath, err := filepath.Rel(context.Environment.Root, workdir) + relPath, err := filepath.Rel(context.Environment.Root, workdir) if err != nil { return "", "", "", errNoRelativeRepository } // turn it into a fake url by prepending a protocol - return "", "file://" + relpath, "", nil + return "", "file://" + relPath, "", nil } diff --git a/cmd/web_test.go b/cmd/web_test.go index 4c7a8a3..c20a65b 100644 --- a/cmd/web_test.go +++ b/cmd/web_test.go @@ -1,5 +1,6 @@ package cmd +//spellchecker:words path filepath testing github ggman internal mockenv import ( "os" "path/filepath" @@ -8,6 +9,8 @@ import ( "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words workdir reclone godoc + func TestCommandURL(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/cmd/where.go b/cmd/where.go index 0122e2d..e90498a 100644 --- a/cmd/where.go +++ b/cmd/where.go @@ -1,10 +1,13 @@ package cmd +//spellchecker:words github ggman import ( "github.com/tkw1536/ggman" "github.com/tkw1536/ggman/env" ) +//spellchecker:words positionals + // Where is the 'ggman where' command. // // When invoked, the ggman where command prints to standard output the location where the remote repository described by the first argument would be cloned to. diff --git a/cmd/where_test.go b/cmd/where_test.go index 690e9da..4026eec 100644 --- a/cmd/where_test.go +++ b/cmd/where_test.go @@ -1,11 +1,14 @@ package cmd +//spellchecker:words testing github ggman internal mockenv import ( "testing" "github.com/tkw1536/ggman/internal/mockenv" ) +//spellchecker:words ggman GGROOT workdir + func TestCommandWhere(t *testing.T) { mock := mockenv.NewMockEnv(t) diff --git a/constants/docs.go b/constants/docs.go index 944ce7e..fd75089 100644 --- a/constants/docs.go +++ b/constants/docs.go @@ -1,2 +1,4 @@ // Package constants contains constants that are set once at build time. +// +//spellchecker:words constants package constants diff --git a/constants/legal/docs.go b/constants/legal/docs.go index cc6c2c5..9ce5f3e 100644 --- a/constants/legal/docs.go +++ b/constants/legal/docs.go @@ -1,4 +1,8 @@ // Package legal contains notices about software included inside the ggman program. +// +//spellchecker:words legal package legal //go:generate gogenlicense -m -o notices.go + +//spellchecker:words gogenlicense ggman diff --git a/constants/legal/notices_test.go b/constants/legal/notices_test.go index 2629cdf..dd8ebb4 100644 --- a/constants/legal/notices_test.go +++ b/constants/legal/notices_test.go @@ -1,10 +1,14 @@ +//spellchecker:words legal package legal +//spellchecker:words strings testing import ( "strings" "testing" ) +//spellchecker:words ggman + func TestLicenses(t *testing.T) { if Notices == "" { t.Errorf("Notices is empty") diff --git a/constants/version.go b/constants/version.go index 2131f2e..3110f72 100644 --- a/constants/version.go +++ b/constants/version.go @@ -1,10 +1,14 @@ +//spellchecker:words constants package constants +//spellchecker:words strconv time import ( "strconv" "time" ) +//spellchecker:words ggman + // DefaultBuildVersion is the build version used when no information is available. const DefaultBuildVersion = "v0.0.0-unknown" diff --git a/constants/version_test.go b/constants/version_test.go index f574db6..336a38c 100644 --- a/constants/version_test.go +++ b/constants/version_test.go @@ -1,5 +1,7 @@ +//spellchecker:words constants package constants +//spellchecker:words reflect testing time import ( "reflect" "testing" diff --git a/docs.go b/docs.go index 1097792..3fb909c 100644 --- a/docs.go +++ b/docs.go @@ -1,5 +1,7 @@ +//spellchecker:words ggman package ggman +//spellchecker:words embed import _ "embed" // to include the license // License contains the terms the ggman program is licensed under. diff --git a/env/canfile.go b/env/canfile.go index e9aef01..8b89944 100644 --- a/env/canfile.go +++ b/env/canfile.go @@ -1,5 +1,6 @@ package env +//spellchecker:words bufio strings github errors import ( "bufio" "io" @@ -8,6 +9,8 @@ import ( "github.com/pkg/errors" ) +//spellchecker:words canfile + // CanLine represents a line within in the canonical configuration file type CanLine struct { Pattern string diff --git a/env/canfile_test.go b/env/canfile_test.go index dfa21b8..6df8e6d 100644 --- a/env/canfile_test.go +++ b/env/canfile_test.go @@ -1,5 +1,6 @@ package env +//spellchecker:words reflect testing import ( "reflect" "testing" diff --git a/env/docs.go b/env/docs.go index c5d9987..057a772 100644 --- a/env/docs.go +++ b/env/docs.go @@ -1,2 +1,4 @@ // Package env implements an Environment for ggman to run commands in. package env + +//spellchecker:words ggman diff --git a/env/env.go b/env/env.go index bf7b0ce..e5f85d6 100644 --- a/env/env.go +++ b/env/env.go @@ -1,5 +1,6 @@ package env +//spellchecker:words path filepath strings github errors ggman internal walker goprogram exit pkglib import ( "io/fs" "os" @@ -14,6 +15,8 @@ import ( "github.com/tkw1536/pkglib/fsx" ) +//spellchecker:words worktree canonicalized canonicalize CANFILE workdir GGNORM GGROOT Wrapf + // Env represents an environment to be used by ggman. // // The environment defines which git repositories are managed by ggman and where these are stored. @@ -304,7 +307,7 @@ func (env Env) At(p string) (repo, worktree string, err error) { // When false, returns the empty string and no error. // When something goes wrong, returns an error. func (env Env) AtRoot(p string) (repo string, err error) { - // This function could check if At(p) returns workdir = "." + // This function could check if At(p) returns worktree = "." // but that would create additional disk I/O! path, err := env.Abs(p) diff --git a/env/env_test.go b/env/env_test.go index 576ad1d..1e8c623 100644 --- a/env/env_test.go +++ b/env/env_test.go @@ -1,5 +1,6 @@ package env +//spellchecker:words path filepath reflect testing github ggman internal testutil pkglib testlib import ( "os" "path/filepath" @@ -12,22 +13,24 @@ import ( "github.com/tkw1536/pkglib/testlib" ) +//spellchecker:words GGNORM GGROOT CANFILE worktree + func TestEnv_LoadDefaultRoot(t *testing.T) { - // nopdir does not have a 'Projects' subdirectory - nopdir := testlib.TempDirAbs(t) - pnopdir := filepath.Join(nopdir, "Projects") + // noProjectsDir does not have a 'Projects' subdirectory + noProjectsDir := testlib.TempDirAbs(t) + missingProjectsDir := filepath.Join(noProjectsDir, "Projects") - // pdir has a 'Projects' subdirectory - pdir := testlib.TempDirAbs(t) - ppdir := filepath.Join(pdir, "Projects") + // withProjectsDir has a 'Projects' subdirectory + withProjectsDir := testlib.TempDirAbs(t) + existingProjectsDir := filepath.Join(withProjectsDir, "Projects") - if err := os.Mkdir(ppdir, os.ModePerm); err != nil { + if err := os.Mkdir(existingProjectsDir, os.ModePerm); err != nil { panic(err) } - // nodir doesn't exist - nodir := filepath.Join(testlib.TempDirAbs(t), "noexist") + // noExistsDir doesn't exist + noExistsDir := filepath.Join(testlib.TempDirAbs(t), "noExist") tests := []struct { name string @@ -35,13 +38,13 @@ func TestEnv_LoadDefaultRoot(t *testing.T) { wantRoot string wantErr bool }{ - {"GGROOT exists", Variables{GGROOT: nopdir}, nopdir, false}, - {"GGROOT not exists", Variables{GGROOT: nodir}, nodir, false}, + {"GGROOT exists", Variables{GGROOT: noProjectsDir}, noProjectsDir, false}, + {"GGROOT not exists", Variables{GGROOT: noExistsDir}, noExistsDir, false}, {"GGROOT unset, HOME unset", Variables{}, "", true}, - {"GGROOT unset, HOME/Projects exists", Variables{HOME: nopdir}, pnopdir, false}, - {"GGROOT unset, HOME/Projects not exists", Variables{HOME: pdir}, ppdir, false}, + {"GGROOT unset, HOME/Projects exists", Variables{HOME: noProjectsDir}, missingProjectsDir, false}, + {"GGROOT unset, HOME/Projects not exists", Variables{HOME: withProjectsDir}, existingProjectsDir, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -59,22 +62,22 @@ func TestEnv_LoadDefaultRoot(t *testing.T) { } func TestEnv_LoadDefaultCANFILE(t *testing.T) { - // dfltCanFile is the default CanFile - var dfltCanFile CanFile - dfltCanFile.ReadDefault() + // defaultCanFile is the default CanFile + var defaultCanFile CanFile + defaultCanFile.ReadDefault() // sampleCanFile is the sample CanFile] const canLineContent = "sample@^:$.git" var sampleCanFile CanFile = []CanLine{{"", canLineContent}} - // edir is an empty directory without a canFile - edir := testlib.TempDirAbs(t) - noggmanfile := filepath.Join(edir, ".ggman") + // emptyDir is an empty directory without a canFile + emptyDir := testlib.TempDirAbs(t) + noGGMANFile := filepath.Join(emptyDir, ".ggman") - // ddir is a directory with a '.ggman' file - ddir := testlib.TempDirAbs(t) - ggmanfile := filepath.Join(ddir, ".ggman") - os.WriteFile(ggmanfile, []byte(canLineContent), os.ModePerm) + // dDir is a directory with a '.ggman' file + dDir := testlib.TempDirAbs(t) + GGMANFile := filepath.Join(dDir, ".ggman") + os.WriteFile(GGMANFile, []byte(canLineContent), os.ModePerm) tests := []struct { name string @@ -82,13 +85,13 @@ func TestEnv_LoadDefaultCANFILE(t *testing.T) { wantErr bool wantCanfile CanFile }{ - {"loading from existing path", Variables{CANFILE: ggmanfile}, false, sampleCanFile}, + {"loading from existing path", Variables{CANFILE: GGMANFile}, false, sampleCanFile}, - {"loading from home", Variables{HOME: ddir}, false, sampleCanFile}, - {"loading from home because of failure", Variables{CANFILE: noggmanfile, HOME: ddir}, false, sampleCanFile}, + {"loading from home", Variables{HOME: dDir}, false, sampleCanFile}, + {"loading from home because of failure", Variables{CANFILE: noGGMANFile, HOME: dDir}, false, sampleCanFile}, - {"loading non-existing path", Variables{CANFILE: noggmanfile}, false, dfltCanFile}, - {"loading non-existing home", Variables{HOME: edir}, false, dfltCanFile}, + {"loading non-existing path", Variables{CANFILE: noGGMANFile}, false, defaultCanFile}, + {"loading non-existing home", Variables{HOME: emptyDir}, false, defaultCanFile}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -269,7 +272,7 @@ func TestEnv_ScanRepos(t *testing.T) { root := testlib.TempDirAbs(t) // make a dir with parents and turn it into git - mkgit := func(s string) { + makeGit := func(s string) { pth := filepath.Join(root, s) err := os.MkdirAll(pth, os.ModePerm) if err != nil { @@ -280,15 +283,15 @@ func TestEnv_ScanRepos(t *testing.T) { } } - mkgit(filepath.Join("a", "aa", "aaa")) - mkgit(filepath.Join("a", "aa", "aab")) - mkgit(filepath.Join("a", "aa", "aac")) - mkgit(filepath.Join("a", "ab", "aba")) - mkgit(filepath.Join("a", "ab", "abb")) - mkgit(filepath.Join("a", "ab", "abc")) - mkgit(filepath.Join("a", "ac", "aca")) - mkgit(filepath.Join("a", "ac", "acb")) - mkgit(filepath.Join("a", "ac", "acc")) + makeGit(filepath.Join("a", "aa", "aaa")) + makeGit(filepath.Join("a", "aa", "aab")) + makeGit(filepath.Join("a", "aa", "aac")) + makeGit(filepath.Join("a", "ab", "aba")) + makeGit(filepath.Join("a", "ab", "abb")) + makeGit(filepath.Join("a", "ab", "abc")) + makeGit(filepath.Join("a", "ac", "aca")) + makeGit(filepath.Join("a", "ac", "acb")) + makeGit(filepath.Join("a", "ac", "acc")) // utility to remove root from all the paths trimPath := func(path string) string { @@ -366,7 +369,7 @@ func TestEnv_ScanRepos_fuzzy(t *testing.T) { root := testlib.TempDirAbs(t) // make a dir with parents and turn it into git - mkgit := func(s string) { + makeGit := func(s string) { pth := filepath.Join(root, s) err := os.MkdirAll(pth, os.ModePerm) if err != nil { @@ -377,8 +380,8 @@ func TestEnv_ScanRepos_fuzzy(t *testing.T) { } } - mkgit(filepath.Join("abc")) // matches the filter 'bc' with a score of 0.66, but lexicographically first - mkgit(filepath.Join("bc")) // matches the filter 'bc' with a score of 1, but lexicographically last + makeGit(filepath.Join("abc")) // matches the filter 'bc' with a score of 0.66, but lexicographically first + makeGit(filepath.Join("bc")) // matches the filter 'bc' with a score of 1, but lexicographically last // utility to remove root from all the paths trimPath := func(path string) string { @@ -444,7 +447,7 @@ func TestEnv_Normalization(t *testing.T) { {"smart", path.FoldPreferExactNorm}, {"exact", path.NoNorm}, {"", path.FoldPreferExactNorm}, - {"this-norm-doesnt-exist", path.FoldPreferExactNorm}, + {"this-norm-doesn't-exist", path.FoldPreferExactNorm}, } for _, tt := range tests { t.Run(tt.GGNORM, func(t *testing.T) { diff --git a/env/filter.go b/env/filter.go index e6ae93e..f038e72 100644 --- a/env/filter.go +++ b/env/filter.go @@ -1,5 +1,6 @@ package env +//spellchecker:words path filepath strings github ggman internal pattern pkglib collection import ( "os" "path/filepath" @@ -10,6 +11,8 @@ import ( "github.com/tkw1536/pkglib/collection" ) +//spellchecker:words worktree + // Filter is a predicate that scores repositories inside an environment. // // A filter is applied by recursively scanning the root folder for git repositories. @@ -231,7 +234,7 @@ func NewWorktreeFilter(Filter Filter, Dirty, Clean bool) Filter { } } -// NewStatusFilter returns new Filter that filters by repositories being synced or unsynced with the remote. +// NewStatusFilter returns new Filter that filters by repositories being synced or un-synced with the remote. func NewStatusFilter(Filter Filter, Synced, UnSynced bool) Filter { return predicateFilter{ Filter: Filter, @@ -246,7 +249,7 @@ func NewStatusFilter(Filter Filter, Synced, UnSynced bool) Filter { } // NewTarnishFilter returns new Filter that filters by if they have been tarnished or not. -// A repository is tarnished if it has a dirty working directory, or is unsynced with the remote. +// A repository is tarnished if it has a dirty working directory, or is un-synced with the remote. func NewTarnishFilter(Filter Filter, Tarnished, Pristine bool) Filter { return predicateFilter{ Filter: Filter, diff --git a/env/filter_test.go b/env/filter_test.go index 12861a8..ca65056 100644 --- a/env/filter_test.go +++ b/env/filter_test.go @@ -1,5 +1,6 @@ package env +//spellchecker:words path filepath reflect testing github ggman internal pattern testutil pkglib testlib import ( "path/filepath" "reflect" @@ -11,6 +12,8 @@ import ( "github.com/tkw1536/pkglib/testlib" ) +//spellchecker:words matcha matchb matchc otherabc + func setupFilterTest(t *testing.T) (root, exampleClonePath, otherClonePath string) { root = testlib.TempDirAbs(t) @@ -438,7 +441,7 @@ func TestDisjunctionFilter_Score(t *testing.T) { }, { - "two pathfilters match first path", + "two PathFilters match first path", fields{ Clauses: []Filter{ PathFilter{[]string{testutil.ToOSPath("/root/matcha")}}, @@ -453,7 +456,7 @@ func TestDisjunctionFilter_Score(t *testing.T) { }, { - "two pathfilters match second path", + "two PathFilters match second path", fields{ Clauses: []Filter{ PathFilter{[]string{testutil.ToOSPath("/root/matcha")}}, @@ -468,7 +471,7 @@ func TestDisjunctionFilter_Score(t *testing.T) { }, { - "two pathfilters do not match third path", + "two PathFilters do not match third path", fields{ Clauses: []Filter{ PathFilter{[]string{testutil.ToOSPath("/root/matcha")}}, diff --git a/env/flags.go b/env/flags.go index eb18529..8ad9fcd 100644 --- a/env/flags.go +++ b/env/flags.go @@ -1,5 +1,6 @@ package env +//spellchecker:words bufio strings github errors goprogram exit pkglib import ( "bufio" "os" @@ -10,6 +11,8 @@ import ( "github.com/tkw1536/pkglib/fsx" ) +//spellchecker:words ggman unsynced uncommited worktree wrapf + // Flags represents a set of filter flags used for the ggman goprogram. type Flags struct { For []string `short:"f" long:"for" value-name:"FILTER" description:"filter list of repositories by FILTER. FILTER can be a relative or absolute path, or a glob pattern which will be matched against the normalized repository url"` diff --git a/env/requirement.go b/env/requirement.go index f0f1738..a9fbdb2 100644 --- a/env/requirement.go +++ b/env/requirement.go @@ -1,5 +1,6 @@ package env +//spellchecker:words github goprogram meta import ( "github.com/tkw1536/goprogram" "github.com/tkw1536/goprogram/meta" diff --git a/env/url.go b/env/url.go index 70aa3f1..5c98480 100644 --- a/env/url.go +++ b/env/url.go @@ -1,5 +1,6 @@ package env +//spellchecker:words strings github ggman internal split pkglib collection text jessevdk flags import ( "strings" @@ -11,6 +12,8 @@ import ( "github.com/jessevdk/go-flags" ) +//spellchecker:words mydomain + // URL represents a URL to a single git repository. // // A URL consists of different parts, and is typically created by using ParseURL. @@ -152,12 +155,12 @@ func (url URL) Components() []string { // ^ -- replaced by the first un-used component of the URI // % -- replaced by the second un-used component of the URI (commonly username) // $ -- replaced by all remaining components in the URI joined with a '/'. Also stops all processing afterwards. -// If $ does not exist in the cspec, it is assumed to be at the end of the cspec. -func (url URL) Canonical(cspec string) (canonical string) { +// If $ does not exist in the cSpec, it is assumed to be at the end of the cSpec. +func (url URL) Canonical(cSpec string) (canonical string) { var builder strings.Builder components := url.Components() // get the components of the URI - prefix, suffix := split.AfterRune(cspec, '$') // split into modable and static part + prefix, suffix := split.AfterRune(cSpec, '$') // split into mod-able and static part for i, r := range prefix { // no more components left diff --git a/env/url_test.go b/env/url_test.go index d0ebaa0..a12953d 100644 --- a/env/url_test.go +++ b/env/url_test.go @@ -1,5 +1,6 @@ package env +//spellchecker:words reflect testing import ( "reflect" "testing" @@ -210,28 +211,28 @@ func TestURL_Components(t *testing.T) { wantParts []string }{ // git@github.com/user/repo - {"noproto1", fields{"", "git", "", "github.com", 0, "hello/world.git"}, []string{"github.com", "hello", "world"}}, - {"noproto2", fields{"", "git", "", "github.com", 0, "hello/world"}, []string{"github.com", "hello", "world"}}, - {"noproto3", fields{"", "git", "", "github.com", 0, "hello/world/"}, []string{"github.com", "hello", "world"}}, - {"noproto4", fields{"", "git", "", "github.com", 0, "hello/world//"}, []string{"github.com", "hello", "world"}}, + {"noProto1", fields{"", "git", "", "github.com", 0, "hello/world.git"}, []string{"github.com", "hello", "world"}}, + {"noProto2", fields{"", "git", "", "github.com", 0, "hello/world"}, []string{"github.com", "hello", "world"}}, + {"noProto3", fields{"", "git", "", "github.com", 0, "hello/world/"}, []string{"github.com", "hello", "world"}}, + {"noProto4", fields{"", "git", "", "github.com", 0, "hello/world//"}, []string{"github.com", "hello", "world"}}, // ssh://git@github.com/hello/world - {"sshproto1", fields{"ssh", "git", "", "github.com", 0, "hello/world.git"}, []string{"github.com", "hello", "world"}}, - {"sshproto2", fields{"ssh", "git", "", "github.com", 0, "hello/world"}, []string{"github.com", "hello", "world"}}, - {"sshproto3", fields{"ssh", "git", "", "github.com", 0, "hello/world/"}, []string{"github.com", "hello", "world"}}, - {"sshproto4", fields{"ssh", "git", "", "github.com", 0, "hello/world//"}, []string{"github.com", "hello", "world"}}, + {"sshProto1", fields{"ssh", "git", "", "github.com", 0, "hello/world.git"}, []string{"github.com", "hello", "world"}}, + {"sshProto2", fields{"ssh", "git", "", "github.com", 0, "hello/world"}, []string{"github.com", "hello", "world"}}, + {"sshProto3", fields{"ssh", "git", "", "github.com", 0, "hello/world/"}, []string{"github.com", "hello", "world"}}, + {"sshProto4", fields{"ssh", "git", "", "github.com", 0, "hello/world//"}, []string{"github.com", "hello", "world"}}, // user@server.com - {"userserver1", fields{"", "user", "", "server.com", 0, "repository"}, []string{"server.com", "user", "repository"}}, - {"userserver2", fields{"", "user", "", "server.com", 0, "repository/"}, []string{"server.com", "user", "repository"}}, - {"userserver3", fields{"", "user", "", "server.com", 0, "repository//"}, []string{"server.com", "user", "repository"}}, - {"userserver4", fields{"", "user", "", "server.com", 0, "repository.git"}, []string{"server.com", "user", "repository"}}, + {"userServer1", fields{"", "user", "", "server.com", 0, "repository"}, []string{"server.com", "user", "repository"}}, + {"userServer2", fields{"", "user", "", "server.com", 0, "repository/"}, []string{"server.com", "user", "repository"}}, + {"userServer3", fields{"", "user", "", "server.com", 0, "repository//"}, []string{"server.com", "user", "repository"}}, + {"userServer4", fields{"", "user", "", "server.com", 0, "repository.git"}, []string{"server.com", "user", "repository"}}, // ssh://user@server.com:1234 - {"userport1", fields{"", "user", "", "server.com", 1234, "repository"}, []string{"server.com", "user", "repository"}}, - {"userport2", fields{"", "user", "", "server.com", 1234, "repository/"}, []string{"server.com", "user", "repository"}}, - {"userport3", fields{"", "user", "", "server.com", 1234, "repository//"}, []string{"server.com", "user", "repository"}}, - {"userport4", fields{"", "user", "", "server.com", 1234, "repository.git"}, []string{"server.com", "user", "repository"}}, + {"userPort1", fields{"", "user", "", "server.com", 1234, "repository"}, []string{"server.com", "user", "repository"}}, + {"userPort2", fields{"", "user", "", "server.com", 1234, "repository/"}, []string{"server.com", "user", "repository"}}, + {"userPort3", fields{"", "user", "", "server.com", 1234, "repository//"}, []string{"server.com", "user", "repository"}}, + {"userPort4", fields{"", "user", "", "server.com", 1234, "repository.git"}, []string{"server.com", "user", "repository"}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -340,7 +341,7 @@ func TestRepoURI_Canonical(t *testing.T) { Path string } type args struct { - cspec string + cSpec string } tests := []struct { name string @@ -350,7 +351,7 @@ func TestRepoURI_Canonical(t *testing.T) { }{ {"Treat one component special", fields{"", "user", "", "server.com", 1234, "repository"}, args{"git@^:$.git"}, "git@server.com:user/repository.git"}, {"Treat two components special", fields{"", "user", "", "server.com", 1234, "repository"}, args{"ssh://%@^/$.git"}, "ssh://user@server.com/repository.git"}, - {"Empty specifcation string", fields{"", "user", "", "server.com", 1234, "repository"}, args{""}, "server.com/user/repository"}, + {"Empty specification string", fields{"", "user", "", "server.com", 1234, "repository"}, args{""}, "server.com/user/repository"}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -362,7 +363,7 @@ func TestRepoURI_Canonical(t *testing.T) { Port: tt.fields.Port, Path: tt.fields.Path, } - if gotCanonical := rURI.Canonical(tt.args.cspec); gotCanonical != tt.wantCanonical { + if gotCanonical := rURI.Canonical(tt.args.cSpec); gotCanonical != tt.wantCanonical { t.Errorf("RepoURI.Canonical() = %v, want %v", gotCanonical, tt.wantCanonical) } }) diff --git a/env/uservars.go b/env/uservars.go index 213000c..b1c49e2 100644 --- a/env/uservars.go +++ b/env/uservars.go @@ -1,5 +1,6 @@ package env +//spellchecker:words strings github goprogram meta golang slices import ( "strings" @@ -7,6 +8,8 @@ import ( "golang.org/x/exp/slices" ) +//spellchecker:words GGROOT ggman workdir + // UserVariable is a variable that is exposed to the user. // See GetUserVariables() for a details. type UserVariable struct { diff --git a/env/vars.go b/env/vars.go index 94949df..229b776 100644 --- a/env/vars.go +++ b/env/vars.go @@ -1,5 +1,6 @@ package env +//spellchecker:words reflect github mitchellh homedir pkglib reflectx import ( "os" "reflect" @@ -8,6 +9,8 @@ import ( "github.com/tkw1536/pkglib/reflectx" ) +//spellchecker:words ggman GGROOT CANFILE GGNORM + // Variables represents the values of specific environment variables. // Unset variables are represented as the empty string. // diff --git a/env/vars_test.go b/env/vars_test.go index 3c2a1a6..a178145 100644 --- a/env/vars_test.go +++ b/env/vars_test.go @@ -1,5 +1,6 @@ package env +//spellchecker:words reflect testing github ggman internal testutil import ( "reflect" "testing" @@ -7,6 +8,8 @@ import ( "github.com/tkw1536/ggman/internal/testutil" ) +//spellchecker:words GGROOT CANFILE GGNORM + func TestReadVariables(t *testing.T) { defer testutil.MockVariables(map[string]string{ "PATH": "/fake/path", diff --git a/ggman.go b/ggman.go index acb7d0d..02d73e1 100644 --- a/ggman.go +++ b/ggman.go @@ -1,14 +1,17 @@ // Package ggman serves as the implementation of the ggman program. // See documentation of the ggman command as an entry point into the documentation. // -// Note that this package and it's subpackages are not intended to be consumed by other go packages. +// Note that this package and it's sub-packages are not intended to be consumed by other go packages. // The public interface of the ggman is defined only by the ggman executable. // This package is not considered part of the public interface as such and not subject to Semantic Versioning. // -// The top-level ggman package is considered to be stand-alone, and (with the exception of 'util') does not directly depend on any of its' subpackages. -// As such it can be safely used by any subpackage without cyclic imports. +// The top-level ggman package is considered to be stand-alone, and (with the exception of 'util') does not directly depend on any of its' sub-packages. +// As such it can be safely used by any sub-package without cyclic imports. +// +//spellchecker:words ggman package ggman +//spellchecker:words github ggman goprogram import ( "github.com/tkw1536/ggman/env" "github.com/tkw1536/goprogram" diff --git a/git/errors.go b/git/errors.go index 39fb75d..e82e243 100644 --- a/git/errors.go +++ b/git/errors.go @@ -1,5 +1,6 @@ package git +//spellchecker:words errors import "errors" // ErrNotARepository is an error that is returned when the clonePath parameter is not a repository diff --git a/git/git.go b/git/git.go index c483404..13f7839 100644 --- a/git/git.go +++ b/git/git.go @@ -11,6 +11,7 @@ // For this reason, implementation of the Plumbing interface are not exported. package git +//spellchecker:words path filepath sync github pkglib stream import ( "os" "path/filepath" @@ -19,6 +20,8 @@ import ( "github.com/tkw1536/pkglib/stream" ) +//spellchecker:words gitgit gogit + // Git represents a wrapper around a Plumbing instance. // It is goroutine-safe and initialization free. // @@ -43,13 +46,13 @@ type Git interface { // // remoteURI is the remote git uri to clone the repository from. // clonePath is the local path to clone the repository to. - // extraargs are arguments as would be passed to a 'git clone' command. + // extraArgs are arguments as would be passed to a 'git clone' command. // // If there is already a repository at clonePath returns ErrCloneAlreadyExists. // If the underlying 'git' process exits abnormally, returns. - // If extraargs is non-empty and extra arguments are not supported by this Wrapper, returns ErrArgumentsUnsupported. + // If extraArgs is non-empty and extra arguments are not supported by this Wrapper, returns ErrArgumentsUnsupported. // May return other error types for other errors. - Clone(stream stream.IOStream, remoteURI, clonePath string, extraargs ...string) error + Clone(stream stream.IOStream, remoteURI, clonePath string, extraArgs ...string) error // GetHeadRef gets a resolved reference to head at the repository at clonePath. // @@ -116,7 +119,7 @@ type Git interface { // // If there is no repository at clonePath returns ErrNotARepository. // May return other error types for other errors. - IsSync(clonePath string) (sycned bool, err error) + IsSync(clonePath string) (synced bool, err error) // GitPath returns the path to the git executable being used, if any. GitPath() string @@ -130,22 +133,22 @@ type Git interface { // The implementation of this function relies on the underlying Plumbing (be it a default one or a caller provided one) to conform according to the specification. // In particular, this function does not checks on the error values returned and passes them directly from the implementation to the caller func NewGitFromPlumbing(plumbing Plumbing, path string) Git { - return &dfltGitWrapper{git: plumbing, path: path} + return &defaultGitWrapper{git: plumbing, path: path} } -type dfltGitWrapper struct { +type defaultGitWrapper struct { once sync.Once git Plumbing path string // the path to lookup 'git' in, if needed. } -func (impl *dfltGitWrapper) Plumbing() Plumbing { +func (impl *defaultGitWrapper) Plumbing() Plumbing { impl.ensureInit() return impl.git } -func (impl *dfltGitWrapper) ensureInit() { +func (impl *defaultGitWrapper) ensureInit() { impl.once.Do(func() { if impl.git != nil { return @@ -165,14 +168,14 @@ func (impl *dfltGitWrapper) ensureInit() { }) } -func (impl *dfltGitWrapper) IsRepository(localPath string) bool { +func (impl *defaultGitWrapper) IsRepository(localPath string) bool { impl.ensureInit() _, isRepo := impl.git.IsRepository(localPath) return isRepo } -func (impl *dfltGitWrapper) IsRepositoryQuick(localPath string) bool { +func (impl *defaultGitWrapper) IsRepositoryQuick(localPath string) bool { impl.ensureInit() if !impl.git.IsRepositoryUnsafe(localPath) { // IsRepositoryUnsafe may not return false negatives @@ -182,7 +185,7 @@ func (impl *dfltGitWrapper) IsRepositoryQuick(localPath string) bool { return impl.IsRepository(localPath) } -func (impl *dfltGitWrapper) Clone(stream stream.IOStream, remoteURI, clonePath string, extraargs ...string) error { +func (impl *defaultGitWrapper) Clone(stream stream.IOStream, remoteURI, clonePath string, extraArgs ...string) error { impl.ensureInit() // check if the repository already exists @@ -196,10 +199,10 @@ func (impl *dfltGitWrapper) Clone(stream stream.IOStream, remoteURI, clonePath s } // run the clone code and return - return impl.git.Clone(stream, remoteURI, clonePath, extraargs...) + return impl.git.Clone(stream, remoteURI, clonePath, extraArgs...) } -func (impl *dfltGitWrapper) GetHeadRef(clonePath string) (ref string, err error) { +func (impl *defaultGitWrapper) GetHeadRef(clonePath string) (ref string, err error) { impl.ensureInit() // check that the given folder is actually a repository @@ -212,7 +215,7 @@ func (impl *dfltGitWrapper) GetHeadRef(clonePath string) (ref string, err error) return impl.git.GetHeadRef(clonePath, repoObject) } -func (impl *dfltGitWrapper) Fetch(stream stream.IOStream, clonePath string) error { +func (impl *defaultGitWrapper) Fetch(stream stream.IOStream, clonePath string) error { impl.ensureInit() // check that the given folder is actually a repository @@ -224,7 +227,7 @@ func (impl *dfltGitWrapper) Fetch(stream stream.IOStream, clonePath string) erro return impl.git.Fetch(stream, clonePath, repoObject) } -func (impl *dfltGitWrapper) Pull(stream stream.IOStream, clonePath string) error { +func (impl *defaultGitWrapper) Pull(stream stream.IOStream, clonePath string) error { impl.ensureInit() // check that the given folder is actually a repository @@ -236,7 +239,7 @@ func (impl *dfltGitWrapper) Pull(stream stream.IOStream, clonePath string) error return impl.git.Pull(stream, clonePath, repoObject) } -func (impl *dfltGitWrapper) GetRemote(clonePath string) (uri string, err error) { +func (impl *defaultGitWrapper) GetRemote(clonePath string) (uri string, err error) { impl.ensureInit() // check that the given folder is actually a repository @@ -257,7 +260,7 @@ func (impl *dfltGitWrapper) GetRemote(clonePath string) (uri string, err error) return } -func (impl *dfltGitWrapper) UpdateRemotes(clonePath string, updateFunc func(url, name string) (string, error)) (err error) { +func (impl *defaultGitWrapper) UpdateRemotes(clonePath string, updateFunc func(url, name string) (string, error)) (err error) { impl.ensureInit() // check that the given folder is actually a repository @@ -293,7 +296,7 @@ func (impl *dfltGitWrapper) UpdateRemotes(clonePath string, updateFunc func(url, return } -func (impl *dfltGitWrapper) GetBranches(clonePath string) (branches []string, err error) { +func (impl *defaultGitWrapper) GetBranches(clonePath string) (branches []string, err error) { impl.ensureInit() // check that the given folder is actually a repository @@ -305,7 +308,7 @@ func (impl *dfltGitWrapper) GetBranches(clonePath string) (branches []string, er return impl.git.GetBranches(clonePath, repoObject) } -func (impl *dfltGitWrapper) ContainsBranch(clonePath, branch string) (exists bool, err error) { +func (impl *defaultGitWrapper) ContainsBranch(clonePath, branch string) (exists bool, err error) { impl.ensureInit() // check that the given folder is actually a repository @@ -317,7 +320,7 @@ func (impl *dfltGitWrapper) ContainsBranch(clonePath, branch string) (exists boo return impl.git.ContainsBranch(clonePath, repoObject, branch) } -func (impl *dfltGitWrapper) IsDirty(clonePath string) (dirty bool, err error) { +func (impl *defaultGitWrapper) IsDirty(clonePath string) (dirty bool, err error) { impl.ensureInit() // check that the given folder is actually a repository @@ -329,7 +332,7 @@ func (impl *dfltGitWrapper) IsDirty(clonePath string) (dirty bool, err error) { return impl.git.IsDirty(clonePath, repoObject) } -func (impl *dfltGitWrapper) IsSync(clonePath string) (dirty bool, err error) { +func (impl *defaultGitWrapper) IsSync(clonePath string) (dirty bool, err error) { impl.ensureInit() // check that the given folder is actually a repository @@ -341,7 +344,7 @@ func (impl *dfltGitWrapper) IsSync(clonePath string) (dirty bool, err error) { return impl.git.IsSync(clonePath, repoObject) } -func (impl *dfltGitWrapper) GitPath() string { +func (impl *defaultGitWrapper) GitPath() string { impl.ensureInit() gitgit, isGitGit := impl.git.(*gitgit) diff --git a/git/git_test.go b/git/git_test.go index 2fafc8e..c243452 100644 --- a/git/git_test.go +++ b/git/git_test.go @@ -11,6 +11,7 @@ // For this reason, implementation of the Plumbing interface are not exported. package git +//spellchecker:words path filepath testing github pkglib testlib import ( "os" "path/filepath" @@ -19,18 +20,20 @@ import ( "github.com/tkw1536/pkglib/testlib" ) +//spellchecker:words gogit gitgit + func TestNewGitFromPlumbing(t *testing.T) { // create a temporary file dir := testlib.TempDirAbs(t) // no path => use a gogit - if _, isgogit := NewGitFromPlumbing(nil, "").Plumbing().(*gogit); !isgogit { + if _, isGogit := NewGitFromPlumbing(nil, "").Plumbing().(*gogit); !isGogit { t.Errorf("NewGitFromPlumbing: Expected *gogit") } // path but no git => use a gogit - if _, isgogit := NewGitFromPlumbing(nil, dir).Plumbing().(*gogit); !isgogit { + if _, isGogit := NewGitFromPlumbing(nil, dir).Plumbing().(*gogit); !isGogit { t.Errorf("NewGitFromPlumbing: Expected *gogit") } @@ -42,7 +45,7 @@ func TestNewGitFromPlumbing(t *testing.T) { } // path with git => gitgit - if _, isgitgit := NewGitFromPlumbing(nil, dir).Plumbing().(*gitgit); !isgitgit { + if _, isGitgit := NewGitFromPlumbing(nil, dir).Plumbing().(*gitgit); !isGitgit { t.Errorf("NewGitFromPlumbing: Expected *gitgit") } diff --git a/git/plumbing.go b/git/plumbing.go index 626e9ac..103ad68 100644 --- a/git/plumbing.go +++ b/git/plumbing.go @@ -1,5 +1,6 @@ package git +//spellchecker:words exec path filepath runtime github errors golang slices plumbing pkglib stream import ( "os" "os/exec" @@ -16,6 +17,8 @@ import ( "github.com/tkw1536/pkglib/stream" ) +//spellchecker:words worktree bref reflike gogit gitgit wrapf storer + // Plumbing is an interface that represents a working internal implementation of git. // Plumbing is intended to be goroutine-safe, i.e. everything except the Init() method can be called from multiple goroutines at once. // @@ -94,13 +97,13 @@ type Plumbing interface { // clonePath will be the path to a local folder where the repository should be cloned to. // It's parent is guaranteed to exist. // - // extraargs will be additional arguments, in the form of arguments of a 'git clone' command. + // extraArgs will be additional arguments, in the form of arguments of a 'git clone' command. // When this implementation does not support arguments, it returns ErrArgumentsUnsupported whenever arguments is a list of length > 0. // // If the clone succeeds returns, err = nil. // If the underlying clone command returns a non-zero code, returns an error of type ExitError. // If something else goes wrong, may return any other error type. - Clone(stream stream.IOStream, remoteURI, clonePath string, extraargs ...string) error + Clone(stream stream.IOStream, remoteURI, clonePath string, extraArgs ...string) error // Fetch should fetch new objects and refs from all remotes of the repository cloned at clonePath. // May attempt to read credentials from stream.Stdin. @@ -169,11 +172,11 @@ type gitgit struct { } func (gg *gitgit) Init() (err error) { - gg.gitPath, err = gg.findgit() + gg.gitPath, err = gg.findGit() return } -func (gg gitgit) findgit() (git string, err error) { +func (gg gitgit) findGit() (git string, err error) { if runtime.GOOS == "windows" { return gg.findGitByExtension([]string{"exe"}) } @@ -222,11 +225,11 @@ func (gg gitgit) findGitByExtension(exts []string) (git string, err error) { return "", exec.ErrNotFound } -func (gg gitgit) Clone(stream stream.IOStream, remoteURI, clonePath string, extraargs ...string) error { +func (gg gitgit) Clone(stream stream.IOStream, remoteURI, clonePath string, extraArgs ...string) error { - gargs := append([]string{"clone", remoteURI, clonePath}, extraargs...) + gitArgs := append([]string{"clone", remoteURI, clonePath}, extraArgs...) - cmd := exec.Command(gg.gitPath, gargs...) + cmd := exec.Command(gg.gitPath, gitArgs...) cmd.Stdin = stream.Stdin cmd.Stdout = stream.Stdout cmd.Stderr = stream.Stderr @@ -485,9 +488,9 @@ func (gogit) SetRemoteURLs(clonePath string, repoObject any, name string, urls [ return } -func (gogit) Clone(stream stream.IOStream, remoteURI, clonePath string, extraargs ...string) error { +func (gogit) Clone(stream stream.IOStream, remoteURI, clonePath string, extraArgs ...string) error { // doesn't support extra arguments - if len(extraargs) > 0 { + if len(extraArgs) > 0 { return ErrArgumentsUnsupported } diff --git a/git/plumbing_test.go b/git/plumbing_test.go index a6684cd..eefa571 100644 --- a/git/plumbing_test.go +++ b/git/plumbing_test.go @@ -1,5 +1,6 @@ package git +//spellchecker:words path filepath reflect testing github config plumbing ggman internal testutil pkglib stream testlib golang slices import ( "os" "path" @@ -16,6 +17,8 @@ import ( "golang.org/x/exp/slices" ) +//spellchecker:words gogit commita commitb worktree + func Test_gogit_IsRepository(t *testing.T) { var gg gogit @@ -32,7 +35,7 @@ func Test_gogit_IsRepository(t *testing.T) { emptyFolder := testlib.TempDirAbs(t) // create a new folder that is deleted - deletedFolder := filepath.Join(testlib.TempDirAbs(t), "noexist") + deletedFolder := filepath.Join(testlib.TempDirAbs(t), "noExist") type args struct { localPath string @@ -73,7 +76,7 @@ func Test_gogit_IsRepositoryUnsafe(t *testing.T) { emptyFolder := testlib.TempDirAbs(t) // create a new folder that is deleted - deletedFolder := filepath.Join(testlib.TempDirAbs(t), "noexist") + deletedFolder := filepath.Join(testlib.TempDirAbs(t), "noExist") type args struct { localPath string @@ -217,7 +220,7 @@ func Test_gogit_GetRemotes(t *testing.T) { } }) - t.Run("GetRemotes() on a reposuitory with more than one remote", func(t *testing.T) { + t.Run("GetRemotes() on a repository with more than one remote", func(t *testing.T) { ggRepoObject, isRepo := gg.IsRepository(cloneB) if !isRepo { panic("IsRepository() failed") diff --git a/internal/mockenv/devplumbing.go b/internal/mockenv/devplumbing.go index 1c5e872..310b1dc 100644 --- a/internal/mockenv/devplumbing.go +++ b/internal/mockenv/devplumbing.go @@ -1,5 +1,7 @@ +//spellchecker:words mockenv package mockenv +//spellchecker:words github ggman pkglib stream import ( "fmt" "io" @@ -57,8 +59,8 @@ func (dp DevPlumbing) Backward(url string) string { } // Clone translates remoteURI and calls Clone on the underlying Plumbing. -func (dp DevPlumbing) Clone(stream stream.IOStream, remoteURI, clonePath string, extraargs ...string) error { - return dp.Plumbing.Clone(dp.stream(stream), dp.Forward(remoteURI), clonePath, extraargs...) +func (dp DevPlumbing) Clone(stream stream.IOStream, remoteURI, clonePath string, extraArgs ...string) error { + return dp.Plumbing.Clone(dp.stream(stream), dp.Forward(remoteURI), clonePath, extraArgs...) } // Fetch called Fetch on the underlying Plumbing diff --git a/internal/mockenv/devplumbing_test.go b/internal/mockenv/devplumbing_test.go index 1852065..8a63777 100644 --- a/internal/mockenv/devplumbing_test.go +++ b/internal/mockenv/devplumbing_test.go @@ -1,5 +1,7 @@ +//spellchecker:words mockenv package mockenv +//spellchecker:words reflect testing github config ggman gggit internal testutil pkglib stream testlib import ( "reflect" "testing" @@ -12,6 +14,8 @@ import ( "github.com/tkw1536/pkglib/testlib" ) +//spellchecker:words gogit + func TestDevPlumbing_Forward(t *testing.T) { mp := &DevPlumbing{URLMap: make(map[string]string)} @@ -71,7 +75,7 @@ func TestDevPlumbing_Backward(t *testing.T) { } func Test_DevPlumbing_GetRemotes(t *testing.T) { - // This test has been adapted from Test_gogit_GetRemotes. + // This test has been adapted from Test_goGit_GetRemotes. mp := &DevPlumbing{ Plumbing: gggit.NewPlumbing(), @@ -143,7 +147,7 @@ func Test_DevPlumbing_GetRemotes(t *testing.T) { } }) - t.Run("GetRemotes() on a reposuitory with more than one remote", func(t *testing.T) { + t.Run("GetRemotes() on a repository with more than one remote", func(t *testing.T) { ggRepoObject, isRepo := mp.IsRepository(cloneB) if !isRepo { panic("IsRepository() failed") diff --git a/internal/mockenv/mockenv.go b/internal/mockenv/mockenv.go index e77d9f5..ff8358d 100644 --- a/internal/mockenv/mockenv.go +++ b/internal/mockenv/mockenv.go @@ -1,6 +1,9 @@ // Package mockenv contains facilities for unit testing commands +// +//spellchecker:words mockenv package mockenv +//spellchecker:words bytes path filepath regexp strings testing github alessio shellescape ggman gggit internal testutil goprogram exit pkglib reflectx stream testlib import ( "bytes" "fmt" @@ -22,6 +25,8 @@ import ( "github.com/tkw1536/pkglib/testlib" ) +//spellchecker:words GGROOT workdir sandboxed + // TODO: Consider generalizing this part of the test suite. // so that we can re-use it for other programs too. @@ -158,14 +163,14 @@ func (mock *MockEnv) Run(command ggman.Command, workdir string, stdin string, ar stderrBuffer := &bytes.Buffer{} // create a program and run Main() - fakeggman := ggman.NewProgram() - ccommand, _ := reflectx.CopyInterface(command) - fakeggman.Register(ccommand) + fakeGGMAN := ggman.NewProgram() + cCommand, _ := reflectx.CopyInterface(command) + fakeGGMAN.Register(cCommand) stream := stream.NewIOStream(stdoutBuffer, stderrBuffer, stdinReader) // run the code - err := exit.AsError(fakeggman.Main(stream, env.Parameters{ + err := exit.AsError(fakeGGMAN.Main(stream, env.Parameters{ Variables: mock.vars, Plumbing: mock.plumbing, Workdir: workdir, diff --git a/internal/mockenv/mockenv_test.go b/internal/mockenv/mockenv_test.go index f36445f..e7d4250 100644 --- a/internal/mockenv/mockenv_test.go +++ b/internal/mockenv/mockenv_test.go @@ -1,6 +1,9 @@ // Package mockenv contains facilities for unit testing commands +// +//spellchecker:words mockenv package mockenv +//spellchecker:words path filepath testing github alessio shellescape ggman internal testutil pkglib testlib import ( "fmt" "path/filepath" @@ -13,6 +16,8 @@ import ( "github.com/tkw1536/pkglib/testlib" ) +//spellchecker:words GGROOT logprefix + // recordingT records a message passed to Errorf() type recordingT struct { message string diff --git a/internal/path/haschild.go b/internal/path/haschild.go index 79e5453..ea3f59c 100644 --- a/internal/path/haschild.go +++ b/internal/path/haschild.go @@ -1,6 +1,9 @@ // Package path provides path-based functions. +// +//spellchecker:words path package path +//spellchecker:words path filepath import ( "os" "path/filepath" diff --git a/internal/path/haschild_test.go b/internal/path/haschild_test.go index 95281de..d8be0be 100644 --- a/internal/path/haschild_test.go +++ b/internal/path/haschild_test.go @@ -1,5 +1,7 @@ +//spellchecker:words path package path +//spellchecker:words testing github ggman internal testutil import ( "testing" diff --git a/internal/path/join.go b/internal/path/join.go index aee8f74..b2107d3 100644 --- a/internal/path/join.go +++ b/internal/path/join.go @@ -1,5 +1,7 @@ +//spellchecker:words path package path +//spellchecker:words errors path filepath strings import ( "errors" "io/fs" diff --git a/internal/path/join_test.go b/internal/path/join_test.go index 23fd057..1ee22ad 100644 --- a/internal/path/join_test.go +++ b/internal/path/join_test.go @@ -1,5 +1,7 @@ +//spellchecker:words path package path +//spellchecker:words path filepath testing github ggman internal testutil pkglib testlib import ( "os" "path/filepath" diff --git a/internal/pattern/pattern.go b/internal/pattern/pattern.go index 26247aa..aa0fb53 100644 --- a/internal/pattern/pattern.go +++ b/internal/pattern/pattern.go @@ -1,6 +1,9 @@ // Package pattern provides Pattern +// +//spellchecker:words pattern package pattern +//spellchecker:words math strings github danwakefield fnmatch lithammer fuzzysearch fuzzy import ( "math" "strings" @@ -9,6 +12,8 @@ import ( "github.com/lithammer/fuzzysearch/fuzzy" ) +//spellchecker:words casefold + // Pattern is a float predicate on strings. // // A pattern must return a float between 0 and 1 (inclusive) when it matches and a negative number when not. diff --git a/internal/pattern/pattern_test.go b/internal/pattern/pattern_test.go index 408e028..e938977 100644 --- a/internal/pattern/pattern_test.go +++ b/internal/pattern/pattern_test.go @@ -1,11 +1,15 @@ +//spellchecker:words pattern package pattern +//spellchecker:words reflect strings testing import ( "reflect" "strings" "testing" ) +//spellchecker:words aaaab + func TestNewGlobPattern(t *testing.T) { type args struct { s string @@ -220,7 +224,7 @@ func TestNewSplitGlobPattern(t *testing.T) { want SplitPattern }{ { - "simple non-fuzzy spliter", + "simple non-fuzzy splitter", args{"a;a*b;;", simpleSplitter, false}, SplitPattern{ Split: simpleSplitter, @@ -234,7 +238,7 @@ func TestNewSplitGlobPattern(t *testing.T) { }, { - "simple fuzzy spliter", + "simple fuzzy splitter", args{"a;a*b;;", simpleSplitter, true}, SplitPattern{ Split: simpleSplitter, diff --git a/internal/record/record.go b/internal/record/record.go index c2a24b5..5b1135e 100644 --- a/internal/record/record.go +++ b/internal/record/record.go @@ -1,6 +1,9 @@ // Package record provides Record +// +//spellchecker:words record package record +//spellchecker:words sync import ( "sync" ) diff --git a/internal/record/record_test.go b/internal/record/record_test.go index 9bb25ce..c3402c2 100644 --- a/internal/record/record_test.go +++ b/internal/record/record_test.go @@ -1,5 +1,7 @@ +//spellchecker:words record package record +//spellchecker:words sync atomic testing import ( "fmt" "sync" diff --git a/internal/split/split.go b/internal/split/split.go index 464224d..186f037 100644 --- a/internal/split/split.go +++ b/internal/split/split.go @@ -1,6 +1,9 @@ // Package split provides Before and After. +// +//spellchecker:words split package split +//spellchecker:words strings unicode import ( "strings" "unicode/utf8" diff --git a/internal/split/split_test.go b/internal/split/split_test.go index a5f87ae..9486ec2 100644 --- a/internal/split/split_test.go +++ b/internal/split/split_test.go @@ -1,5 +1,7 @@ +//spellchecker:words split package split +//spellchecker:words testing import ( "testing" ) diff --git a/internal/testutil/case.go b/internal/testutil/case.go index bfa9f9b..47a88f8 100644 --- a/internal/testutil/case.go +++ b/internal/testutil/case.go @@ -1,5 +1,7 @@ +//spellchecker:words testutil package testutil +//spellchecker:words errors path filepath testing github pkglib testlib import ( "errors" "io/fs" diff --git a/internal/testutil/docs.go b/internal/testutil/docs.go index 954f3ab..306fbee 100644 --- a/internal/testutil/docs.go +++ b/internal/testutil/docs.go @@ -2,4 +2,8 @@ // // Functions in this package are not considered part of the stable interface. // For this reason most functions are themselves untested. +// +//spellchecker:words testutil package testutil + +//spellchecker:words ggman diff --git a/internal/testutil/env.go b/internal/testutil/env.go index 094da80..6cae338 100644 --- a/internal/testutil/env.go +++ b/internal/testutil/env.go @@ -1,3 +1,4 @@ +//spellchecker:words testutil package testutil import "os" diff --git a/internal/testutil/env_test.go b/internal/testutil/env_test.go index 969a4b6..3646b17 100644 --- a/internal/testutil/env_test.go +++ b/internal/testutil/env_test.go @@ -1,5 +1,7 @@ +//spellchecker:words testutil package testutil +//spellchecker:words testing import ( "os" "testing" diff --git a/internal/testutil/git.go b/internal/testutil/git.go index d13dced..f1cfdf0 100644 --- a/internal/testutil/git.go +++ b/internal/testutil/git.go @@ -1,5 +1,7 @@ +//spellchecker:words testutil package testutil +//spellchecker:words path testing time github config plumbing object pkglib testlib import ( "os" "path" @@ -13,6 +15,8 @@ import ( "github.com/tkw1536/pkglib/testlib" ) +//spellchecker:words worktree + // NewTestRepo creates a new (empty) repository for testing purposes. // clonePath is the path where the repository is located on disk. // repo is a reference to the created repository. diff --git a/internal/testutil/git_test.go b/internal/testutil/git_test.go index 646ca31..44a6fc6 100644 --- a/internal/testutil/git_test.go +++ b/internal/testutil/git_test.go @@ -1,5 +1,7 @@ +//spellchecker:words testutil package testutil +//spellchecker:words testing github import ( "os" "testing" diff --git a/internal/testutil/path.go b/internal/testutil/path.go index 6e936f0..e54a6f9 100644 --- a/internal/testutil/path.go +++ b/internal/testutil/path.go @@ -1,5 +1,7 @@ +//spellchecker:words testutil package testutil +//spellchecker:words path filepath import ( "os" "path/filepath" diff --git a/internal/testutil/path_test.go b/internal/testutil/path_test.go index 9ddf14b..de09193 100644 --- a/internal/testutil/path_test.go +++ b/internal/testutil/path_test.go @@ -1,5 +1,7 @@ +//spellchecker:words testutil package testutil +//spellchecker:words testing import ( "os" "testing" diff --git a/internal/url/url.go b/internal/url/url.go index d24176e..18ee376 100644 --- a/internal/url/url.go +++ b/internal/url/url.go @@ -1,6 +1,7 @@ // Package url provides utilities for URL parsing package url +//spellchecker:words errors math import ( "errors" "math" diff --git a/internal/url/url_test.go b/internal/url/url_test.go index eab53d4..cadc8fb 100644 --- a/internal/url/url_test.go +++ b/internal/url/url_test.go @@ -1,5 +1,6 @@ package url +//spellchecker:words math strconv testing import ( "math" "strconv" @@ -8,7 +9,7 @@ import ( func Test_ParsePort(t *testing.T) { type args struct { - portstring string + portString string } tests := []struct { name string @@ -28,7 +29,7 @@ func Test_ParsePort(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - gotPort, err := ParsePort(tt.args.portstring) + gotPort, err := ParsePort(tt.args.portString) if (err != nil) != tt.wantErr { t.Errorf("parsePort() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/internal/walker/context.go b/internal/walker/context.go index 3ca3681..3c182bb 100644 --- a/internal/walker/context.go +++ b/internal/walker/context.go @@ -1,5 +1,7 @@ +//spellchecker:words walker package walker +//spellchecker:words golang slices import ( "io/fs" @@ -95,8 +97,8 @@ func (w context[S]) Depth() int { return len(w.path) } -func (w context[S]) Mark(prio float64) { - w.w.reportResult(w.nodePath, w.rNodePath, prio) +func (w context[S]) Mark(priority float64) { + w.w.reportResult(w.nodePath, w.rNodePath, priority) } func (w *context[S]) Snapshot(update func(snapshot S) S) { diff --git a/internal/walker/fs.go b/internal/walker/fs.go index 4d3f228..1190522 100644 --- a/internal/walker/fs.go +++ b/internal/walker/fs.go @@ -1,5 +1,7 @@ +//spellchecker:words walker package walker +//spellchecker:words path filepath github pkglib import ( "io/fs" "os" @@ -8,6 +10,8 @@ import ( "github.com/tkw1536/pkglib/fsx" ) +//spellchecker:words fsys + // FS represents a file system for use by walker // // See NewRealFS for a instantiating a sample implementation. diff --git a/internal/walker/scan.go b/internal/walker/scan.go index dd19589..fe32fe9 100644 --- a/internal/walker/scan.go +++ b/internal/walker/scan.go @@ -1,3 +1,4 @@ +//spellchecker:words walker package walker import "io/fs" @@ -21,7 +22,7 @@ func Scan(Visit ScanProcess, Params Params) ([]string, error) { // we can safely access results directly // because now the walker becomes inaccessible! - return scanner.rpaths, err + return scanner.rPaths, err } // ScanProcess is a function that is called once for each directory that is being walked. diff --git a/internal/walker/scan_test.go b/internal/walker/scan_test.go index 5572d5c..aa9ffd0 100644 --- a/internal/walker/scan_test.go +++ b/internal/walker/scan_test.go @@ -1,5 +1,7 @@ +//spellchecker:words walker package walker +//spellchecker:words path filepath reflect testing github ggman internal testutil pkglib testlib import ( "os" "path/filepath" @@ -23,8 +25,8 @@ func TestScan(t *testing.T) { } } - symlink := func(oldname, newname string) { - err := os.Symlink(filepath.Join(base, oldname), filepath.Join(base, newname)) + symlink := func(oldName, newName string) { + err := os.Symlink(filepath.Join(base, oldName), filepath.Join(base, newName)) if err != nil { panic(err) } diff --git a/internal/walker/sweep_test.go b/internal/walker/sweep_test.go index 7d512b2..64e13cf 100644 --- a/internal/walker/sweep_test.go +++ b/internal/walker/sweep_test.go @@ -1,5 +1,7 @@ +//spellchecker:words walker package walker +//spellchecker:words path filepath reflect testing github ggman internal testutil pkglib testlib import ( "os" "path/filepath" diff --git a/internal/walker/sweeper.go b/internal/walker/sweeper.go index 1fc5927..0062472 100644 --- a/internal/walker/sweeper.go +++ b/internal/walker/sweeper.go @@ -1,7 +1,10 @@ +//spellchecker:words walker package walker import "io/fs" +//spellchecker:words sweeped + // Sweep recursively sweeps a directory tree, and returns all nodes that are empty or contain only empty directories // When an error occurs, may continue sweeping until all units have exited and returns nil, err. // @@ -20,7 +23,7 @@ func Sweep(Visit SweepProcess, Params Params) ([]string, error) { // we can safely access results directly // because now the walker becomes inaccessible! - return scanner.rpaths, err + return scanner.rPaths, err } // SweepProcess is a function that is called once for each directory that is being sweeped. diff --git a/internal/walker/walker.go b/internal/walker/walker.go index 90ed9a5..2bf85a7 100644 --- a/internal/walker/walker.go +++ b/internal/walker/walker.go @@ -1,6 +1,9 @@ // Package walker provides Walker, Scan and Sweep. +// +//spellchecker:words walker package walker +//spellchecker:words errors strings sync atomic github ggman internal record pkglib sema golang slices import ( "errors" "io/fs" @@ -41,7 +44,7 @@ type Walker[S any] struct { ctxPool sync.Pool // pool for *context[S] objects paths []string - rpaths []string + rPaths []string scores []float64 Params Params @@ -157,7 +160,7 @@ type WalkContext[S any] interface { // Mark the current node as a result with the given priority. // May be called multiple times, in which case the node is marked as a result multiple times. - Mark(prio float64) + Mark(priority float64) } // Walk begins recursively walking the directory tree starting at the roots defined in Config. @@ -210,11 +213,11 @@ func (w *Walker[S]) Walk() error { // store the real (textual) results w.paths = make([]string, len(results)) - w.rpaths = make([]string, len(results)) + w.rPaths = make([]string, len(results)) w.scores = make([]float64, len(results)) for i, r := range results { w.paths[i] = r.NodePath - w.rpaths[i] = r.NodeRPath + w.rPaths[i] = r.NodeRPath w.scores[i] = r.Score } @@ -304,17 +307,17 @@ func (w *Walker[S]) walk(sync bool, ctx *context[S]) (ok bool) { w.wg.Done() case action == DoConcurrent: // work asynchronously and discard the parent! - go func(cctx *context[S]) { - defer w.returnCtx(cctx) - w.walk(false, cctx) + go func(cContext *context[S]) { + defer w.returnCtx(cContext) + w.walk(false, cContext) }(ctx.sub(entry)) case action == DoSync: // run the child processing! - ok, value := func(cctx *context[S]) (bool, any) { - defer w.returnCtx(cctx) + ok, value := func(cContext *context[S]) (bool, any) { + defer w.returnCtx(cContext) - ok := w.walk(true, cctx) - return ok, cctx.snapshot + ok := w.walk(true, cContext) + return ok, cContext.snapshot }(ctx.sub(entry)) if err := w.Process.AfterVisitChild(entry, value, ok, ctx); err != nil { @@ -370,7 +373,7 @@ func (w *Walker[S]) Paths(resolved bool) []string { } if resolved { - return slices.Clone(w.rpaths) + return slices.Clone(w.rPaths) } else { return slices.Clone(w.paths) } diff --git a/program.go b/program.go index 45a43c8..3cdf0a4 100644 --- a/program.go +++ b/program.go @@ -1,5 +1,7 @@ +//spellchecker:words ggman package ggman +//spellchecker:words github ggman constants goprogram exit meta import ( "fmt"