Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error info if no user can fork the repo #25820

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ fork_from = Fork From
already_forked = You've already forked %s
fork_to_different_account = Fork to a different account
fork_visibility_helper = The visibility of a forked repository cannot be changed.
no_fork_user = No user can fork this repo.
yp05327 marked this conversation as resolved.
Show resolved Hide resolved
use_template = Use this template
clone_in_vsc = Clone in VS Code
download_zip = Download ZIP
Expand Down
6 changes: 6 additions & 0 deletions routers/web/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository {
ctx.Data["ContextUser"] = ctx.Doer
} else if len(orgs) > 0 {
ctx.Data["ContextUser"] = orgs[0]
} else {
msg := ctx.Tr("repo.no_fork_user")
yp05327 marked this conversation as resolved.
Show resolved Hide resolved
ctx.Data["Flash"] = ctx.Flash
ctx.Flash.Error(msg)
Comment on lines +179 to +180
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would break the "Flash" framework, it should be ctx.Flash.Error(msg, true)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> Fix "Flash" message usage #25895

ctx.Data["CanForkRepo"] = false
return nil
}

return forkRepo
Expand Down