update git api. fix link... and so on

This commit is contained in:
slene 2014-03-30 10:13:02 +08:00
parent 41ca0ed302
commit b27c34f39a
11 changed files with 63 additions and 91 deletions

View file

@ -50,16 +50,12 @@ func Commits(ctx *middleware.Context, params martini.Params) {
}
func Diff(ctx *middleware.Context, params martini.Params) {
userName := params["username"]
repoName := params["reponame"]
branchName := params["branchname"]
commitId := params["commitid"]
userName := ctx.Repo.Owner.Name
repoName := ctx.Repo.Repository.Name
branchName := ctx.Repo.BranchName
commitId := ctx.Repo.CommitId
commit, err := models.GetCommit(userName, repoName, branchName, commitId)
if err != nil {
ctx.Handle(404, "repo.Diff", err)
return
}
commit := ctx.Repo.Commit
diff, err := models.GetDiff(models.RepoPath(userName, repoName), commitId)
if err != nil {
@ -85,11 +81,9 @@ func Diff(ctx *middleware.Context, params martini.Params) {
return isImage
}
shortSha := params["commitid"][:10]
ctx.Data["IsImageFile"] = isImageFile
ctx.Data["Title"] = commit.Message() + " · " + shortSha
ctx.Data["Title"] = commit.Message() + " · " + base.ShortSha(commitId)
ctx.Data["Commit"] = commit
ctx.Data["ShortSha"] = shortSha
ctx.Data["Diff"] = diff
ctx.Data["IsRepoToolbarCommits"] = true
ctx.Data["SourcePath"] = "/" + path.Join(userName, repoName, "src", commitId)