mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-29 14:54:06 +00:00
fix(web): populate the reason for "cannot commit to branch" in web editor commit form (#39155)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
+5
-17
@@ -575,14 +575,13 @@ func (repo *Repository) IsOwnedBy(userID int64) bool {
|
||||
return repo.OwnerID == userID
|
||||
}
|
||||
|
||||
// CanCreateBranch returns true if repository meets the requirements for creating new branches.
|
||||
func (repo *Repository) CanCreateBranch() bool {
|
||||
return !repo.IsMirror
|
||||
}
|
||||
|
||||
// CanEnablePulls returns true if repository meets the requirements of accepting pulls.
|
||||
func (repo *Repository) CanEnablePulls() bool {
|
||||
return !repo.IsMirror && !repo.IsEmpty
|
||||
return repo.CanContentChange() && !repo.IsEmpty
|
||||
}
|
||||
|
||||
func (repo *Repository) CanContentChange() bool {
|
||||
return !repo.IsMirror && !repo.IsArchived
|
||||
}
|
||||
|
||||
// AllowsPulls returns true if repository meets the requirements of accepting pulls and has them enabled.
|
||||
@@ -590,17 +589,6 @@ func (repo *Repository) AllowsPulls(ctx context.Context) bool {
|
||||
return repo.CanEnablePulls() && repo.UnitEnabled(ctx, unit.TypePullRequests)
|
||||
}
|
||||
|
||||
// CanEnableEditor returns true if repository meets the requirements of web editor.
|
||||
// FIXME: most CanEnableEditor calls should be replaced with CanContentChange
|
||||
// And all other like CanCreateBranch / CanEnablePulls should also be updated
|
||||
func (repo *Repository) CanEnableEditor() bool {
|
||||
return repo.CanContentChange()
|
||||
}
|
||||
|
||||
func (repo *Repository) CanContentChange() bool {
|
||||
return !repo.IsMirror && !repo.IsArchived
|
||||
}
|
||||
|
||||
// DescriptionHTML does special handles to description and return HTML string.
|
||||
func (repo *Repository) DescriptionHTML(ctx context.Context) template.HTML {
|
||||
return markup.PostProcessDescriptionHTML(markup.NewRenderContext(ctx), htmlutil.EscapeString(repo.Description))
|
||||
|
||||
Reference in New Issue
Block a user