with action creator

This commit is contained in:
2022-09-13 22:54:49 +02:00
parent 564147eb6a
commit ce55f6523c
9 changed files with 208 additions and 77 deletions

View File

@@ -70,7 +70,7 @@ func (g *Git) Clone(ctx context.Context, storageArea *storage.Area, repoUrl stri
Auth: auth,
RemoteName: "origin",
ReferenceName: "refs/heads/main",
SingleBranch: true,
SingleBranch: false,
NoCheckout: false,
Depth: 1,
RecurseSubmodules: 1,
@@ -90,6 +90,21 @@ func (g *Git) Clone(ctx context.Context, storageArea *storage.Area, repoUrl stri
return &GitRepo{repo: repo}, nil
}
func (g *Git) Checkout(ctx context.Context, gitRepo *GitRepo, branch string) error {
wt, err := gitRepo.repo.Worktree()
if err != nil {
return err
}
return wt.Checkout(&git.CheckoutOptions{
Hash: [20]byte{},
Branch: plumbing.NewBranchReferenceName(branch),
Create: false,
Force: false,
Keep: false,
})
}
func (g *Git) getProgressWriter() *zapio.Writer {
return &zapio.Writer{
Log: g.logger.With(zap.String("process", "go-git")),