From 06785e5f194363b5290d2d4a7df8c2ebbd4f7349 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 23 2015 09:50:03 +0000 Subject: [PATCH 1/2] Add a method to reset the merge_status of all open PR of a project This is required to do every-time a PR is merged otherwise we will still show the cached status instead of showing an updated one. --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 8843f05..749bdee 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -1592,6 +1592,18 @@ def close_pull_request(session, request, user, requestfolder, merged=True): ) ) +def reset_status_pull_request(session, project): + ''' Reset the status of all opened Pull-Requests of a project. + ''' + requests = search_pull_requests( + session, project_id=project.id, status='Open') + + for request in requests: + request.merge_status = None + session.add(request) + + session.commit() + def get_issue_statuses(session): ''' Return the complete list of status an issue can have. From c1aaacc50e543dc2f3868d3632943967d035251d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 23 2015 09:53:25 +0000 Subject: [PATCH 2/2] Reset the merge_status of all opened PR of a project when merging a PR --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index cf68d31..28b1a67 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -990,6 +990,8 @@ def merge_pull_request( requestfolder=request_folder, ) try: + # Reset the merge_status of all opened PR to refresh their cache + pagure.lib.reset_status_pull_request(session, request.project) session.commit() except SQLAlchemyError as err: # pragma: no cover session.rollback()