|
|
|
@ -18,8 +18,6 @@ import (
|
|
|
|
|
"github.com/go-macaron/session"
|
|
|
|
|
"gopkg.in/macaron.v1"
|
|
|
|
|
|
|
|
|
|
"github.com/gogits/git-module"
|
|
|
|
|
|
|
|
|
|
"github.com/gogits/gogs/models"
|
|
|
|
|
"github.com/gogits/gogs/modules/auth"
|
|
|
|
|
"github.com/gogits/gogs/modules/base"
|
|
|
|
@ -27,56 +25,6 @@ import (
|
|
|
|
|
"github.com/gogits/gogs/modules/setting"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type PullRequest struct {
|
|
|
|
|
BaseRepo *models.Repository
|
|
|
|
|
Allowed bool
|
|
|
|
|
SameRepo bool
|
|
|
|
|
HeadInfo string // [<user>:]<branch>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Repository struct {
|
|
|
|
|
AccessMode models.AccessMode
|
|
|
|
|
IsWatching bool
|
|
|
|
|
IsViewBranch bool
|
|
|
|
|
IsViewTag bool
|
|
|
|
|
IsViewCommit bool
|
|
|
|
|
Repository *models.Repository
|
|
|
|
|
Owner *models.User
|
|
|
|
|
Commit *git.Commit
|
|
|
|
|
Tag *git.Tag
|
|
|
|
|
GitRepo *git.Repository
|
|
|
|
|
BranchName string
|
|
|
|
|
TagName string
|
|
|
|
|
TreeName string
|
|
|
|
|
CommitID string
|
|
|
|
|
RepoLink string
|
|
|
|
|
CloneLink models.CloneLink
|
|
|
|
|
CommitsCount int64
|
|
|
|
|
Mirror *models.Mirror
|
|
|
|
|
|
|
|
|
|
PullRequest *PullRequest
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IsOwner returns true if current user is the owner of repository.
|
|
|
|
|
func (r *Repository) IsOwner() bool {
|
|
|
|
|
return r.AccessMode >= models.ACCESS_MODE_OWNER
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IsAdmin returns true if current user has admin or higher access of repository.
|
|
|
|
|
func (r *Repository) IsAdmin() bool {
|
|
|
|
|
return r.AccessMode >= models.ACCESS_MODE_ADMIN
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IsWriter returns true if current user has write or higher access of repository.
|
|
|
|
|
func (r *Repository) IsWriter() bool {
|
|
|
|
|
return r.AccessMode >= models.ACCESS_MODE_WRITE
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// HasAccess returns true if the current user has at least read access for this repository
|
|
|
|
|
func (r *Repository) HasAccess() bool {
|
|
|
|
|
return r.AccessMode >= models.ACCESS_MODE_READ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Context represents context of a request.
|
|
|
|
|
type Context struct {
|
|
|
|
|
*macaron.Context
|
|
|
|
@ -90,17 +38,7 @@ type Context struct {
|
|
|
|
|
IsBasicAuth bool
|
|
|
|
|
|
|
|
|
|
Repo *Repository
|
|
|
|
|
|
|
|
|
|
Org struct {
|
|
|
|
|
IsOwner bool
|
|
|
|
|
IsMember bool
|
|
|
|
|
IsTeamMember bool // Is member of team.
|
|
|
|
|
IsTeamAdmin bool // In owner team or team that has admin permission level.
|
|
|
|
|
Organization *models.User
|
|
|
|
|
OrgLink string
|
|
|
|
|
|
|
|
|
|
Team *models.Team
|
|
|
|
|
}
|
|
|
|
|
Org *Organization
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// HasError returns true if error occurs in form validation.
|
|
|
|
@ -223,6 +161,7 @@ func Contexter() macaron.Handler {
|
|
|
|
|
Repo: &Repository{
|
|
|
|
|
PullRequest: &PullRequest{},
|
|
|
|
|
},
|
|
|
|
|
Org: &Organization{},
|
|
|
|
|
}
|
|
|
|
|
// Compute current URL for real-time change language.
|
|
|
|
|
ctx.Data["Link"] = setting.AppSubUrl + strings.TrimSuffix(ctx.Req.URL.Path, "/")
|
|
|
|
|