Browse Source

Revert "Add ability to fork your own repos (#761)" (#2193)

Bwko 3 years ago
parent
commit
8f171210b9
3 changed files with 8 additions and 1 deletions
  1. 1 0
      options/locale/locale_en-US.ini
  2. 6 0
      routers/repo/pull.go
  3. 1 1
      templates/repo/header.tmpl

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

@@ -492,6 +492,7 @@ migrate.lfs_mirror_unsupported = Mirroring LFS objects is not supported - use 'g
492 492
 
493 493
 mirror_from = mirror of
494 494
 forked_from = forked from
495
+fork_from_self = You cannot fork a repository you already own!
495 496
 copy_link = Copy
496 497
 copy_link_success = Copied!
497 498
 copy_link_error = Press ⌘-C or Ctrl-C to copy

+ 6 - 0
routers/repo/pull.go

@@ -111,6 +111,12 @@ func ForkPost(ctx *context.Context, form auth.CreateRepoForm) {
111 111
 		return
112 112
 	}
113 113
 
114
+	repo, has := models.HasForkedRepo(ctxUser.ID, forkRepo.ID)
115
+	if has {
116
+		ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name)
117
+		return
118
+	}
119
+
114 120
 	// Check ownership of organization.
115 121
 	if ctxUser.IsOrganization() {
116 122
 		if !ctxUser.IsOwnedBy(ctx.User.ID) {

+ 1 - 1
templates/repo/header.tmpl

@@ -32,7 +32,7 @@
32 32
 						</div>
33 33
 						{{if .CanBeForked}}
34 34
 							<div class="ui compact labeled button" tabindex="0">
35
-								<a class="ui compact button" href="{{AppSubUrl}}/repo/fork/{{.ID}}">
35
+								<a class="ui compact button {{if eq .OwnerID $.SignedUserID}}poping up{{end}}" {{if not (eq .OwnerID $.SignedUserID)}}href="{{AppSubUrl}}/repo/fork/{{.ID}}"{{else}} data-content="{{$.i18n.Tr "repo.fork_from_self"}}" data-position="top center" data-variation="tiny"{{end}}>
36 36
 									<i class="octicon octicon-repo-forked"></i>{{$.i18n.Tr "repo.fork"}}
37 37
 								</a>
38 38
 								<a class="ui basic label" href="{{.Link}}/forks">