diff options
author | Lauris BH <lauris@nix.lv> | 2017-10-15 22:59:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-15 22:59:24 +0300 |
commit | f3833b7ce4dc78095194808c6e07d8ae133e7ab5 (patch) | |
tree | cdcb53731d4523f068a6e532bf5da9e2759f8cb2 /modules/context | |
parent | c25303b11c323045718a5af373c11f5807f77fb7 (diff) | |
download | gitea-f3833b7ce4dc78095194808c6e07d8ae133e7ab5.tar.gz gitea-f3833b7ce4dc78095194808c6e07d8ae133e7ab5.zip |
Create new branch from branch selection dropdown (#2130)
* Create new branch from branch selection dropdown and rewrite it to VueJS
* Make updateLocalCopyToCommit as not exported
* Move branch name validation to model
* Fix possible race condition
Diffstat (limited to 'modules/context')
-rw-r--r-- | modules/context/repo.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go index 88208922c8..c33396c0f9 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -76,6 +76,11 @@ func (r *Repository) CanEnableEditor() bool { return r.Repository.CanEnableEditor() && r.IsViewBranch && r.IsWriter() } +// CanCreateBranch returns true if repository is editable and user has proper access level. +func (r *Repository) CanCreateBranch() bool { + return r.Repository.CanCreateBranch() && r.IsWriter() +} + // CanCommitToBranch returns true if repository is editable and user has proper access level // and branch is not protected func (r *Repository) CanCommitToBranch(doer *models.User) (bool, error) { @@ -528,6 +533,7 @@ func RepoRef() macaron.Handler { ctx.Data["IsViewBranch"] = ctx.Repo.IsViewBranch ctx.Data["IsViewTag"] = ctx.Repo.IsViewTag ctx.Data["IsViewCommit"] = ctx.Repo.IsViewCommit + ctx.Data["CanCreateBranch"] = ctx.Repo.CanCreateBranch() ctx.Repo.CommitsCount, err = ctx.Repo.Commit.CommitsCount() if err != nil { |