with actual head branch name
This commit is contained in:
parent
1889f05db2
commit
64e9f8dca8
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
.cuddle/
|
||||
.env
|
||||
|
@ -2,7 +2,9 @@ package providers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/signer"
|
||||
@ -63,12 +65,12 @@ func NewGit(logger *zap.Logger, gitConfig *GitConfig, openPGP *signer.OpenPGP) *
|
||||
}
|
||||
|
||||
func (g *Git) GetOriginHEADForRepo(ctx context.Context, gitRepo *GitRepo) (string, error) {
|
||||
remote, err := gitRepo.repo.Remote("origin")
|
||||
auth, err := g.GetAuth()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
auth, err := g.GetAuth()
|
||||
remote, err := gitRepo.repo.Remote("origin")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -82,11 +84,16 @@ func (g *Git) GetOriginHEADForRepo(ctx context.Context, gitRepo *GitRepo) (strin
|
||||
|
||||
headRef := ""
|
||||
for _, ref := range refs {
|
||||
if !ref.Name().IsBranch() {
|
||||
headRef = ref.Target().Short()
|
||||
//g.logger.Debug(ref.String())
|
||||
if ref.Name().IsBranch() && strings.Contains(ref.String(), "/heads/") {
|
||||
headRef = ref.Name().Short()
|
||||
}
|
||||
}
|
||||
|
||||
if headRef == "" {
|
||||
return "", errors.New("no upstream HEAD branch could be found")
|
||||
}
|
||||
|
||||
return headRef, nil
|
||||
}
|
||||
|
||||
@ -140,11 +147,11 @@ func (g *Git) Clone(ctx context.Context, storageArea *storage.Area, repoUrl stri
|
||||
}
|
||||
|
||||
cloneOptions := git.CloneOptions{
|
||||
URL: repoUrl,
|
||||
Auth: auth,
|
||||
RemoteName: "origin",
|
||||
ReferenceName: "refs/heads/main",
|
||||
SingleBranch: true,
|
||||
URL: repoUrl,
|
||||
Auth: auth,
|
||||
RemoteName: "origin",
|
||||
// ReferenceName: "refs/heads/main",
|
||||
SingleBranch: false,
|
||||
NoCheckout: false,
|
||||
Depth: 1,
|
||||
RecurseSubmodules: 1,
|
||||
@ -292,7 +299,6 @@ func (g *Git) Push(ctx context.Context, gitRepo *GitRepo) error {
|
||||
CABundle: []byte{},
|
||||
RequireRemoteRefs: []config.RefSpec{},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -2,4 +2,6 @@
|
||||
|
||||
set -e
|
||||
|
||||
export $(cat .env | xargs)
|
||||
|
||||
go run cmd/server/server.go start
|
||||
|
Loading…
Reference in New Issue
Block a user