Backport #10344
Ensure that pr.HeadRepo is loaded before using it in GetPullRequestCommitStatusState.
Fixes error on merging with successful commit merge statuses.
Backport #10317
The commit status code has a bug whereby setting the initial status to Pending means you can never have the status of Success - it should be set to Success.
* Fix wrong hint when status checking is running on pull request view
* fix lint
* fix test
* fix test
* fix wrong tmpl
* fix import
* rename function name
In investigating #7947 it has become clear that the storage component of go-git repositories needs closing.
This PR adds this Close function and adds the Close functions as necessary.
In TransferOwnership the ctx.Repo.GitRepo is closed if it is open to help prevent the risk of multiple open files.
Fixes#7947
* extract actions on new pull request from models to pulls service
* improve code
* move code.gitea.io/gitea/modules/pull to code.gitea.io/gitea/services/pull
* fix fmt
* Rename pulls.go to pull.go