[REV] auto Identify the SVN protocol (#85)

This commit is contained in:
barnettZQG 2018-07-23 21:45:13 +08:00
parent d384bd685b
commit 41a955dd16
3 changed files with 11 additions and 7 deletions

View File

@ -117,6 +117,7 @@ func NewSouceCodeBuildItem(in []byte) *SourceCodeBuildItem {
scb.CacheDir = fmt.Sprintf("/cache/build/%s/cache/%s", scb.TenantID, scb.ServiceID)
//scb.SourceDir = scb.CodeSouceInfo.GetCodeSourceDir()
scb.TGZDir = fmt.Sprintf("/grdata/build/tenant/%s/slug/%s", scb.TenantID, scb.ServiceID)
scb.CodeSouceInfo.InitServerType()
return scb
}

View File

@ -88,13 +88,7 @@ func (d *SourceCodeParse) Parse() ParseErrorList {
if csi.Branch == "" {
csi.Branch = "master"
}
if csi.ServerType == "" {
if strings.HasPrefix(csi.RepositoryURL, "svn") {
csi.ServerType = "svn"
} else {
csi.ServerType = "git"
}
}
csi.InitServerType()
if csi.RepositoryURL == "" {
d.logger.Error("Git项目仓库地址不能为空", map[string]string{"step": "parse"})
d.errappend(ErrorAndSolve(FatalError, "Git项目仓库地址格式错误", SolveAdvice("modify_url", "请确认并修改仓库地址")))

View File

@ -65,6 +65,15 @@ type CodeSourceInfo struct {
ServiceID string `json:"service_id"`
}
//InitServerType init server type
func (c *CodeSourceInfo) InitServerType() {
if strings.HasPrefix(c.RepositoryURL, "svn://") || strings.HasSuffix(c.RepositoryURL, ".svn") {
c.ServerType = "svn"
} else {
c.ServerType = "git"
}
}
//GetCodeCacheDir 获取代码缓存目录
func (c CodeSourceInfo) GetCodeCacheDir() string {
cacheDir := os.Getenv("CACHE_DIR")