diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index f231305..3a8ba98 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go_version: [1.18, 1.15, 1.16, 1.17] + go_version: [1.18, 1.19, 1.16, 1.17] steps: - name: Check out code diff --git a/chlog/filter_test.go b/chlog/filter_test.go index b963956..7b95cdb 100644 --- a/chlog/filter_test.go +++ b/chlog/filter_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gookit/gitw/chlog" - "github.com/stretchr/testify/assert" + "github.com/gookit/goutil/testutil/assert" ) func TestKeywordsFilter(t *testing.T) { diff --git a/cmd_quick.go b/cmd_quick.go deleted file mode 100644 index 8a6f3bc..0000000 --- a/cmd_quick.go +++ /dev/null @@ -1 +0,0 @@ -package gitw diff --git a/cmds_test.go b/cmds_test.go index 0a7e079..ec9ca59 100644 --- a/cmds_test.go +++ b/cmds_test.go @@ -5,15 +5,15 @@ import ( "github.com/gookit/gitw" "github.com/gookit/goutil/dump" - "github.com/stretchr/testify/assert" + "github.com/gookit/goutil/testutil/assert" ) func TestTags(t *testing.T) { ts, err := gitw.Tags() - assert.NoError(t, err) + assert.NoErr(t, err) dump.P(ts) ts, err = gitw.Tags("-n", "--sort=-version:refname") - assert.NoError(t, err) + assert.NoErr(t, err) dump.P(ts) } diff --git a/go.mod b/go.mod index eec3de2..51946fe 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,21 @@ module github.com/gookit/gitw -go 1.15 +go 1.18 require ( github.com/gookit/color v1.5.2 github.com/gookit/goutil v0.5.15 github.com/gookit/slog v0.3.3 - github.com/stretchr/testify v1.8.0 gopkg.in/yaml.v3 v3.0.1 ) + +require ( + github.com/gookit/gsr v0.0.7 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect + golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect + golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect + golang.org/x/text v0.3.8 // indirect +) diff --git a/info_test.go b/info_test.go index cdf125b..c7962c7 100644 --- a/info_test.go +++ b/info_test.go @@ -6,92 +6,92 @@ import ( "github.com/gookit/gitw" "github.com/gookit/goutil/dump" - "github.com/stretchr/testify/assert" + "github.com/gookit/goutil/testutil/assert" ) func TestNewRemoteInfo(t *testing.T) { URL := "https://github.com/gookit/gitw" rt, err := gitw.NewRemoteInfo("origin", URL, gitw.RemoteTypePush) - assert.NoError(t, err) + assert.NoErr(t, err) assert.True(t, rt.Valid()) assert.False(t, rt.Invalid()) - assert.Equal(t, "origin", rt.Name) - assert.Equal(t, gitw.RemoteTypePush, rt.Type) - assert.Equal(t, "github.com", rt.Host) - assert.Equal(t, "gookit/gitw", rt.RepoPath()) - assert.Equal(t, gitw.SchemeHTTPS, rt.Scheme) - assert.Equal(t, gitw.ProtoHTTP, rt.Proto) - assert.Equal(t, rt.URL, rt.RawURLOfHTTP()) + assert.Eq(t, "origin", rt.Name) + assert.Eq(t, gitw.RemoteTypePush, rt.Type) + assert.Eq(t, "github.com", rt.Host) + assert.Eq(t, "gookit/gitw", rt.RepoPath()) + assert.Eq(t, gitw.SchemeHTTPS, rt.Scheme) + assert.Eq(t, gitw.ProtoHTTP, rt.Proto) + assert.Eq(t, rt.URL, rt.RawURLOfHTTP()) URL = "git@github.com:gookit/gitw.git" rt, err = gitw.NewRemoteInfo("origin", URL, gitw.RemoteTypePush) - assert.NoError(t, err) - assert.Equal(t, "github.com", rt.Host) - assert.Equal(t, "gookit/gitw", rt.Path()) - assert.Equal(t, gitw.SchemeGIT, rt.Scheme) - assert.Equal(t, gitw.ProtoSSH, rt.Proto) - assert.Equal(t, "https://github.com/gookit/gitw", rt.RawURLOfHTTP()) + assert.NoErr(t, err) + assert.Eq(t, "github.com", rt.Host) + assert.Eq(t, "gookit/gitw", rt.Path()) + assert.Eq(t, gitw.SchemeGIT, rt.Scheme) + assert.Eq(t, gitw.ProtoSSH, rt.Proto) + assert.Eq(t, "https://github.com/gookit/gitw", rt.RawURLOfHTTP()) } func TestParseBranchLine_simple(t *testing.T) { info, err := gitw.ParseBranchLine("* ", false) - assert.Error(t, err) + assert.Err(t, err) info, err = gitw.ParseBranchLine("* (HEAD)", false) - assert.Error(t, err) + assert.Err(t, err) info, err = gitw.ParseBranchLine("* fea/new_br001", false) - assert.NoError(t, err) + assert.NoErr(t, err) assert.True(t, info.Current) assert.True(t, info.IsValid()) assert.False(t, info.IsRemoted()) - assert.Equal(t, "", info.Remote) - assert.Equal(t, "fea/new_br001", info.Name) - assert.Equal(t, "fea/new_br001", info.Short) + assert.Eq(t, "", info.Remote) + assert.Eq(t, "fea/new_br001", info.Name) + assert.Eq(t, "fea/new_br001", info.Short) info, err = gitw.ParseBranchLine(" remotes/source/my_new_br ", false) - assert.NoError(t, err) + assert.NoErr(t, err) assert.False(t, info.Current) assert.True(t, info.IsValid()) assert.True(t, info.IsRemoted()) - assert.Equal(t, "source", info.Remote) - assert.Equal(t, "remotes/source/my_new_br", info.Name) - assert.Equal(t, "my_new_br", info.Short) + assert.Eq(t, "source", info.Remote) + assert.Eq(t, "remotes/source/my_new_br", info.Name) + assert.Eq(t, "my_new_br", info.Short) } func TestParseBranchLine_verbose(t *testing.T) { info, err := gitw.ParseBranchLine("* fea/new_br001 73j824d the message 001", true) - assert.NoError(t, err) + assert.NoErr(t, err) assert.True(t, info.Current) assert.True(t, info.IsValid()) assert.False(t, info.IsRemoted()) - assert.Equal(t, "", info.Remote) - assert.Equal(t, "fea/new_br001", info.Name) - assert.Equal(t, "fea/new_br001", info.Short) - assert.Equal(t, "73j824d", info.Hash) - assert.Equal(t, "the message 001", info.HashMsg) + assert.Eq(t, "", info.Remote) + assert.Eq(t, "fea/new_br001", info.Name) + assert.Eq(t, "fea/new_br001", info.Short) + assert.Eq(t, "73j824d", info.Hash) + assert.Eq(t, "the message 001", info.HashMsg) info, err = gitw.ParseBranchLine(" remotes/source/my_new_br 6fb8dcd the message 003 ", true) - assert.NoError(t, err) + assert.NoErr(t, err) dump.P(info) assert.False(t, info.Current) assert.True(t, info.IsValid()) assert.True(t, info.IsRemoted()) - assert.Equal(t, "source", info.Remote) - assert.Equal(t, "remotes/source/my_new_br", info.Name) - assert.Equal(t, "my_new_br", info.Short) - assert.Equal(t, "6fb8dcd", info.Hash) - assert.Equal(t, "the message 003", info.HashMsg) + assert.Eq(t, "source", info.Remote) + assert.Eq(t, "remotes/source/my_new_br", info.Name) + assert.Eq(t, "my_new_br", info.Short) + assert.Eq(t, "6fb8dcd", info.Hash) + assert.Eq(t, "the message 003", info.HashMsg) info, err = gitw.ParseBranchLine("* (头指针在 v0.2.3 分离) 3c08adf chore: update readme add branch info docs", true) - assert.Error(t, err) + assert.Err(t, err) info, err = gitw.ParseBranchLine("* (HEAD detached at pull/29/merge) 62f3455 Merge cfc79b748e176c1c9e266c8bc413c87fe974acef into c9503c2aef993a2cf582d90c137deda53c9bca68", true) - assert.Error(t, err) + assert.Err(t, err) } func TestBranchInfo_parse_simple(t *testing.T) { @@ -106,11 +106,11 @@ func TestBranchInfo_parse_simple(t *testing.T) { bis.Parse() // dump.P(bis) - assert.NoError(t, bis.LastErr()) + assert.NoErr(t, bis.LastErr()) assert.NotEmpty(t, bis.Current()) assert.NotEmpty(t, bis.Locales()) assert.NotEmpty(t, bis.Remotes("")) - assert.Equal(t, "master", bis.Current().Name) + assert.Eq(t, "master", bis.Current().Name) } func TestBranchInfo_parse_invalid(t *testing.T) { @@ -124,7 +124,7 @@ func TestBranchInfo_parse_invalid(t *testing.T) { bis.Parse() // dump.P(bis) - assert.Error(t, bis.LastErr()) + assert.Err(t, bis.LastErr()) assert.Nil(t, bis.Current()) assert.NotEmpty(t, bis.Locales()) assert.NotEmpty(t, bis.Remotes("origin")) @@ -144,11 +144,11 @@ func TestBranchInfo_parse_verbose(t *testing.T) { bis.Parse() // dump.P(bis) - assert.NoError(t, bis.LastErr()) + assert.NoErr(t, bis.LastErr()) assert.NotEmpty(t, bis.Current()) assert.NotEmpty(t, bis.Locales()) assert.NotEmpty(t, bis.Remotes("")) - assert.Equal(t, "master", bis.Current().Name) + assert.Eq(t, "master", bis.Current().Name) // search rets := bis.Search("new", gitw.BrSearchLocal) @@ -165,5 +165,5 @@ func TestBranchInfo_parse_verbose(t *testing.T) { assert.NotEmpty(t, rets) assert.Len(t, rets, 1) assert.True(t, rets[0].IsRemoted()) - assert.Equal(t, "origin", rets[0].Remote) + assert.Eq(t, "origin", rets[0].Remote) } diff --git a/repo_test.go b/repo_test.go index 881ec60..cf06b78 100644 --- a/repo_test.go +++ b/repo_test.go @@ -6,8 +6,8 @@ import ( "github.com/gookit/gitw" "github.com/gookit/goutil/dump" "github.com/gookit/goutil/sysutil" + "github.com/gookit/goutil/testutil/assert" "github.com/gookit/slog" - "github.com/stretchr/testify/assert" ) var repo = gitw.NewRepo("./").WithFn(func(r *gitw.Repo) { @@ -23,7 +23,7 @@ func TestRepo_RemoteInfos(t *testing.T) { rs := repo.AllRemoteInfos() dump.P(rs) - assert.NoError(t, repo.Err()) + assert.NoErr(t, repo.Err()) assert.NotEmpty(t, rs) assert.True(t, repo.HasRemote(gitw.DefaultRemoteName)) @@ -37,18 +37,18 @@ func TestRepo_DefaultRemoteInfo(t *testing.T) { assert.NotEmpty(t, rt) assert.True(t, rt.Valid()) assert.False(t, rt.Invalid()) - assert.Equal(t, gitw.DefaultRemoteName, rt.Name) - assert.Equal(t, "git@github.com:gookit/gitw.git", rt.GitURL()) - assert.Equal(t, "http://github.com/gookit/gitw", rt.URLOfHTTP()) - assert.Equal(t, "https://github.com/gookit/gitw", rt.URLOfHTTPS()) + assert.Eq(t, gitw.DefaultRemoteName, rt.Name) + assert.Eq(t, "git@github.com:gookit/gitw.git", rt.GitURL()) + assert.Eq(t, "http://github.com/gookit/gitw", rt.URLOfHTTP()) + assert.Eq(t, "https://github.com/gookit/gitw", rt.URLOfHTTPS()) rt = repo.RandomRemoteInfo(gitw.RemoteTypePush) assert.NotEmpty(t, rt) } func TestRepo_AutoMatchTag(t *testing.T) { - assert.Equal(t, "HEAD", repo.AutoMatchTag("head")) - assert.Equal(t, "541fb9d", repo.AutoMatchTag("541fb9d")) + assert.Eq(t, "HEAD", repo.AutoMatchTag("head")) + assert.Eq(t, "541fb9d", repo.AutoMatchTag("541fb9d")) } func TestRepo_BranchInfos(t *testing.T) { @@ -66,8 +66,8 @@ func TestRepo_BranchInfos(t *testing.T) { mbr := repo.BranchInfo("main") if mbr != nil { - assert.Equal(t, "main", mbr.Name) - assert.Equal(t, "main", mbr.Short) + assert.Eq(t, "main", mbr.Name) + assert.Eq(t, "main", mbr.Short) } } @@ -77,12 +77,12 @@ func TestRepo_Info(t *testing.T) { assert.Nil(t, repo.Err()) assert.NotNil(t, info) - assert.Equal(t, "gitw", info.Name) + assert.Eq(t, "gitw", info.Name) } func TestRepo_AutoMatchTagByTagType(t *testing.T) { - assert.Equal(t, "HEAD", repo.AutoMatchTagByType("head", 0)) - assert.Equal(t, "541fb9d", repo.AutoMatchTagByType("541fb9d", 0)) + assert.Eq(t, "HEAD", repo.AutoMatchTagByType("head", 0)) + assert.Eq(t, "541fb9d", repo.AutoMatchTagByType("541fb9d", 0)) } func TestRepo_TagsSortedByCreatorDate(t *testing.T) {