Without cibus
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"go.uber.org/zap"
|
||||
@@ -23,7 +24,11 @@ func NewGitea(logger *zap.Logger) *Gitea {
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Gitea) ListRepositoriesForOrganization(ctx context.Context, server string, organization string) ([]string, error) {
|
||||
func (g *Gitea) ListRepositoriesForOrganization(
|
||||
ctx context.Context,
|
||||
server string,
|
||||
organization string,
|
||||
) ([]string, error) {
|
||||
client, err := g.getOrCreateClient(ctx, server)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -52,6 +57,35 @@ func (g *Gitea) ListRepositoriesForOrganization(ctx context.Context, server stri
|
||||
return repoUrls, err
|
||||
}
|
||||
|
||||
func (g *Gitea) CreatePr(
|
||||
ctx context.Context,
|
||||
server string,
|
||||
organization string,
|
||||
repository string,
|
||||
head string,
|
||||
base string,
|
||||
actionName string,
|
||||
) error {
|
||||
client, err := g.getOrCreateClient(ctx, server)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client.CreatePullRequest(organization, repository, gitea.CreatePullRequestOption{
|
||||
Head: head,
|
||||
Base: base,
|
||||
Title: actionName,
|
||||
Body: "",
|
||||
Assignee: "",
|
||||
Assignees: []string{},
|
||||
Milestone: 0,
|
||||
Labels: []int64{},
|
||||
Deadline: &time.Time{},
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *Gitea) getOrCreateClient(ctx context.Context, server string) (*gitea.Client, error) {
|
||||
g.giteamu.Lock()
|
||||
defer g.giteamu.Unlock()
|
||||
|
Reference in New Issue
Block a user