refactor: Update dependencies and remove unused code

This commit is contained in:
Marvin Zhang
2024-07-13 11:18:30 +08:00
parent 96ba586cd2
commit efabb2071b

View File

@@ -2,9 +2,7 @@ package vcs
import (
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/plumbing/transport"
"strings"
)
@@ -53,12 +51,6 @@ func WithPrivateKey(key string) GitOption {
}
}
func WithDefaultBranch(branch string) GitOption {
return func(c *GitClient) {
c.defaultBranch = branch
}
}
func WithDefaultInit(init bool) GitOption {
return func(c *GitClient) {
c.defaultInit = init
@@ -79,48 +71,6 @@ func WithURL(url string) GitCloneOption {
}
}
func WithAuthClone(auth transport.AuthMethod) GitCloneOption {
return func(o *git.CloneOptions) {
o.Auth = auth
}
}
func WithRemoteName(name string) GitCloneOption {
return func(o *git.CloneOptions) {
o.RemoteName = name
}
}
func WithSingleBranch(singleBranch bool) GitCloneOption {
return func(o *git.CloneOptions) {
o.SingleBranch = singleBranch
}
}
func WithNoCheckout(noCheckout bool) GitCloneOption {
return func(o *git.CloneOptions) {
o.NoCheckout = noCheckout
}
}
func WithDepthClone(depth int) GitCloneOption {
return func(o *git.CloneOptions) {
o.Depth = depth
}
}
func WithRecurseSubmodules(recurseSubmodules git.SubmoduleRescursivity) GitCloneOption {
return func(o *git.CloneOptions) {
o.RecurseSubmodules = recurseSubmodules
}
}
func WithTags(tags git.TagMode) GitCloneOption {
return func(o *git.CloneOptions) {
o.Tags = tags
}
}
type GitCheckoutOption func(o *git.CheckoutOptions)
func WithBranch(branch string) GitCheckoutOption {
@@ -145,30 +95,6 @@ func WithHash(hash string) GitCheckoutOption {
type GitCommitOption func(o *git.CommitOptions)
func WithAll(all bool) GitCommitOption {
return func(o *git.CommitOptions) {
o.All = all
}
}
func WithAuthor(author *object.Signature) GitCommitOption {
return func(o *git.CommitOptions) {
o.Author = author
}
}
func WithCommitter(committer *object.Signature) GitCommitOption {
return func(o *git.CommitOptions) {
o.Committer = committer
}
}
func WithParents(parents []plumbing.Hash) GitCommitOption {
return func(o *git.CommitOptions) {
o.Parents = parents
}
}
type GitPullOption func(o *git.PullOptions)
func WithRemoteNamePull(name string) GitPullOption {
@@ -183,12 +109,6 @@ func WithBranchNamePull(branch string) GitPullOption {
}
}
func WithDepthPull(depth int) GitPullOption {
return func(o *git.PullOptions) {
o.Depth = depth
}
}
func WithAuthPull(auth transport.AuthMethod) GitPullOption {
return func(o *git.PullOptions) {
if auth != nil {
@@ -197,58 +117,16 @@ func WithAuthPull(auth transport.AuthMethod) GitPullOption {
}
}
func WithRecurseSubmodulesPull(recurseSubmodules git.SubmoduleRescursivity) GitPullOption {
return func(o *git.PullOptions) {
o.RecurseSubmodules = recurseSubmodules
}
}
func WithForcePull(force bool) GitPullOption {
return func(o *git.PullOptions) {
o.Force = force
}
}
type GitPushOption func(o *git.PushOptions)
func WithRemoteNamePush(name string) GitPushOption {
return func(o *git.PushOptions) {
o.RemoteName = name
}
}
func WithRefSpecs(specs []config.RefSpec) GitPushOption {
return func(o *git.PushOptions) {
o.RefSpecs = specs
}
}
func WithAuthPush(auth transport.AuthMethod) GitPushOption {
return func(o *git.PushOptions) {
o.Auth = auth
}
}
func WithPrune(prune bool) GitPushOption {
return func(o *git.PushOptions) {
o.Prune = prune
}
}
func WithForcePush(force bool) GitPushOption {
return func(o *git.PushOptions) {
o.Force = force
}
}
type GitResetOption func(o *git.ResetOptions)
func WithCommit(commit plumbing.Hash) GitResetOption {
return func(o *git.ResetOptions) {
o.Commit = commit
}
}
func WithMode(mode git.ResetMode) GitResetOption {
return func(o *git.ResetOptions) {
o.Mode = mode