git: fix pull request deletion - don't crash on deleting refs to PR heads
tests: initial_repo_scan = false in test.ini, explicitly do repo scan in the pytest configure phase.
test: move test environment initialization from the main code to tests
lib: fix Git hook failure after TG2 port
middleware: convert check_locking_state to be a separate function