Browse Source

Merge branch 'zouap' of https://git.openi.org.cn/OpenI/aiforge into zouap

tags/v1.21.12.1^2
zhoupzh 4 years ago
parent
commit
df3d60a787
4 changed files with 27 additions and 16 deletions
  1. +0
    -3
      routers/private/hook.go
  2. +5
    -0
      routers/repo/ai_model_manage.go
  3. +16
    -10
      routers/repo/view.go
  4. +6
    -3
      templates/repo/view_list.tmpl

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

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


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


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

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




+ 5
- 0
routers/repo/ai_model_manage.go View File

@@ -391,6 +391,11 @@ func ShowOneVersionOtherModel(ctx *context.Context) {
repoId := ctx.Repo.Repository.ID repoId := ctx.Repo.Repository.ID
name := ctx.Query("name") name := ctx.Query("name")
aimodels := models.QueryModelByName(name, repoId) aimodels := models.QueryModelByName(name, repoId)
for _, model := range aimodels {
log.Info("model=" + model.Name)
log.Info("model.UserId=" + fmt.Sprint(model.UserId))
model.IsCanOper = isOper(ctx, model.UserId)
}
if len(aimodels) > 0 { if len(aimodels) > 0 {
ctx.JSON(200, aimodels[1:]) ctx.JSON(200, aimodels[1:])
} else { } else {


+ 16
- 10
routers/repo/view.go View File

@@ -7,8 +7,8 @@ package repo


import ( import (
"bytes" "bytes"
"code.gitea.io/gitea/modules/options"
"encoding/base64" "encoding/base64"
"encoding/json"
"fmt" "fmt"
gotemplate "html/template" gotemplate "html/template"
"io/ioutil" "io/ioutil"
@@ -29,6 +29,7 @@ import (
"code.gitea.io/gitea/modules/lfs" "code.gitea.io/gitea/modules/lfs"
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/options"
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
) )


@@ -343,6 +344,11 @@ func renderDirectory(ctx *context.Context, treeLink string) {
// Show latest commit info of repository in table header, // Show latest commit info of repository in table header,
// or of directory if not in root directory. // or of directory if not in root directory.
ctx.Data["LatestCommit"] = latestCommit ctx.Data["LatestCommit"] = latestCommit

latestCommitJson, _ := json.Marshal(latestCommit)
//log.Info(accuracyJson=” + string(accuracyJson))
log.Info("latestCommitJson=" + string(latestCommitJson))

verification := models.ParseCommitWithSignature(latestCommit) verification := models.ParseCommitWithSignature(latestCommit)


if err := models.CalculateTrustStatus(verification, ctx.Repo.Repository, nil); err != nil { if err := models.CalculateTrustStatus(verification, ctx.Repo.Repository, nil); err != nil {
@@ -578,11 +584,11 @@ func safeURL(address string) string {
} }


type ContributorInfo struct { type ContributorInfo struct {
UserInfo *models.User // nil for contributor who is not a registered user
RelAvatarLink string `json:"rel_avatar_link"`
UserName string `json:"user_name"`
Email string `json:"email"`
CommitCnt int `json:"commit_cnt"`
UserInfo *models.User // nil for contributor who is not a registered user
RelAvatarLink string `json:"rel_avatar_link"`
UserName string `json:"user_name"`
Email string `json:"email"`
CommitCnt int `json:"commit_cnt"`
} }


type GetContributorsInfo struct { type GetContributorsInfo struct {
@@ -641,7 +647,7 @@ func Home(ctx *context.Context) {
existedContributorInfo.CommitCnt += c.CommitCnt existedContributorInfo.CommitCnt += c.CommitCnt
} else { } else {
var newContributor = &ContributorInfo{ var newContributor = &ContributorInfo{
user, "", "",c.Email, c.CommitCnt,
user, "", "", c.Email, c.CommitCnt,
} }
count++ count++
contributorInfos = append(contributorInfos, newContributor) contributorInfos = append(contributorInfos, newContributor)
@@ -838,7 +844,7 @@ func renderCode(ctx *context.Context) {
compareInfo, err = baseGitRepo.GetCompareInfo(ctx.Repo.Repository.RepoPath(), ctx.Repo.BranchName, ctx.Repo.Repository.BaseRepo.DefaultBranch) compareInfo, err = baseGitRepo.GetCompareInfo(ctx.Repo.Repository.RepoPath(), ctx.Repo.BranchName, ctx.Repo.Repository.BaseRepo.DefaultBranch)
ctx.Data["UpstreamSameBranchName"] = false ctx.Data["UpstreamSameBranchName"] = false
} }
if err==nil && compareInfo != nil {
if err == nil && compareInfo != nil {
if compareInfo.Commits != nil { if compareInfo.Commits != nil {
log.Info("compareInfoCommits数量:%d", compareInfo.Commits.Len()) log.Info("compareInfoCommits数量:%d", compareInfo.Commits.Len())
ctx.Data["FetchUpstreamCnt"] = compareInfo.Commits.Len() ctx.Data["FetchUpstreamCnt"] = compareInfo.Commits.Len()
@@ -942,7 +948,7 @@ func ContributorsAPI(ctx *context.Context) {
} else { } else {
// new committer info // new committer info
var newContributor = &ContributorInfo{ var newContributor = &ContributorInfo{
user, user.RelAvatarLink(),user.Name, user.Email,c.CommitCnt,
user, user.RelAvatarLink(), user.Name, user.Email, c.CommitCnt,
} }
count++ count++
contributorInfos = append(contributorInfos, newContributor) contributorInfos = append(contributorInfos, newContributor)
@@ -955,7 +961,7 @@ func ContributorsAPI(ctx *context.Context) {
existedContributorInfo.CommitCnt += c.CommitCnt existedContributorInfo.CommitCnt += c.CommitCnt
} else { } else {
var newContributor = &ContributorInfo{ var newContributor = &ContributorInfo{
user, "", "",c.Email,c.CommitCnt,
user, "", "", c.Email, c.CommitCnt,
} }
count++ count++
contributorInfos = append(contributorInfos, newContributor) contributorInfos = append(contributorInfos, newContributor)


+ 6
- 3
templates/repo/view_list.tmpl View File

@@ -5,14 +5,17 @@
{{if .LatestCommitUser}} {{if .LatestCommitUser}}
<img class="ui avatar image img-12" src="{{.LatestCommitUser.RelAvatarLink}}" /> <img class="ui avatar image img-12" src="{{.LatestCommitUser.RelAvatarLink}}" />
{{if .LatestCommitUser.FullName}} {{if .LatestCommitUser.FullName}}
<a href="{{AppSubUrl}}/{{.LatestCommitUser.Name}}"><strong>{{.LatestCommitUser.FullName}}</strong></a>
<a id="1" href="{{AppSubUrl}}/{{.LatestCommitUser.Name}}"><strong>{{.LatestCommitUser.FullName}}</strong></a>
<strong id="6">{{.LatestCommit.Committer.Name}}</strong>
{{else}} {{else}}
<a href="{{AppSubUrl}}/{{.LatestCommitUser.Name}}"><strong>{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}</strong></a>
<a id="2" href="{{AppSubUrl}}/{{.LatestCommitUser.Name}}"><strong>{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}</strong></a>
<strong id="6">{{.LatestCommit.Committer.Name}}</strong>
{{end}} {{end}}
{{else}} {{else}}
{{if .LatestCommit.Author}} {{if .LatestCommit.Author}}
<img class="ui avatar image img-12" src="{{AvatarLink .LatestCommit.Author.Email}}" /> <img class="ui avatar image img-12" src="{{AvatarLink .LatestCommit.Author.Email}}" />
<strong>{{.LatestCommit.Author.Name}}</strong>
<strong id="3">{{.LatestCommit.Author.Name}}</strong>
<strong id="4">{{.LatestCommit.Committer.Name}}</strong>
{{end}} {{end}}
{{end}} {{end}}
<a rel="nofollow" class="ui sha label {{if .LatestCommit.Signature}} isSigned {{if .LatestCommitVerification.Verified }} isVerified{{if eq .LatestCommitVerification.TrustStatus "trusted"}}{{else if eq .LatestCommitVerification.TrustStatus "untrusted"}}Untrusted{{else}}Unmatched{{end}}{{else if .LatestCommitVerification.Warning}} isWarning{{end}}{{end}}" href="{{.RepoLink}}/commit/{{.LatestCommit.ID}}"> <a rel="nofollow" class="ui sha label {{if .LatestCommit.Signature}} isSigned {{if .LatestCommitVerification.Verified }} isVerified{{if eq .LatestCommitVerification.TrustStatus "trusted"}}{{else if eq .LatestCommitVerification.TrustStatus "untrusted"}}Untrusted{{else}}Unmatched{{end}}{{else if .LatestCommitVerification.Warning}} isWarning{{end}}{{end}}" href="{{.RepoLink}}/commit/{{.LatestCommit.ID}}">


Loading…
Cancel
Save