Fixes some more tests in the line of f61bb39.
But the repo was empty when the PR got created (granted, not after) :)
If I merge this and it fails on ci.centos.org, I'll come back to haunt you, deal? :)
About mocking pagure.lib.git.update_pull_ref(), it took me a while to track it down but this function is called by pagure.lib.tasks.sync_pull_ref() which is itself called by pagure.lib.new_pull_request() in the test. At the moment, it's a race condition : it's counting on the fact that the delayed task will not run before we make the GET request. If it runs before, then pagure.lib.git.get_diff_info() will see the orig_repo.is_empty as False and it will blow up.
pagure.lib.git.update_pull_ref()
pagure.lib.tasks.sync_pull_ref()
pagure.lib.new_pull_request()
pagure.lib.git.get_diff_info()
orig_repo.is_empty
About setting REMOTE_ADDR, yeah I've tested it on Flask 0.11 and Flask 0.12 and both work.
REMOTE_ADDR
I'm not quite seeing the race condition since pagure.lib.git.get_diff_info() is called before the PR gets created, so I'm not entirely sure how they could be racing.
hmm nope in the test get_diff_info() is called after, it's called when doing GET on the pull request via the diff_pull_request() function.
get_diff_info()
diff_pull_request()
Hm, ok I see what you mean, but if that raises an error it's likely something we need to fix as opening a PR against an empty project is a valid use-case
Yes, the consequence is a redirect to the project page with the flash message "Branch master could not be found in the target repo". It comes from get_diff_info(), the .is_empty condition there returns False because the refs/pull isn't empty, but there is still no master branch. Maybe make that condition a bit smarter?
.is_empty
False
refs/pull
Sounds good, do we want to do it here or merge this and track that in another PR?
Another PR sounds cleaner
Corresponding issue: #3090
Let's rebase and merge :)
rebased onto d90ed462e25dd17ea7bc8bbd1cd14b7b2eb70210
Pull-Request has been merged by pingou
Fixes some more tests in the line of f61bb39.