From 2dace145f763e2722a2a261fc52ca2ff8fb185be Mon Sep 17 00:00:00 2001 From: hang Date: Wed, 29 Dec 2021 09:55:52 +0800 Subject: [PATCH] add:branch for the commit page --- modules/convert/git_commit.go | 2 ++ modules/structs/repo_commit.go | 1 + routers/api/v1/repo/pull.go | 2 -- templates/swagger/v1_json.tmpl | 4 ++++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/convert/git_commit.go b/modules/convert/git_commit.go index d849929ad..efb73813b 100644 --- a/modules/convert/git_commit.go +++ b/modules/convert/git_commit.go @@ -144,6 +144,7 @@ func ToCommit(repo *models.Repository, commit *git.Commit, userCache map[string] }) } } + commit.LoadBranchName() return &api.Commit{ CommitDate: commit.Committer.When.Format("2006-01-02"), // new time format, year-moon-day @@ -178,5 +179,6 @@ func ToCommit(repo *models.Repository, commit *git.Commit, userCache map[string] Committer: apiCommitter, Parents: apiParents, Files: affectedFileList, + Branch: commit.Branch, }, nil } diff --git a/modules/structs/repo_commit.go b/modules/structs/repo_commit.go index 04311955b..1168d3c27 100644 --- a/modules/structs/repo_commit.go +++ b/modules/structs/repo_commit.go @@ -49,6 +49,7 @@ type Commit struct { Parents []*CommitMeta `json:"parents"` Files []*CommitAffectedFiles `json:"files"` CommitDate string `json:"commit_date"` + Branch string `json:"branch"` } // CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index b3d664f2d..aa396493a 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -1387,8 +1387,6 @@ func GetPullFiles(ctx *context.APIContext) { pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) issue := pr.Issue - // issue := checkPullInfo(ctx.Context) - log.Info("issue %s", issue) if issue == nil { ctx.NotFound("checkPullInfo", nil) diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 335cd8924..9c81d080c 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -13268,6 +13268,10 @@ "author": { "$ref": "#/definitions/User" }, + "branch": { + "type": "string", + "x-go-name": "Branch" + }, "commit": { "$ref": "#/definitions/RepoCommit" },