#1761 Improve the error message on error pulling changes of remote pull-request
Merged by pingou. Opened by pingou.
nicer_remote_error  into  master

Download 1761.patch

With remote pull-request, the changes are pulled from the remote repo
when the PR is accessed, in order to offer to the reviewer, the latest
changes.
If for some reason the pull errors out, it will raise a GitError.
With this PR we catch this exception and return it to the user with an
error message, being a little more friendly than we were.

Fixes https://pagure.io/pagure/issue/1755

I could be asking too much but can we have some picture or some break down logo here too ? :alien:

That would be a request for an artist, and trust me, I'm not one :-D

And I'm not sure how related this is to this PR :)

hahaha okay then LGTM :thumbsup: but still if @ryanlerch can do something for us it will be awesome .

We should make a ticket for this then :)

Potentially, we could just put the pagure logo on both the 500 and the 404 pages, it's a fairly easyfix. But if we want to go with another ~~ticket~~ design not ticket, then it is clearly something for an artist :)

Is there a particular reason to exclude this from the coverage report?

How would you reproduce a network error?

If it's logged at the exception level does it doesn't make much sense to me to log it again at the debug level as well.

One triggers an email, the other appears in the logs

You can use mock to raise exceptions as a side effect. Although you don't test that a network error raises GitError, you do test that when that exception is raised it's handled as expected.

Let me try replicating the issue locally and see if exception also logs in the log file

1 new commit added

  • Improve the error returned when cloning a remote git repo fails and logging

I recommend writing a test case for this and only logging the exception once. This looks reasonable though, :thumbsup:

I dropped logging the exception twice and remove the no-cover so we know this isn't covered by the tests.

We'll need to investigate how to trigger the exception in the tests. I'm going to give it a try and if that takes too much time I'll keep it for another PR, otherwise, I'll update this one and let people know :)

Sounds good. It should be as simple as mocking pygit2.clone_repository with mock.Mock(side_effect=WhateverExceptionYouWant).

1 new commit added

  • Add unit-tests checking the get_remote_repo_path method in pagure

Ok, added a test, how does this look now? :)

If/when more test classes get added to this file, it's probably easier to do unittest.main(verbosity=2)

One small note, nothing blocking. Looks good to me.

rebased

I adjusted how the tests are called and rebased :)

Many thanks for the review and the inputs :)

Pull-Request has been merged by pingou

Metadata