fixed git
This commit is contained in:
parent
64e9f8dca8
commit
c865b597c0
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/signer"
|
"git.front.kjuulh.io/kjuulh/kraken/internal/services/signer"
|
||||||
@ -85,8 +84,8 @@ func (g *Git) GetOriginHEADForRepo(ctx context.Context, gitRepo *GitRepo) (strin
|
|||||||
headRef := ""
|
headRef := ""
|
||||||
for _, ref := range refs {
|
for _, ref := range refs {
|
||||||
//g.logger.Debug(ref.String())
|
//g.logger.Debug(ref.String())
|
||||||
if ref.Name().IsBranch() && strings.Contains(ref.String(), "/heads/") {
|
if !ref.Name().IsBranch() {
|
||||||
headRef = ref.Name().Short()
|
headRef = ref.Target().Short()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +113,7 @@ func (g *Git) CloneBranch(ctx context.Context, storageArea *storage.Area, repoUr
|
|||||||
Auth: auth,
|
Auth: auth,
|
||||||
RemoteName: "origin",
|
RemoteName: "origin",
|
||||||
ReferenceName: plumbing.NewBranchReferenceName(branch),
|
ReferenceName: plumbing.NewBranchReferenceName(branch),
|
||||||
SingleBranch: true,
|
SingleBranch: false,
|
||||||
NoCheckout: false,
|
NoCheckout: false,
|
||||||
Depth: 1,
|
Depth: 1,
|
||||||
RecurseSubmodules: 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)
|
repo, err := git.PlainCloneContext(ctx, storageArea.Path, false, &cloneOptions)
|
||||||
if err != nil {
|
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,10 +146,10 @@ func (g *Git) Clone(ctx context.Context, storageArea *storage.Area, repoUrl stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
cloneOptions := git.CloneOptions{
|
cloneOptions := git.CloneOptions{
|
||||||
URL: repoUrl,
|
URL: repoUrl,
|
||||||
Auth: auth,
|
Auth: auth,
|
||||||
RemoteName: "origin",
|
RemoteName: "origin",
|
||||||
// ReferenceName: "refs/heads/main",
|
ReferenceName: "refs/heads/main",
|
||||||
SingleBranch: false,
|
SingleBranch: false,
|
||||||
NoCheckout: false,
|
NoCheckout: false,
|
||||||
Depth: 1,
|
Depth: 1,
|
||||||
@ -252,7 +251,7 @@ func (g *Git) CreateBranch(ctx context.Context, gitRepo *GitRepo) error {
|
|||||||
InsecureSkipTLS: false,
|
InsecureSkipTLS: false,
|
||||||
CABundle: []byte{},
|
CABundle: []byte{},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
|
||||||
return fmt.Errorf("could not pull from origin: %w", err)
|
return fmt.Errorf("could not pull from origin: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user