From 67002575589c1b77c86ecacd6edb5a05e81015cb Mon Sep 17 00:00:00 2001 From: Chris Lee Date: Sun, 27 Apr 2014 23:43:14 +0000 Subject: [PATCH] Show parents in commit diff page --- routers/repo/commit.go | 12 ++++++++++++ templates/repo/diff.tmpl | 9 ++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/routers/repo/commit.go b/routers/repo/commit.go index 9ecc697d2..d73669923 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -91,10 +91,22 @@ func Diff(ctx *middleware.Context, params martini.Params) { return isImage } + parents := make([]string, commit.ParentCount()) + for i := 0; i < commit.ParentCount(); i++ { + sha, err := commit.ParentId(i) + parents[i] = sha.String() + if err != nil { + ctx.Handle(404, "repo.Diff", err) + } + } + + ctx.Data["Username"] = userName + ctx.Data["Reponame"] = repoName ctx.Data["IsImageFile"] = isImageFile ctx.Data["Title"] = commit.Summary() + " ยท " + base.ShortSha(commitId) ctx.Data["Commit"] = commit ctx.Data["Diff"] = diff + ctx.Data["Parents"] = parents ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 ctx.Data["IsRepoToolbarCommits"] = true ctx.Data["SourcePath"] = "/" + path.Join(userName, repoName, "src", commitId) diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl index 0dce40533..38fe3fee2 100644 --- a/templates/repo/diff.tmpl +++ b/templates/repo/diff.tmpl @@ -8,9 +8,16 @@ Browse Source

{{.Commit.Message}}

+ {{ $username := .Username }} + {{ $reponame := .Reponame }}
- commit {{ShortSha .CommitId}} +
    + {{range .Parents}} +
  • parent {{ShortSha .}}
  • + {{end}} +
  • commit {{ShortSha .CommitId}}
  • +