diff options
author | Unknwon <u@gogs.io> | 2017-02-17 15:10:50 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-02-17 15:10:50 -0500 |
commit | 7e09d210ba421a1baf03ef7ba8770bebe8d28b72 (patch) | |
tree | 1d209f6175c3e4d7e21c4bda62e65db0ac4608f5 /routers/repo/view.go | |
parent | dab768212af15f4e671e5403ad3def455117f699 (diff) |
Initial version of protected branches (#776)
- Able to restrict force push and deletion
- Able to restrict direct push
Diffstat (limited to 'routers/repo/view.go')
-rw-r--r-- | routers/repo/view.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/routers/repo/view.go b/routers/repo/view.go index 623b7fee..db0adea2 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -108,8 +108,7 @@ func renderDirectory(ctx *context.Context, treeLink string) { ctx.Data["LatestCommit"] = latestCommit ctx.Data["LatestCommitUser"] = models.ValidateCommitWithEmail(latestCommit) - // Check permission to add or upload new file. - if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch { + if ctx.Repo.CanEnableEditor() { ctx.Data["CanAddFile"] = true ctx.Data["CanUploadFile"] = setting.Repository.Upload.Enabled } @@ -142,6 +141,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.cannot_edit_non_text_files") } + canEnableEditor := ctx.Repo.CanEnableEditor() switch { case isTextFile: if blob.Size() >= setting.UI.MaxDisplayFileSize { @@ -186,7 +186,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st ctx.Data["LineNums"] = gotemplate.HTML(output.String()) } - if ctx.Repo.CanEnableEditor() { + if canEnableEditor { ctx.Data["CanEditFile"] = true ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.edit_this_file") } else if !ctx.Repo.IsViewBranch { @@ -203,7 +203,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st ctx.Data["IsImageFile"] = true } - if ctx.Repo.CanEnableEditor() { + if canEnableEditor { ctx.Data["CanDeleteFile"] = true ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.delete_this_file") } else if !ctx.Repo.IsViewBranch { @@ -216,7 +216,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st func setEditorconfigIfExists(ctx *context.Context) { ec, err := ctx.Repo.GetEditorconfig() if err != nil && !git.IsErrNotExist(err) { - log.Error(4, "Fail to get '.editorconfig' [%d]: %v", ctx.Repo.Repository.ID, err) + log.Trace("setEditorconfigIfExists.GetEditorconfig [%d]: %v", ctx.Repo.Repository.ID, err) return } ctx.Data["Editorconfig"] = ec @@ -228,6 +228,9 @@ func Home(ctx *context.Context) { title += ": " + ctx.Repo.Repository.Description } ctx.Data["Title"] = title + if ctx.Repo.BranchName != ctx.Repo.Repository.DefaultBranch { + ctx.Data["Title"] = title + " @ " + ctx.Repo.BranchName + } ctx.Data["PageIsViewCode"] = true ctx.Data["RequireHighlightJS"] = true |