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)