diff --git a/routers/hat/hat.go b/routers/hat/hat.go index 3e871f8..1ff0d48 100644 --- a/routers/hat/hat.go +++ b/routers/hat/hat.go @@ -102,6 +102,7 @@ func Routers(ctx gocontext.Context) *web.Route { m.Get("/files", context.RepoRef(), repo.GetPullFiles) m.Group("/versions", func() { m.Get("", repo.ListPullRequestVersions) + m.Get("/{versionId}/diff", context.RepoRef(), repo.GetPullRequestVersionDiff) }) }) }, mustAllowPulls, reqRepoReader(unit_model.TypeCode), context.ReferencesGitRepo()) diff --git a/routers/hat/repo/pull_version.go b/routers/hat/repo/pull_version.go index d4eaea9..0527273 100644 --- a/routers/hat/repo/pull_version.go +++ b/routers/hat/repo/pull_version.go @@ -18,7 +18,7 @@ import ( ) func ListPullRequestVersions(ctx *context.APIContext) { - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.RepoID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound() @@ -89,7 +89,7 @@ func GetPullRequestVersionDiff(ctx *context.APIContext) { if filepath == "" { ctx.JSON(http.StatusOK, diffs) } else { - var targetDiffFile *hat_gitdiff.DiffFile + targetDiffFile := &hat_gitdiff.DiffFile{} for _, file := range diffs.Files { if file.Name == filepath { if diffString, err := hat_git.GetDiffStringByFilePath(ctx.Repo.GitRepo, prv.BaseCommitID, prv.HeadCommitID, file.Name); err == nil { @@ -117,9 +117,6 @@ func GetPullRequestVersionDiff(ctx *context.APIContext) { } targetDiffFile.Diff = strings.Join(afterStrings, "\n") } - targetDiffFile = &hat_gitdiff.DiffFile{ - DiffFile: *file, - } break } }