Re-fixed workflow imports with master branch

This commit is contained in:
frikky
2020-10-26 11:22:15 +01:00
parent 63e5d82637
commit ca798de0cd
2 changed files with 8 additions and 5 deletions
+2 -2
View File
@@ -6710,7 +6710,7 @@ func runInit(ctx context.Context) {
} }
} }
branch := os.Getenv("SHUFFLE_DOWNLOAD_AUTH_BRANCH") branch := os.Getenv("SHUFFLE_DOWNLOAD_AUTH_BRANCH")
if len(branch) > 0 { if len(branch) > 0 && branch != "master" && branch != "main" {
cloneOptions.ReferenceName = plumbing.ReferenceName(branch) cloneOptions.ReferenceName = plumbing.ReferenceName(branch)
} }
@@ -6719,7 +6719,7 @@ func runInit(ctx context.Context) {
r, err := git.Clone(storer, fs, cloneOptions) r, err := git.Clone(storer, fs, cloneOptions)
if err != nil { 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("") dir, err := fs.ReadDir("")
+6 -3
View File
@@ -1713,6 +1713,7 @@ func saveWorkflow(resp http.ResponseWriter, request *http.Request) {
} }
if len(workflow.ExecutingOrg.Id) == 0 { if len(workflow.ExecutingOrg.Id) == 0 {
log.Printf("setting executing org")
workflow.ExecutingOrg = user.ActiveOrg 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 { func loadGithubWorkflows(url, username, password, userId, branch string) error {
fs := memfs.New() 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") { if strings.Contains(url, "github") || strings.Contains(url, "gitlab") || strings.Contains(url, "bitbucket") {
cloneOptions := &git.CloneOptions{ cloneOptions := &git.CloneOptions{
URL: url, 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) cloneOptions.ReferenceName = plumbing.ReferenceName(branch)
} }
storer := memory.NewStorage() storer := memory.NewStorage()
r, err := git.Clone(storer, fs, cloneOptions) r, err := git.Clone(storer, fs, cloneOptions)
if err != nil { 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 return err
} }
@@ -4772,7 +4775,7 @@ func loadSpecificApps(resp http.ResponseWriter, request *http.Request) {
storer := memory.NewStorage() storer := memory.NewStorage()
r, err := git.Clone(storer, fs, cloneOptions) r, err := git.Clone(storer, fs, cloneOptions)
if err != nil { 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.WriteHeader(401)
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "%s"}`, err))) resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "%s"}`, err)))
return return