From 73ddd9e7bf7c6c7793b170f0998a5b0c503a5797 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 8 Dec 2022 09:58:57 +0800 Subject: [PATCH] #3169 repo-square:change setting name --- modules/setting/setting.go | 6 +++--- services/repository/square.go | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index b6a4cb540..b7da8e871 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -667,8 +667,8 @@ var ( CloudbrainStoppedRemark string //repo square config - IncubationSourceOrgId int64 - PaperRepoTopicName string + IncubationSourceOrgName string + PaperRepoTopicName string //nginx proxy PROXYURL string @@ -1579,7 +1579,7 @@ func NewContext() { CloudbrainStoppedRemark = sec.Key("CLOUDBRAIN_STOPPED_REMARK").MustString("感谢您的耐心等待。") sec = Cfg.Section("repo-square") - IncubationSourceOrgId = sec.Key("INCUBATION_ORG_ID").MustInt64(9) + IncubationSourceOrgName = sec.Key("INCUBATION_ORG_NAME").MustString("OpenI") PaperRepoTopicName = sec.Key("PAPER_REPO_TOPIC_NAME").MustString("openi-paper") sec = Cfg.Section("point") diff --git a/services/repository/square.go b/services/repository/square.go index 0fc7e6e06..d68e5b189 100644 --- a/services/repository/square.go +++ b/services/repository/square.go @@ -115,12 +115,19 @@ func GetPreferredRepos() ([]*models.Repository4Card, error) { } func GetIncubationRepos() ([]*models.Repository4Card, error) { + org, err := models.GetOrgByName(setting.IncubationSourceOrgName) + if models.IsErrOrgNotExist(err) { + return make([]*models.Repository4Card, 0), nil + } + if err != nil { + return nil, err + } repos, err := models.GetSelectedRepos(models.FindSelectedReposOpts{ ListOptions: models.ListOptions{ PageSize: 10, Page: 1, }, - OrgId: setting.IncubationSourceOrgId, + OrgId: org.ID, OnlyPublic: true, }) if err != nil {