mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-30 06:38:37 -04:00 
			
		
		
		
	Web editor: disallow edit mirror repository
This commit is contained in:
		| @@ -3,7 +3,7 @@ Gogs - Go Git Service [ | ||||
|  | ||||
| ##### Current tip version: 0.9.91 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions) | ||||
| ##### Current tip version: 0.9.92 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions) | ||||
|  | ||||
| | Web | UI  | Preview  | | ||||
| |:-------------:|:-------:|:-------:| | ||||
|   | ||||
| @@ -511,7 +511,7 @@ func runWeb(ctx *cli.Context) error { | ||||
| 			// m.Post("/upload-file", repo.UploadFileToServer) | ||||
| 			// m.Post("/upload-remove", bindIgnErr(auth.RemoveUploadFileForm{}), repo.RemoveUploadFileFromServer) | ||||
| 		}, reqRepoWriter, context.RepoRef(), func(ctx *context.Context) { | ||||
| 			if ctx.Repo.IsViewCommit { | ||||
| 			if !ctx.Repo.Repository.CanEnableEditor() || ctx.Repo.IsViewCommit { | ||||
| 				ctx.Handle(404, "", nil) | ||||
| 				return | ||||
| 			} | ||||
|   | ||||
							
								
								
									
										2
									
								
								gogs.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								gogs.go
									
									
									
									
									
								
							| @@ -17,7 +17,7 @@ import ( | ||||
| 	"github.com/gogits/gogs/modules/setting" | ||||
| ) | ||||
|  | ||||
| const APP_VER = "0.9.91.0828" | ||||
| const APP_VER = "0.9.92.0828" | ||||
|  | ||||
| func init() { | ||||
| 	runtime.GOMAXPROCS(runtime.NumCPU()) | ||||
|   | ||||
| @@ -444,6 +444,11 @@ func (repo *Repository) AllowsPulls() bool { | ||||
| 	return repo.CanEnablePulls() && repo.EnablePulls | ||||
| } | ||||
|  | ||||
| // CanEnableEditor returns true if repository meets the requirements of web editor. | ||||
| func (repo *Repository) CanEnableEditor() bool { | ||||
| 	return !repo.IsMirror | ||||
| } | ||||
|  | ||||
| // FIXME: should have a mutex to prevent producing same index for two issues that are created | ||||
| // closely enough. | ||||
| func (repo *Repository) NextIssueIndex() int64 { | ||||
|   | ||||
| @@ -1 +1 @@ | ||||
| 0.9.91.0828 | ||||
| 0.9.92.0828 | ||||
| @@ -33,6 +33,7 @@ | ||||
| 				</div> | ||||
| 			</div> | ||||
| 			<div class="right fitted item"> | ||||
| 				{{if .Repository.CanEnableEditor}} | ||||
| 					<div id="file-buttons" class="ui tiny buttons"> | ||||
| 						{{if .CanAddFile}} | ||||
| 							<a href="{{.RepoLink}}/_new/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}" class="ui button"> | ||||
| @@ -45,6 +46,9 @@ | ||||
| 							</a> --> | ||||
| 						{{end}} | ||||
| 					</div> | ||||
| 				{{end}} | ||||
| 				 | ||||
| 				<!-- Only show colne panel in repository home page --> | ||||
| 				{{if eq $n 0}} | ||||
| 					<div class="ui action small input" id="clone-panel"> | ||||
| 						<button class="ui basic clone button" id="repo-clone-https" data-link="{{.CloneLink.HTTPS}}"> | ||||
|   | ||||
| @@ -20,6 +20,7 @@ | ||||
| 					<a class="ui button" href="{{.RepoLink}}/commits/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_history"}}</a> | ||||
| 					<a class="ui button" href="{{EscapePound .FileLink}}">{{.i18n.Tr "repo.file_raw"}}</a> | ||||
| 				</div> | ||||
| 				{{if .Repository.CanEnableEditor}} | ||||
| 					{{if .CanEditFile}} | ||||
| 						<a href="{{.RepoLink}}/_edit/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><i class="octicon octicon-pencil btn-octicon poping up"  data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a> | ||||
| 					{{else}} | ||||
| @@ -30,6 +31,7 @@ | ||||
| 					{{else}} | ||||
| 						<i class="octicon octicon-trashcan btn-octicon poping up disabled" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i> | ||||
| 					{{end}} | ||||
| 				{{end}} | ||||
| 			</div> | ||||
| 		{{end}} | ||||
| 	</h4> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user