Sfoglia il codice sorgente

repo: does not allow fork to original owner (#4182)

But can still fork to organizations.
Unknwon 7 anni fa
parent
commit
4d90527a6e
3 ha cambiato i file con 8 aggiunte e 1 eliminazioni
  1. 1 0
      conf/locale/locale_en-US.ini
  2. 1 1
      modules/bindata/bindata.go
  3. 6 0
      routers/repo/pull.go

+ 1 - 0
conf/locale/locale_en-US.ini

@@ -688,6 +688,7 @@ settings.tracker_issue_style.alphanumeric = Alphanumeric
 settings.tracker_url_format_desc = You can use placeholder <code>{user} {repo} {index}</code> for user name, repository name and issue index.
 settings.pulls_desc = Enable pull requests to accept public contributions
 settings.danger_zone = Danger Zone
+settings.cannot_fork_to_same_owner = You cannot fork a repository to its original owner.
 settings.new_owner_has_same_repo = The new owner already has a repository with same name. Please choose another name.
 settings.convert = Convert To Regular Repository
 settings.convert_desc = You can convert this mirror to a regular repository. This cannot be reversed.

File diff suppressed because it is too large
+ 1 - 1
modules/bindata/bindata.go


+ 6 - 0
routers/repo/pull.go

@@ -118,6 +118,12 @@ func ForkPost(ctx *context.Context, form auth.CreateRepoForm) {
 		}
 	}
 
+	// Cannot fork to same owner
+	if ctxUser.ID == forkRepo.OwnerID {
+		ctx.RenderWithErr(ctx.Tr("repo.settings.cannot_fork_to_same_owner"), FORK, &form)
+		return
+	}
+
 	repo, err := models.ForkRepository(ctxUser, forkRepo, form.RepoName, form.Description)
 	if err != nil {
 		ctx.Data["Err_RepoName"] = true

Some files were not shown because too many files changed in this diff