mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
@@ -12,6 +12,8 @@ import (
|
||||
"gopkg.in/src-d/go-git.v4/config"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing/transport"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing/transport/http"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
|
||||
"gopkg.in/src-d/go-git.v4/storage/memory"
|
||||
"io/ioutil"
|
||||
@@ -269,7 +271,7 @@ func SyncSpiderGit(s model.Spider) (err error) {
|
||||
}
|
||||
|
||||
// 生成验证信息
|
||||
var auth ssh.AuthMethod
|
||||
var auth transport.AuthMethod
|
||||
if !strings.HasPrefix(s.GitUrl, "http") {
|
||||
// 为 SSH
|
||||
regex := regexp.MustCompile("^(?:ssh://?)?([0-9a-zA-Z_]+)@")
|
||||
@@ -289,6 +291,11 @@ func SyncSpiderGit(s model.Spider) (err error) {
|
||||
SaveSpiderGitSyncError(s, err.Error())
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// 为 HTTP
|
||||
if s.GitUsername != "" && s.GitPassword != "" {
|
||||
auth = &http.BasicAuth{s.GitUsername, s.GitPassword}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取 repo
|
||||
|
||||
Reference in New Issue
Block a user