feature/docker-action #11

Merged
kjuulh merged 11 commits from feature/docker-action into v0.1 2022-09-18 11:51:23 +02:00
3 changed files with 19 additions and 10 deletions
Showing only changes of commit 64e9f8dca8 - Show all commits

1
.gitignore vendored
View File

@ -1 +1,2 @@
.cuddle/ .cuddle/
.env

View File

@ -2,7 +2,9 @@ package providers
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"strings"
"time" "time"
"git.front.kjuulh.io/kjuulh/kraken/internal/services/signer" "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) { func (g *Git) GetOriginHEADForRepo(ctx context.Context, gitRepo *GitRepo) (string, error) {
remote, err := gitRepo.repo.Remote("origin") auth, err := g.GetAuth()
if err != nil { if err != nil {
return "", err return "", err
} }
auth, err := g.GetAuth() remote, err := gitRepo.repo.Remote("origin")
if err != nil { if err != nil {
return "", err return "", err
} }
@ -82,11 +84,16 @@ func (g *Git) GetOriginHEADForRepo(ctx context.Context, gitRepo *GitRepo) (strin
headRef := "" headRef := ""
for _, ref := range refs { for _, ref := range refs {
if !ref.Name().IsBranch() { //g.logger.Debug(ref.String())
headRef = ref.Target().Short() 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 return headRef, nil
} }
@ -140,11 +147,11 @@ 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: true, SingleBranch: false,
NoCheckout: false, NoCheckout: false,
Depth: 1, Depth: 1,
RecurseSubmodules: 1, RecurseSubmodules: 1,
@ -292,7 +299,6 @@ func (g *Git) Push(ctx context.Context, gitRepo *GitRepo) error {
CABundle: []byte{}, CABundle: []byte{},
RequireRemoteRefs: []config.RefSpec{}, RequireRemoteRefs: []config.RefSpec{},
}) })
if err != nil { if err != nil {
return err return err
} }

View File

@ -2,4 +2,6 @@
set -e set -e
export $(cat .env | xargs)
go run cmd/server/server.go start go run cmd/server/server.go start