From fec0c505300d6f98a73ffd06a89d78520ed423bb Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 03 2017 16:52:56 +0000 Subject: [PATCH 1/3] Check that the identifier isn't the hash of a git tree If the user provides the hash of a tree instead of the hash of a commit, we currently crash in a 500 error. With this commit if the hash returned a tree, don't try to extract a tree from it. Fixes an error reported by email. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 0045487..f4fa534 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -469,9 +469,15 @@ def view_file(repo, identifier, filename, username=None, namespace=None): if isinstance(commit, pygit2.Tag): commit = commit.get_object() - if commit and not isinstance(commit, pygit2.Blob): + tree = None + if isinstance(commit, pygit2.Tree): + tree = commit + elif isinstance(commit, pygit2.Commit): + tree = commit.tree + + if tree and commit and not isinstance(commit, pygit2.Blob): content = __get_file_in_tree( - repo_obj, commit.tree, filename.split('/'), bail_on_tree=True) + repo_obj, tree, filename.split('/'), bail_on_tree=True) if not content: flask.abort(404, 'File not found') content = repo_obj[content.oid] From 66b80e713c58cc2a177bc16d779af5bea88c662f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 03 2017 16:52:56 +0000 Subject: [PATCH 2/3] Fix if the identifier provided is one of a blob instead of a commit Currently if the user provide the hash of a blob instead of the one of a commit, we simply crash since the objects are different. With this commit, we will raise a 404 error instead of a 500 error. Fixes an error reported by email Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index f4fa534..499b9c5 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -743,6 +743,9 @@ def view_commit(repo, commitid, username=None, namespace=None): if commit is None: flask.abort(404, 'Commit not found') + if isinstance(commit, pygit2.Blob): + flask.abort(404, 'Commit not found') + if commit.parents: diff = repo_obj.diff(commit.parents[0], commit) else: From 28408380f45fb112f4c7706359255980ee1c2d31 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 03 2017 17:09:40 +0000 Subject: [PATCH 3/3] Include the status when flagging a PR via jenkins Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/lib_ci.py b/pagure/lib/lib_ci.py index cd9cc7e..f87e4a4 100644 --- a/pagure/lib/lib_ci.py +++ b/pagure/lib/lib_ci.py @@ -55,6 +55,8 @@ def process_jenkins_build(session, project, build_id, requestfolder): pagure.exceptions.PagureException( 'Unknown build status: %s' % result) + status = result.lower() + request = pagure.lib.search_pull_requests( session, project_id=project.id, requestid=pr_id) @@ -72,6 +74,7 @@ def process_jenkins_build(session, project, build_id, requestfolder): percent=percent, comment=comment, url=url, + status=status, uid=None, user=project.user.username, token=None,