Skip to content

Commit cc9feed

Browse files
committed
fix fork check
1 parent c654ade commit cc9feed

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

routers/web/repo/fork.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,17 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository {
9191
ctx.Data["CanForkToUser"] = canForkToUser
9292
ctx.Data["Orgs"] = orgs
9393

94+
// TODO: this message should only be shown for the "current doer" when it is selected, just like the "new repo" page.
95+
// msg := ctx.TrN(maxCreationLimit, "repo.form.reach_limit_of_creation_1", "repo.form.reach_limit_of_creation_n", ctx.Doer.MaxCreationLimit())
96+
9497
if canForkToUser {
9598
ctx.Data["ContextUser"] = ctx.Doer
99+
ctx.Data["CanForkRepoInNewOwner"] = true
96100
} else if len(orgs) > 0 {
97101
ctx.Data["ContextUser"] = orgs[0]
102+
ctx.Data["CanForkRepoInNewOwner"] = true
98103
} else {
99-
ctx.Data["CanForkRepoInDoer"] = false
104+
ctx.Data["CanForkRepoInNewOwner"] = false
100105
ctx.Flash.Error(ctx.Tr("repo.fork_no_valid_owners"), true)
101106
return nil
102107
}
@@ -120,15 +125,6 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository {
120125
// Fork render repository fork page
121126
func Fork(ctx *context.Context) {
122127
ctx.Data["Title"] = ctx.Tr("new_fork")
123-
124-
if ctx.Doer.CanForkRepoIn(ctx.Doer) {
125-
ctx.Data["CanForkRepoInDoer"] = true
126-
} else {
127-
maxCreationLimit := ctx.Doer.MaxCreationLimit()
128-
msg := ctx.TrN(maxCreationLimit, "repo.form.reach_limit_of_creation_1", "repo.form.reach_limit_of_creation_n", maxCreationLimit)
129-
ctx.Flash.Error(msg, true)
130-
}
131-
132128
getForkRepository(ctx)
133129
if ctx.Written() {
134130
return
@@ -141,7 +137,6 @@ func Fork(ctx *context.Context) {
141137
func ForkPost(ctx *context.Context) {
142138
form := web.GetForm(ctx).(*forms.CreateRepoForm)
143139
ctx.Data["Title"] = ctx.Tr("new_fork")
144-
ctx.Data["CanForkRepoInDoer"] = true
145140

146141
ctxUser := checkContextUser(ctx, form.UID)
147142
if ctx.Written() {

templates/repo/pulls/fork.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
<div class="inline field">
7777
<label></label>
78-
<button class="ui primary button{{if not .CanForkRepoInDoer}} disabled{{end}}">
78+
<button class="ui primary button{{if not .CanForkRepoInNewOwner}} disabled{{end}}">
7979
{{ctx.Locale.Tr "repo.fork_repo"}}
8080
</button>
8181
</div>

0 commit comments

Comments
 (0)