Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.21.12.1^2
zouap 4 years ago
parent
commit
1248a3012c
4 changed files with 48 additions and 1 deletions
  1. +7
    -1
      modules/setting/setting.go
  2. +35
    -0
      routers/home.go
  3. +4
    -0
      routers/private/hook.go
  4. +2
    -0
      routers/routes/routes.go

+ 7
- 1
modules/setting/setting.go View File

@@ -433,6 +433,9 @@ var (
AuthUser string
AuthPassword string

//home page
RecommentRepoAddr string

//labelsystem config
LabelTaskName string
LabelDatasetDeleteQueue string
@@ -549,7 +552,7 @@ var (
RecordBeginTime string
IgnoreMirrorRepo bool
}{}
Warn_Notify_Mails []string
)

@@ -1224,6 +1227,9 @@ func NewContext() {
LabelDatasetDeleteQueue = sec.Key("LabelDatasetDeleteQueue").MustString("LabelDatasetDeleteQueue")
DecompressOBSTaskName = sec.Key("DecompressOBSTaskName").MustString("LabelDecompressOBSQueue")

sec = Cfg.Section("homepage")
RecommentRepoAddr = sec.Key("Address").MustString("https://git.openi.org.cn/OpenIOSSG/promote/raw/branch/master/")

sec = Cfg.Section("cloudbrain")
CBAuthUser = sec.Key("USER").MustString("cW4cMtH24eoWPE7X")
CBAuthPassword = sec.Key("PWD").MustString("4BPmgvK2hb2Eywwyp4YZRY4B7yQf4DAC")


+ 35
- 0
routers/home.go View File

@@ -7,6 +7,8 @@ package routers

import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"strings"

@@ -511,3 +513,36 @@ func NotFound(ctx *context.Context) {
ctx.Data["Title"] = "Page Not Found"
ctx.NotFound("home.NotFound", nil)
}

func RecommendOrgFromPromote(ctx *context.Context) {
url := setting.RecommentRepoAddr + "organizations"
recommendFromPromote(ctx, url)
}

func recommendFromPromote(ctx *context.Context, url string) {
resp, err := http.Get(url)
if err != nil {
log.Info("Get organizations url error=" + err.Error())
ctx.ServerError("QueryTrainJobList:", err)
return
}
bytes, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
log.Info("Get organizations url error=" + err.Error())
ctx.ServerError("QueryTrainJobList:", err)
return
}

allLineStr := string(bytes)
lines := strings.Split(allLineStr, "\n")
for i, line := range lines {
log.Info("i=" + fmt.Sprint(i) + " line=" + line)
}
ctx.JSON(http.StatusOK, lines)
}

func RecommendRepoFromPromote(ctx *context.Context) {
url := setting.RecommentRepoAddr + "projects"
recommendFromPromote(ctx, url)
}

+ 4
- 0
routers/private/hook.go View File

@@ -164,6 +164,7 @@ func isErrUnverifiedCommit(err error) bool {

// HookPreReceive checks whether a individual commit is acceptable
func HookPreReceive(ctx *macaron.Context, opts private.HookOptions) {
log.Info("Git pre start..................................")
ownerName := ctx.Params(":owner")
repoName := ctx.Params(":repo")
repo, err := models.GetRepositoryByOwnerAndName(ownerName, repoName)
@@ -370,6 +371,9 @@ func HookPreReceive(ctx *macaron.Context, opts private.HookOptions) {

// HookPostReceive updates services and users
func HookPostReceive(ctx *macaron.Context, opts private.HookOptions) {

log.Info("Git post start..................................")

ownerName := ctx.Params(":owner")
repoName := ctx.Params(":repo")



+ 2
- 0
routers/routes/routes.go View File

@@ -313,6 +313,8 @@ func RegisterRoutes(m *macaron.Macaron) {
})
m.Get("/", routers.Home)
m.Get("/dashboard", routers.Dashboard)
m.Get("/recommend/org", routers.RecommendOrgFromPromote)
m.Get("/recommend/repo", routers.RecommendRepoFromPromote)
m.Group("/explore", func() {
m.Get("", func(ctx *context.Context) {
ctx.Redirect(setting.AppSubURL + "/explore/repos")


Loading…
Cancel
Save