@ -8,6 +8,7 @@ import (
"errors"
"errors"
"fmt"
"fmt"
"net/http"
"net/http"
"net/url"
"strings"
"strings"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models"
@ -65,21 +66,17 @@ func Branches(ctx *context.Context) {
if page <= 1 {
if page <= 1 {
page = 1
page = 1
}
}
pageSize := setting . Git . BranchesRangeSize
limit := ctx . FormInt ( "limit" )
skip := ( page - 1 ) * pageSize
if limit <= 0 || limit > setting . Git . BranchesRangeSize {
log . Debug ( "Branches: skip: %d limit: %d" , skip , pageSize )
limit = setting . Git . BranchesRangeSize
defaultBranchBranch , branches , branchesCount := loadBranches ( ctx , skip , pageSize )
}
skip := ( page - 1 ) * limit
log . Debug ( "Branches: skip: %d limit: %d" , skip , limit )
defaultBranchBranch , branches , branchesCount := loadBranches ( ctx , skip , limit )
if ctx . Written ( ) {
if ctx . Written ( ) {
return
return
}
}
ctx . Data [ "Branches" ] = branches
ctx . Data [ "Branches" ] = branches
ctx . Data [ "DefaultBranchBranch" ] = defaultBranchBranch
ctx . Data [ "DefaultBranchBranch" ] = defaultBranchBranch
pager := context . NewPagination ( branchesCount , setting . Git . BranchesRan geSize, page , 5 )
pager := context . NewPagination ( branchesCount , pa geSize, page , 5 )
pager . SetDefaultParams ( ctx )
pager . SetDefaultParams ( ctx )
ctx . Data [ "Page" ] = pager
ctx . Data [ "Page" ] = pager
@ -165,7 +162,7 @@ func RestoreBranchPost(ctx *context.Context) {
func redirect ( ctx * context . Context ) {
func redirect ( ctx * context . Context ) {
ctx . JSON ( http . StatusOK , map [ string ] interface { } {
ctx . JSON ( http . StatusOK , map [ string ] interface { } {
"redirect" : ctx . Repo . RepoLink + "/branches" ,
"redirect" : ctx . Repo . RepoLink + "/branches?page= " + url . QueryEscape ( ctx . FormString ( "page" ) ) ,
} )
} )
}
}