Ported the function as-is and added comments so we don't forget about this in the future. Fixes: https://github.com/go-gitea/gitea/issues/29462 (cherry picked from commit 82405f808d7b50c3580f26e5ca645e2ed6d284ab)
Ported the function as-is and added comments so we don't forget about this in the future. Fixes: https://github.com/go-gitea/gitea/issues/29462 (cherry picked from commit 82405f808d7b50c3580f26e5ca645e2ed6d284ab)