.
This commit is contained in:
parent
e3f57bba01
commit
3fb4bf5d54
@ -628,7 +628,7 @@ func (e *GitHandler) GitSubmoduleCommitId(cwd, packageName, commitId string) (su
|
|||||||
data_out.ch <- '\x00'
|
data_out.ch <- '\x00'
|
||||||
c, err := parseGitCommit(data_in.ch)
|
c, err := parseGitCommit(data_in.ch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic("Error parsing git commit: %v\n", err)
|
log.Panicf("Error parsing git commit: %v\n", err)
|
||||||
}
|
}
|
||||||
data_out.Write([]byte(c.Tree))
|
data_out.Write([]byte(c.Tree))
|
||||||
data_out.ch <- '\x00'
|
data_out.ch <- '\x00'
|
||||||
|
@ -22,14 +22,14 @@ func TestLogging(t *testing.T) {
|
|||||||
stdLogger.Printf("OKA %d Done\n", 77)
|
stdLogger.Printf("OKA %d Done\n", 77)
|
||||||
stdLogger.Println("Another line")
|
stdLogger.Println("Another line")
|
||||||
|
|
||||||
const prefixMatch = `\[\d+\]: `
|
const prefixMatch = `\[\d+\] `
|
||||||
|
|
||||||
err := errWriter.String()
|
errStr := errWriter.String()
|
||||||
if ok, err := regexp.MatchString("^"+prefixMatch+"100\n$", err); !ok {
|
if ok, err := regexp.MatchString("^"+prefixMatch+"100\n$", errStr); !ok {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Logf("err: %v", err)
|
t.Logf("err: %v", err)
|
||||||
}
|
}
|
||||||
t.Fatal(err)
|
t.Fatal(errStr)
|
||||||
}
|
}
|
||||||
str := strWriter.String()
|
str := strWriter.String()
|
||||||
if ok, err := regexp.MatchString("^"+prefixMatch+"OKA 77 Done\n"+prefixMatch+"Another line\n$", str); !ok {
|
if ok, err := regexp.MatchString("^"+prefixMatch+"OKA 77 Done\n"+prefixMatch+"Another line\n$", str); !ok {
|
||||||
@ -40,4 +40,3 @@ func TestLogging(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,10 @@ func (h *RequestHandler) parsePullRequest(data io.Reader) (action *PullRequestWe
|
|||||||
return nil, fmt.Errorf("Got error while parsing json: %w", err)
|
return nil, fmt.Errorf("Got error while parsing json: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
h.Request.Data = action
|
h.Request = &Request {
|
||||||
|
Data: action,
|
||||||
|
Type: RequestType_PR,
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ func TestPrParsing(t *testing.T) {
|
|||||||
t.Fatalf("error parsing PR: %v\n", err)
|
t.Fatalf("error parsing PR: %v\n", err)
|
||||||
}
|
}
|
||||||
if pr == nil {
|
if pr == nil {
|
||||||
t.Fatalf("parsing PR failed without error?: %v")
|
t.Fatal("parsing PR failed without error?")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = h.parsePullRequest(strings.NewReader(samplePRsync_JSON))
|
_, err = h.parsePullRequest(strings.NewReader(samplePRsync_JSON))
|
||||||
|
@ -40,7 +40,10 @@ func (h *RequestHandler) parsePushRequest(data io.Reader) (*PushWebhookEvent, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
h.StdLogger.Printf("Request push for repo: %s\n", action.Repository.Full_Name)
|
h.StdLogger.Printf("Request push for repo: %s\n", action.Repository.Full_Name)
|
||||||
h.Request.Data = action
|
h.Request = &Request {
|
||||||
|
Type: RequestType_Push,
|
||||||
|
Data: action,
|
||||||
|
}
|
||||||
if len(action.Commits) < 1 || len(action.Head_Commit.Id) != 64 {
|
if len(action.Commits) < 1 || len(action.Head_Commit.Id) != 64 {
|
||||||
return nil, fmt.Errorf("Request has no action .... skipping")
|
return nil, fmt.Errorf("Request has no action .... skipping")
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@ -9,6 +10,7 @@ func TestPushRequestParsing(t *testing.T) {
|
|||||||
t.Run("parsing repo creation message", func(t *testing.T) {
|
t.Run("parsing repo creation message", func(t *testing.T) {
|
||||||
var h RequestHandler
|
var h RequestHandler
|
||||||
|
|
||||||
|
h.StdLogger, h.ErrLogger = CreateStdoutLogger(os.Stdout, os.Stderr)
|
||||||
json, err := h.parsePushRequest(strings.NewReader(examplePushJSON))
|
json, err := h.parsePushRequest(strings.NewReader(examplePushJSON))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to parser push request: %v", err)
|
t.Fatalf("failed to parser push request: %v", err)
|
||||||
|
@ -54,7 +54,7 @@ func (h *RequestHandler) parseRepositoryRequest(dataReader io.Reader) (data *Rep
|
|||||||
|
|
||||||
repoIdx := strings.LastIndex(data.Repository.Ssh_Url, "/")
|
repoIdx := strings.LastIndex(data.Repository.Ssh_Url, "/")
|
||||||
if repoIdx == -1 || data.Repository.Ssh_Url[repoIdx+1:] != data.Repository.Name+".git" {
|
if repoIdx == -1 || data.Repository.Ssh_Url[repoIdx+1:] != data.Repository.Name+".git" {
|
||||||
return nil, fmt.Errorf("Unexpected URL for SSH repository: %w", data.Repository.Name)
|
return nil, fmt.Errorf("Unexpected URL for SSH repository: %s", data.Repository.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
data.PrjGit = data.Repository.Ssh_Url[:repoIdx+1] + DefaultGitPrj + ".git"
|
data.PrjGit = data.Repository.Ssh_Url[:repoIdx+1] + DefaultGitPrj + ".git"
|
||||||
|
@ -18,6 +18,7 @@ type ConfigRepos struct {
|
|||||||
prjgit string
|
prjgit string
|
||||||
branch string // "" == default branch
|
branch string // "" == default branch
|
||||||
}
|
}
|
||||||
|
|
||||||
var configuredRepos map[string]ConfigRepos
|
var configuredRepos map[string]ConfigRepos
|
||||||
|
|
||||||
func processRepositoryAction(h *common.RequestHandler) error {
|
func processRepositoryAction(h *common.RequestHandler) error {
|
||||||
@ -81,21 +82,21 @@ func processPushAction(h *common.RequestHandler) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func verifyProjectState(org string, config ConfigRepos) error {
|
func verifyProjectState(org string, config ConfigRepos) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var checkOnStart bool
|
var checkOnStart bool
|
||||||
var checkInterval time.Duration
|
var checkInterval time.Duration
|
||||||
|
|
||||||
func consistencyCheckProcess(repos map[string]ConfigRepos) {
|
func consistencyCheckProcess(repos map[string]ConfigRepos) {
|
||||||
if checkOnStart {
|
if checkOnStart {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for org, conf := range repos {
|
for org, conf := range repos {
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
verifyProjectState(org, conf)
|
verifyProjectState(org, conf)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
@ -140,7 +141,7 @@ func main() {
|
|||||||
for _, c := range configs {
|
for _, c := range configs {
|
||||||
if slices.Contains(c.Workflows, "push") {
|
if slices.Contains(c.Workflows, "push") {
|
||||||
if debugMode {
|
if debugMode {
|
||||||
log.Printf(" + adding org: '%s', branch: '%s', prjgit: '%s'\n", c.Organization, c.Branch, c.GitProjectName)
|
log.Printf(" + adding org: '%s', branch: '%s', prjgit: '%s'\n", c.Organization, c.Branch, c.GitProjectName)
|
||||||
}
|
}
|
||||||
configuredRepos[c.Organization] = ConfigRepos{
|
configuredRepos[c.Organization] = ConfigRepos{
|
||||||
prjgit: c.GitProjectName,
|
prjgit: c.GitProjectName,
|
||||||
|
Loading…
Reference in New Issue
Block a user