From ca798de0cdcb78d77f06241ef5cb3d782cb1e6fc Mon Sep 17 00:00:00 2001 From: frikky Date: Mon, 26 Oct 2020 11:22:15 +0100 Subject: [PATCH] Re-fixed workflow imports with master branch --- backend/go-app/main.go | 4 ++-- backend/go-app/walkoff.go | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 4ef276a6..84b9c10b 100644 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -6710,7 +6710,7 @@ func runInit(ctx context.Context) { } } branch := os.Getenv("SHUFFLE_DOWNLOAD_AUTH_BRANCH") - if len(branch) > 0 { + if len(branch) > 0 && branch != "master" && branch != "main" { cloneOptions.ReferenceName = plumbing.ReferenceName(branch) } @@ -6719,7 +6719,7 @@ func runInit(ctx context.Context) { r, err := git.Clone(storer, fs, cloneOptions) if err != nil { - log.Printf("Failed loading repo into memory: %s", err) + log.Printf("Failed loading repo into memory (init): %s", err) } dir, err := fs.ReadDir("") diff --git a/backend/go-app/walkoff.go b/backend/go-app/walkoff.go index e0eb0eda..0f52aabd 100644 --- a/backend/go-app/walkoff.go +++ b/backend/go-app/walkoff.go @@ -1713,6 +1713,7 @@ func saveWorkflow(resp http.ResponseWriter, request *http.Request) { } if len(workflow.ExecutingOrg.Id) == 0 { + log.Printf("setting executing org") workflow.ExecutingOrg = user.ActiveOrg } @@ -4549,6 +4550,7 @@ func deployWebhookFunction(ctx context.Context, name, localization, applocation func loadGithubWorkflows(url, username, password, userId, branch string) error { fs := memfs.New() + log.Printf("Starting load of %s with branch %s", url, branch) if strings.Contains(url, "github") || strings.Contains(url, "gitlab") || strings.Contains(url, "bitbucket") { cloneOptions := &git.CloneOptions{ URL: url, @@ -4563,14 +4565,15 @@ func loadGithubWorkflows(url, username, password, userId, branch string) error { } } - if len(branch) > 0 { + // main is the new master + if len(branch) > 0 && branch != "main" && branch != "master" { cloneOptions.ReferenceName = plumbing.ReferenceName(branch) } storer := memory.NewStorage() r, err := git.Clone(storer, fs, cloneOptions) if err != nil { - log.Printf("Failed loading repo into memory: %s", err) + log.Printf("Failed loading repo %s into memory (github workflows): %s", url, err) return err } @@ -4772,7 +4775,7 @@ func loadSpecificApps(resp http.ResponseWriter, request *http.Request) { storer := memory.NewStorage() r, err := git.Clone(storer, fs, cloneOptions) if err != nil { - log.Printf("Failed loading repo into memory: %s", err) + log.Printf("Failed loading repo %s into memory (github workflows 2): %s", tmpBody.URL, err) resp.WriteHeader(401) resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "%s"}`, err))) return