Fixed git clone error messages
This commit is contained in:
+4
-23
@@ -42,7 +42,6 @@ import (
|
||||
"github.com/go-git/go-billy/v5/memfs"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/go-git/go-git/v5/config"
|
||||
"github.com/go-git/go-git/v5/storage/memory"
|
||||
|
||||
// Random
|
||||
@@ -6369,6 +6368,10 @@ func runInit(ctx context.Context) {
|
||||
Password: password,
|
||||
}
|
||||
}
|
||||
branch := os.Getenv("SHUFFLE_DOWNLOAD_AUTH_BRANCH")
|
||||
if len(branch) > 0 {
|
||||
cloneOptions.ReferenceName = plumbing.ReferenceName(branch)
|
||||
}
|
||||
|
||||
log.Printf("Getting apps from %s", url)
|
||||
|
||||
@@ -6378,28 +6381,6 @@ func runInit(ctx context.Context) {
|
||||
log.Printf("Failed loading repo into memory: %s", err)
|
||||
}
|
||||
|
||||
branch := os.Getenv("SHUFFLE_DOWNLOAD_AUTH_BRANCH")
|
||||
if len(branch) > 0 {
|
||||
log.Printf("Checkout to branch: %s", branch)
|
||||
|
||||
w, _ := r.Worktree()
|
||||
|
||||
err := r.Fetch(&git.FetchOptions{
|
||||
RefSpecs: []config.RefSpec{"refs/*:refs/*", "HEAD:refs/heads/HEAD"},
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Failed fetch for git repo: %s", err)
|
||||
}
|
||||
|
||||
err = w.Checkout(&git.CheckoutOptions{
|
||||
Branch: plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", branch)),
|
||||
Force: true,
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Failed checkout for git repo: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
dir, err := fs.ReadDir("")
|
||||
if err != nil {
|
||||
log.Printf("Failed reading folder: %s", err)
|
||||
|
||||
@@ -28,8 +28,8 @@ import (
|
||||
"github.com/go-git/go-billy/v5"
|
||||
"github.com/go-git/go-billy/v5/memfs"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/go-git/go-git/v5/config"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/go-git/go-git/v5/storage/memory"
|
||||
http2 "gopkg.in/src-d/go-git.v4/plumbing/transport/http"
|
||||
//"github.com/gorilla/websocket"
|
||||
@@ -4168,6 +4168,7 @@ func deployWebhookFunction(ctx context.Context, name, localization, applocation
|
||||
func loadGithubWorkflows(url, username, password, userId, branch string) error {
|
||||
fs := memfs.New()
|
||||
|
||||
// FIXME: add more git options lol
|
||||
if strings.Contains(url, "github") || strings.Contains(url, "gitlab") || strings.Contains(url, "bitbucket") {
|
||||
cloneOptions := &git.CloneOptions{
|
||||
URL: url,
|
||||
@@ -4192,20 +4193,21 @@ func loadGithubWorkflows(url, username, password, userId, branch string) error {
|
||||
log.Printf("Checkout to branch: %s", branch)
|
||||
|
||||
w, _ := r.Worktree()
|
||||
|
||||
|
||||
err := r.Fetch(&git.FetchOptions{
|
||||
RefSpecs: []config.RefSpec{"refs/*:refs/*", "HEAD:refs/heads/HEAD"},
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Failed fetch for git repo: %s", err)
|
||||
}
|
||||
|
||||
|
||||
err = w.Checkout(&git.CheckoutOptions{
|
||||
Branch: plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", branch)),
|
||||
Force: true,
|
||||
Force: true,
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Failed checkout for git repo: %s", err)
|
||||
return errors.New(fmt.Sprintf("Failed checking out to branch %s - does it exist?", branch))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4286,7 +4288,7 @@ func loadSpecificWorkflows(resp http.ResponseWriter, request *http.Request) {
|
||||
if err != nil {
|
||||
log.Printf("Error with unmarshal tmpBody: %s", err)
|
||||
resp.WriteHeader(401)
|
||||
resp.Write([]byte(`{"success": false}`))
|
||||
resp.Write([]byte(`{"success": false, "reason": "json decode error"}`))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -4295,7 +4297,7 @@ func loadSpecificWorkflows(resp http.ResponseWriter, request *http.Request) {
|
||||
if err != nil {
|
||||
log.Printf("Failed to update workflows: %s", err)
|
||||
resp.WriteHeader(401)
|
||||
resp.Write([]byte(`{"success": false}`))
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "%s"}`, err)))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5046,7 +5048,7 @@ func getWorkflowExecutions(resp http.ResponseWriter, request *http.Request) {
|
||||
|
||||
if len(workflowExecutions) == 0 {
|
||||
resp.Write([]byte("[]"))
|
||||
resp.WriteHeader(200)
|
||||
//resp.WriteHeader(200)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user