https://github.com/go-gitea/gitea/pull/30876#discussion_r1637112394 (cherry picked from commit 78e8296e113e2fd9259ec05fe87035427821ea0b)