@ -30,32 +30,31 @@ import (
"github.com/nektos/act/pkg/model"
)
func prepareLatestCommitInfo ( ctx * context . Context ) bool {
commit , err := ctx . Repo . Commit . GetCommitByPath ( ctx . Repo . TreePath )
if err != nil {
ctx . ServerError ( "GetCommitByPath" , err )
return false
}
return loadLatestCommitData ( ctx , commit )
}
func prepareToRenderFile ( ctx * context . Context , entry * git . TreeEntry ) {
ctx . Data [ "IsViewFile" ] = true
ctx . Data [ "HideRepoInfo" ] = true
blob := entry . Blob ( )
buf , dataRc , fInfo , err := getFileReader ( ctx , ctx . Repo . Repository . ID , blob )
if err != nil {
ctx . ServerError ( "getFileReader" , err )
if ! prepareLatestCommitInfo ( ctx ) {
return
}
defer dataRc . Close ( )
blob := entry . Blob ( )
ctx . Data [ "Title" ] = ctx . Tr ( "repo.file.title" , ctx . Repo . Repository . Name + "/" + path . Base ( ctx . Repo . TreePath ) , ctx . Repo . RefFullName . ShortName ( ) )
ctx . Data [ "FileIsSymlink" ] = entry . IsLink ( )
ctx . Data [ "FileName" ] = blob . Name ( )
ctx . Data [ "RawFileLink" ] = ctx . Repo . RepoLink + "/raw/" + ctx . Repo . RefTypeNameSubURL ( ) + "/" + util . PathEscapeSegments ( ctx . Repo . TreePath )
commit , err := ctx . Repo . Commit . GetCommitByPath ( ctx . Repo . TreePath )
if err != nil {
ctx . ServerError ( "GetCommitByPath" , err )
return
}
if ! loadLatestCommitData ( ctx , commit ) {
return
}
if ctx . Repo . TreePath == ".editorconfig" {
_ , editorconfigWarning , editorconfigErr := ctx . Repo . GetEditorconfig ( ctx . Repo . Commit )
if editorconfigWarning != nil {
@ -90,6 +89,15 @@ func prepareToRenderFile(ctx *context.Context, entry *git.TreeEntry) {
isDisplayingSource := ctx . FormString ( "display" ) == "source"
isDisplayingRendered := ! isDisplayingSource
// Don't call any other repository functions depends on git.Repository until the dataRc closed to
// avoid create unnecessary temporary cat file.
buf , dataRc , fInfo , err := getFileReader ( ctx , ctx . Repo . Repository . ID , blob )
if err != nil {
ctx . ServerError ( "getFileReader" , err )
return
}
defer dataRc . Close ( )
if fInfo . isLFSFile {
ctx . Data [ "RawFileLink" ] = ctx . Repo . RepoLink + "/media/" + ctx . Repo . RefTypeNameSubURL ( ) + "/" + util . PathEscapeSegments ( ctx . Repo . TreePath )
}