Without cibus
This commit is contained in:
@@ -3,6 +3,7 @@ package commands
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -11,6 +12,7 @@ import (
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/schema"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/providers"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/storage"
|
||||
giturls "github.com/whilp/git-urls"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -42,8 +44,6 @@ func NewProcessRepos(logger *zap.Logger, deps ProcessReposDeps) *ProcessRepos {
|
||||
}
|
||||
|
||||
func (pr *ProcessRepos) Process(ctx context.Context, repository string, branch string, actionPath string) error {
|
||||
errChan := make(chan error, 1)
|
||||
|
||||
action, err := pr.actionCreator.Prepare(ctx, &actions.ActionCreatorOps{
|
||||
RepositoryUrl: repository,
|
||||
Branch: branch,
|
||||
@@ -68,19 +68,14 @@ func (pr *ProcessRepos) Process(ctx context.Context, repository string, branch s
|
||||
}()
|
||||
err := pr.processRepo(ctx, repoUrl, action)
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
pr.logger.Error("could not process repo", zap.Error(err))
|
||||
}
|
||||
}(ctx, repoUrl)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
close(errChan)
|
||||
pr.logger.Debug("finished processing all repos", zap.Strings("repos", repositoryUrls))
|
||||
|
||||
for err := range errChan {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -122,11 +117,13 @@ func (pr *ProcessRepos) processRepo(ctx context.Context, repoUrl string, action
|
||||
return err
|
||||
}
|
||||
|
||||
err = pr.commit(ctx, area, repo)
|
||||
err = pr.commit(ctx, area, repo, repoUrl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//pr.gitea.CreatePr(ctx, )
|
||||
|
||||
pr.logger.Debug("processing done", zap.String("path", area.Path), zap.String("repoUrl", repoUrl))
|
||||
return nil
|
||||
}
|
||||
@@ -167,7 +164,7 @@ func (pr *ProcessRepos) clone(ctx context.Context, area *storage.Area, repoUrl s
|
||||
return repo, nil
|
||||
}
|
||||
|
||||
func (pr *ProcessRepos) commit(ctx context.Context, area *storage.Area, repo *providers.GitRepo) error {
|
||||
func (pr *ProcessRepos) commit(ctx context.Context, area *storage.Area, repo *providers.GitRepo, repoUrl string) error {
|
||||
_, err := pr.git.Add(ctx, area, repo)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not add file: %w", err)
|
||||
@@ -184,6 +181,21 @@ func (pr *ProcessRepos) commit(ctx context.Context, area *storage.Area, repo *pr
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not push to repo: %w", err)
|
||||
}
|
||||
|
||||
url, err := giturls.Parse(repoUrl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
head, err := repo.GetHEAD()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
path := strings.Split(url.Path, "/")
|
||||
pr.logger.Debug("path string", zap.Strings("paths", path), zap.String("HEAD", head))
|
||||
|
||||
pr.gitea.CreatePr(ctx, url.Host, path[0], repoUrl, head, "", "kraken-apply")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user