Skip to content

Commit 52f4691

Browse files
authored
Add error info if no user can fork the repo (#25820)
Before: (Owner list is empty) ![image](https://github.com/go-gitea/gitea/assets/18380374/dbe87bfe-14ed-4997-8cb2-5c1308232a70) After: (Disable the button and show the error info) ![image](https://github.com/go-gitea/gitea/assets/18380374/a7e4c315-67ab-408b-88f2-c554076ce87a)
1 parent 61c9268 commit 52f4691

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

options/locale/locale_en-US.ini

+1
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ fork_from = Fork From
935935
already_forked = You've already forked %s
936936
fork_to_different_account = Fork to a different account
937937
fork_visibility_helper = The visibility of a forked repository cannot be changed.
938+
fork_no_valid_owners = This repository can not be forked because there are no valid owners.
938939
use_template = Use this template
939940
clone_in_vsc = Clone in VS Code
940941
download_zip = Download ZIP

routers/web/repo/pull.go

+6
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository {
174174
ctx.Data["ContextUser"] = ctx.Doer
175175
} else if len(orgs) > 0 {
176176
ctx.Data["ContextUser"] = orgs[0]
177+
} else {
178+
msg := ctx.Tr("repo.fork_no_valid_owners")
179+
ctx.Data["Flash"] = ctx.Flash
180+
ctx.Flash.Error(msg)
181+
ctx.Data["CanForkRepo"] = false
182+
return nil
177183
}
178184

179185
return forkRepo

0 commit comments

Comments
 (0)