From 3ba9322f935f47162b364facc8698036b10ce1fd Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 27 2015 12:39:59 +0000 Subject: [PATCH 1/2] Handle the situation where the branch asked is not found in the git repo This should fix an error seen in the logs: File "/usr/lib/python2.7/site-packages/pagure/internal/__init__.py", line 185, in mergeable_request_pull fork_obj.lookup_branch(request.branch_from).get_object().hex] AttributeError: 'NoneType' object has no attribute 'get_object' --- diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py index e03690a..cb7cb23 100644 --- a/pagure/internal/__init__.py +++ b/pagure/internal/__init__.py @@ -181,8 +181,15 @@ def mergeable_request_pull(): newpath = tempfile.mkdtemp(prefix='pagure-pr-check') new_repo = pygit2.clone_repository(parentpath, newpath) - repo_commit = fork_obj[ - fork_obj.lookup_branch(request.branch_from).get_object().hex] + branch = fork_obj.lookup_branch(request.branch_from) + if not branch: + flask.abort( + 400, + 'Branch %s could not be found in the repo %s' % ( + request.branch_from, request.project_from.fullname + )) + + repo_commit = fork_obj[branch.get_object().hex] ori_remote = new_repo.remotes[0] # Add the fork as remote repo From 8da4af181543dc9a9e589926a128e46b4f936a1c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 27 2015 12:39:59 +0000 Subject: [PATCH 2/2] Handle the situation where we cannot find a desired commit Should fix the error seen in the logs: File "/srv/progit/pagure/ui/repo.py", line 435, in view_raw_file if commit.parents: AttributeError: 'NoneType' object has no attribute 'parents' --- diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index e396789..b583501 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -421,6 +421,9 @@ def view_raw_file(repo, identifier, filename=None, username=None): # If it's not a commit id then it's part of the filename commit = repo_obj[repo_obj.head.target] + if not commit: + flask.abort(400, 'Commit %s not found' % (identifier)) + mimetype = None encoding = None if filename: