From ab3a701a42f0cbe810f9ea9a7752d63d4be7faed Mon Sep 17 00:00:00 2001 From: sulenn <273409891@qq.com> Date: Fri, 6 Nov 2020 21:23:25 +0800 Subject: [PATCH] fix: fix error LatestSha field for compare API --- routers/api/v1/repo/repo.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index ae9378ac9..0d129e278 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -895,9 +895,12 @@ func CompareDiff(ctx *context.APIContext) { Diff interface{} LatestSha string }{ - Commits: result, - Diff: ctx.Context.Data["Diff"], - LatestSha: headBranch, + Commits: result, + Diff: ctx.Context.Data["Diff"], + } + + if len(different.Commits) != 0 { + different.LatestSha = different.Commits[0].Sha } ctx.JSON(200, different)