@ -5,7 +5,6 @@
package repo
package repo
import (
import (
"encoding/json"
"path"
"path"
"github.com/go-martini/martini"
"github.com/go-martini/martini"
@ -106,26 +105,6 @@ func SearchCommits(ctx *middleware.Context, params martini.Params) {
ctx . HTML ( 200 , COMMITS )
ctx . HTML ( 200 , COMMITS )
}
}
func DiffAjax ( ctx * middleware . Context , params martini . Params ) {
userName := params [ "username" ]
repoName := params [ "reponame" ]
commitId := params [ "branchname" ]
err := models . GetDiffCallback ( models . RepoPath ( userName , repoName ) , commitId , func ( f * models . DiffFile ) error {
bs , err := json . Marshal ( f )
if err != nil {
return err
}
_ , err = ctx . Res . Write ( bs )
return err
} )
if err != nil {
ctx . Handle ( 404 , "repo.DiffAjax" , err )
return
}
}
func Diff ( ctx * middleware . Context , params martini . Params ) {
func Diff ( ctx * middleware . Context , params martini . Params ) {
ctx . Data [ "IsRepoToolbarCommits" ] = true
ctx . Data [ "IsRepoToolbarCommits" ] = true
@ -135,11 +114,15 @@ func Diff(ctx *middleware.Context, params martini.Params) {
commit := ctx . Repo . Commit
commit := ctx . Repo . Commit
/ * diff , err := models . GetDiff ( models . RepoPath ( userName , repoName ) , commitId )
var fileChan = make ( chan * models . DiffFile )
go func ( ) {
err := models . GetDiffChan ( models . RepoPath ( userName , repoName ) , commitId , fileChan )
if err != nil {
if err != nil {
ctx . Handle ( 404 , "repo.Diff(GetDiff)" , err )
ctx . Handle ( 404 , "repo.Diff(GetDiff)" , err )
return
return
} * /
}
close ( fileChan )
} ( )
isImageFile := func ( name string ) bool {
isImageFile := func ( name string ) bool {
blob , err := ctx . Repo . Commit . GetBlobByPath ( name )
blob , err := ctx . Repo . Commit . GetBlobByPath ( name )
@ -178,9 +161,10 @@ func Diff(ctx *middleware.Context, params martini.Params) {
ctx . Data [ "Commit" ] = commit
ctx . Data [ "Commit" ] = commit
//ctx.Data["Diff"] = diff
//ctx.Data["Diff"] = diff
ctx . Data [ "Parents" ] = parents
ctx . Data [ "Parents" ] = parents
//ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
ctx . Data [ "DiffNotAvailable" ] = false
ctx . Data [ "SourcePath" ] = "/" + path . Join ( userName , repoName , "src" , commitId )
ctx . Data [ "SourcePath" ] = "/" + path . Join ( userName , repoName , "src" , commitId )
ctx . Data [ "RawPath" ] = "/" + path . Join ( userName , repoName , "raw" , commitId )
ctx . Data [ "RawPath" ] = "/" + path . Join ( userName , repoName , "raw" , commitId )
ctx . Data [ "Diffs" ] = fileChan
ctx . HTML ( 200 , DIFF )
ctx . HTML ( 200 , DIFF )
}
}