fixed git

This commit is contained in:
Kasper Juul Hermansen 2022-09-18 11:50:57 +02:00
parent 64e9f8dca8
commit c865b597c0
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912

View File

@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"strings"
"time"
"git.front.kjuulh.io/kjuulh/kraken/internal/services/signer"
@ -85,8 +84,8 @@ func (g *Git) GetOriginHEADForRepo(ctx context.Context, gitRepo *GitRepo) (strin
headRef := ""
for _, ref := range refs {
//g.logger.Debug(ref.String())
if ref.Name().IsBranch() && strings.Contains(ref.String(), "/heads/") {
headRef = ref.Name().Short()
if !ref.Name().IsBranch() {
headRef = ref.Target().Short()
}
}
@ -114,7 +113,7 @@ func (g *Git) CloneBranch(ctx context.Context, storageArea *storage.Area, repoUr
Auth: auth,
RemoteName: "origin",
ReferenceName: plumbing.NewBranchReferenceName(branch),
SingleBranch: true,
SingleBranch: false,
NoCheckout: false,
Depth: 1,
RecurseSubmodules: 1,
@ -125,7 +124,7 @@ func (g *Git) CloneBranch(ctx context.Context, storageArea *storage.Area, repoUr
}
repo, err := git.PlainCloneContext(ctx, storageArea.Path, false, &cloneOptions)
if err != nil {
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
return nil, err
}
@ -150,7 +149,7 @@ func (g *Git) Clone(ctx context.Context, storageArea *storage.Area, repoUrl stri
URL: repoUrl,
Auth: auth,
RemoteName: "origin",
// ReferenceName: "refs/heads/main",
ReferenceName: "refs/heads/main",
SingleBranch: false,
NoCheckout: false,
Depth: 1,
@ -252,7 +251,7 @@ func (g *Git) CreateBranch(ctx context.Context, gitRepo *GitRepo) error {
InsecureSkipTLS: false,
CABundle: []byte{},
})
if err != nil {
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
return fmt.Errorf("could not pull from origin: %w", err)
}