From c9612448071d090797a3916ad3c77934ba884007 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 11 2018 15:14:10 +0000 Subject: [PATCH 1/7] Add support to merge a PR when the fork was deleted Fixes https://pagure.io/pagure/issue/3818 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index cd8ead6..9a11472 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -924,6 +924,7 @@ class TemporaryClone(object): # equal to another.... The pygit2.Repository returned from # pygit2.clone_repository does not have the "branches" attribute. self.repo = pygit2.Repository(self.repopath) + self._origrepo = pygit2.Repository(self._origpath) else: repourl, regioninfo = self._project.repospanner_repo_info( self._repotype @@ -965,13 +966,21 @@ class TemporaryClone(object): headname = None if not self.repo.is_empty and not self.repo.head_is_unborn: headname = self.repo.head.shorthand - for branchname in self.repo.branches.remote: - localname = branchname.replace("origin/", "") - if localname in (headname, "HEAD"): - # This gets checked out by default - continue - branch = self.repo.branches.remote.get(branchname) - self.repo.branches.local.create(localname, branch.get_object()) + + # Sync up all the references, branches and PR heads + for ref in self._origrepo.listall_references(): + if ref.startswith("refs/heads/"): + localname = ref.replace("refs/heads/", "") + if localname in (headname, "HEAD"): + # This gets checked out by default + continue + branch = self.repo.branches.remote.get("origin/%s" % localname) + self.repo.branches.local.create(localname, branch.get_object()) + elif ref.startswith("refs/pull/"): + reference = self._origrepo.references.get(ref) + self.repo.references.create( + ref, reference.get_object().oid.hex + ) return self @@ -1474,6 +1483,7 @@ def merge_pull_request(session, request, username, domerge=True): else: _log.info("%s asked to diff the pull-request: %s", username, request) + repopath = None if request.remote: # Get the fork repopath = pagure.utils.get_remote_repo_path( @@ -1482,10 +1492,10 @@ def merge_pull_request(session, request, username, domerge=True): elif request.project_from: # Get the fork repopath = pagure.utils.get_repo_path(request.project_from) - else: - return - fork_obj = PagureRepo(repopath) + fork_obj = None + if repopath: + fork_obj = PagureRepo(repopath) with TemporaryClone(request.project, "main", "merge_pr") as tempclone: new_repo = tempclone.repo @@ -1507,95 +1517,112 @@ def merge_pull_request(session, request, username, domerge=True): "signed off by their author. " ) - # Check/Get the branch from - try: - branch = get_branch_ref(fork_obj, request.branch_from) - except pagure.exceptions.PagureException: + if not new_repo.is_empty and not new_repo.head_is_unborn: + try: + branch_ref = get_branch_ref(new_repo, request.branch) + except pagure.exceptions.PagureException: + branch_ref = None + if not branch_ref: + _log.info(" Target branch could not be found") + raise pagure.exceptions.BranchNotFoundException( + "Branch %s could not be found in the repo %s" + % (request.branch, request.project.fullname) + ) + + new_repo.checkout(branch_ref) + + if fork_obj: + # Check/Get the branch from branch = None - if not branch: - _log.info(" Branch of origin could not be found") - raise pagure.exceptions.BranchNotFoundException( - "Branch %s could not be found in the repo %s" - % ( - request.branch_from, - request.project_from.fullname - if request.project_from - else request.remote_git, + try: + branch = get_branch_ref(fork_obj, request.branch_from) + except pagure.exceptions.PagureException: + pass + if not branch: + _log.info(" Branch of origin could not be found") + raise pagure.exceptions.BranchNotFoundException( + "Branch %s could not be found in the repo %s" + % ( + request.branch_from, + request.project_from.fullname + if request.project_from + else request.remote_git, + ) ) + + # Add the fork as remote repo + reponame = "%s_%s" % (request.user.user, request.uid) + + _log.info( + " Adding remote: %s pointing to: %s", reponame, repopath ) + remote = new_repo.create_remote(reponame, repopath) - # Add the fork as remote repo - reponame = "%s_%s" % (request.user.user, request.uid) + # Fetch the commits + remote.fetch() - _log.info(" Adding remote: %s pointing to: %s", reponame, repopath) - remote = new_repo.create_remote(reponame, repopath) + # repo_commit = fork_obj[branch.get_object().hex] + repo_commit = new_repo[branch.get_object().hex] - # Fetch the commits - remote.fetch() + # Checkout the correct branch + if new_repo.is_empty or new_repo.head_is_unborn: + _log.debug( + " target repo is empty, so PR can be merged using " + "fast-forward, reporting it" + ) - # repo_commit = fork_obj[branch.get_object().hex] - repo_commit = new_repo[branch.get_object().hex] + if domerge: + _log.info(" PR merged using fast-forward") + if not request.project.settings.get("always_merge", False): + new_repo.create_branch(request.branch, repo_commit) + commit = repo_commit.oid.hex + else: + tree = new_repo.index.write_tree() + user_obj = pagure.lib.query.get_user(session, username) + commitname = user_obj.fullname or user_obj.user + author = _make_signature( + commitname, user_obj.default_email + ) + commit = new_repo.create_commit( + "refs/heads/%s" % request.branch, + author, + author, + "Merge #%s `%s`" % (request.id, request.title), + tree, + [repo_commit.oid.hex], + ) - # Checkout the correct branch - if new_repo.is_empty or new_repo.head_is_unborn: - _log.debug( - " target repo is empty, so PR can be merged using " - "fast-forward, reporting it" - ) - if domerge: - _log.info(" PR merged using fast-forward") - if not request.project.settings.get("always_merge", False): - new_repo.create_branch(request.branch, repo_commit) - commit = repo_commit.oid.hex - else: - tree = new_repo.index.write_tree() - user_obj = pagure.lib.query.get_user(session, username) - commitname = user_obj.fullname or user_obj.user - author = _make_signature( - commitname, user_obj.default_email - ) - commit = new_repo.create_commit( - "refs/heads/%s" % request.branch, - author, - author, - "Merge #%s `%s`" % (request.id, request.title), - tree, - [repo_commit.oid.hex], + _log.info(" New head: %s", commit) + tempclone.push( + username, + request.branch, + request.branch, + pull_request=request, ) - _log.info(" New head: %s", commit) - tempclone.push( - username, - request.branch, - request.branch, - pull_request=request, - ) + # Update status + _log.info(" Closing the PR in the DB") + pagure.lib.query.close_pull_request( + session, request, username + ) - # Update status - _log.info(" Closing the PR in the DB") - pagure.lib.query.close_pull_request(session, request, username) + return "Changes merged!" + else: + _log.info( + " PR can be merged using fast-forward, reporting it" + ) + request.merge_status = "FFORWARD" + session.commit() + return "FFORWARD" - return "Changes merged!" - else: - _log.info( - " PR can be merged using fast-forward, reporting it" + else: + try: + ref = new_repo.lookup_reference( + "refs/pull/%s/head" % request.id ) - request.merge_status = "FFORWARD" - session.commit() - return "FFORWARD" - - try: - branch_ref = get_branch_ref(new_repo, request.branch) - except pagure.exceptions.PagureException: - branch_ref = None - if not branch_ref: - _log.info(" Target branch could not be found") - raise pagure.exceptions.BranchNotFoundException( - "Branch %s could not be found in the repo %s" - % (request.branch, request.project.fullname) - ) - - new_repo.checkout(branch_ref) + repo_commit = new_repo[ref.target.hex] + except KeyError: + pass merge = new_repo.merge(repo_commit.oid) _log.debug(" Merge: %s", merge) @@ -1907,7 +1934,9 @@ def get_diff_info(repo_obj, orig_repo, branch_from, branch_to, prid=None): raise pagure.exceptions.BranchNotFoundException( "Branch %s does not exist" % branch_from ) - if not frombranch and not repo_obj.is_empty and prid is None: + except AttributeError: + frombranch = None + if not frombranch and prid is None and repo_obj and not repo_obj.is_empty: raise pagure.exceptions.BranchNotFoundException( "Branch %s does not exist" % branch_from ) @@ -1938,7 +1967,7 @@ def get_diff_info(repo_obj, orig_repo, branch_from, branch_to, prid=None): except KeyError: pass - if not commitid and not repo_obj.is_empty: + if not commitid and repo_obj and not repo_obj.is_empty: raise pagure.exceptions.PagureException( "No branch from which to pull or local PR reference were found" ) @@ -1948,7 +1977,7 @@ def get_diff_info(repo_obj, orig_repo, branch_from, branch_to, prid=None): orig_commit = None # If the fork is empty but there is a PR open, use the main repo - if repo_obj.is_empty and prid is not None: + if (not repo_obj or repo_obj.is_empty) and prid is not None: repo_obj = orig_repo if not repo_obj.is_empty and not orig_repo.is_empty: @@ -2017,7 +2046,7 @@ def get_diff_info(repo_obj, orig_repo, branch_from, branch_to, prid=None): ) diff = diff_commits[0].tree.diff_to_tree(swap=True) - elif orig_repo.is_empty and not repo_obj.is_empty: + elif orig_repo.is_empty and repo_obj and not repo_obj.is_empty: _log.info("pagure.lib.git.get_diff_info: Pulling into an empty repo") if "master" in repo_obj.listall_branches(): repo_commit = repo_obj[repo_obj.head.target] @@ -2072,7 +2101,7 @@ def diff_pull_request( ) if request.status == "Open" and diff_commits: - first_commit = repo_obj[diff_commits[-1].oid.hex] + first_commit = diff_commits[-1] # Check if we can still rely on the merge_status commenttext = None if ( diff --git a/pagure/lib/tasks.py b/pagure/lib/tasks.py index 4b764a6..fc6623a 100644 --- a/pagure/lib/tasks.py +++ b/pagure/lib/tasks.py @@ -854,9 +854,11 @@ def sync_pull_ref(self, session, name, namespace, user, requestid): repopath = pagure.utils.get_remote_repo_path( request.remote_git, request.branch_from ) - else: + elif request.project_from: # Get the fork repopath = pagure.utils.get_repo_path(request.project_from) + else: + return _log.debug(" working on the repo in: %s", repopath) repo_obj = pygit2.Repository(repopath) From c8c021b89f424e144b90e5746c5d981aaccaae5a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 11 2018 15:14:10 +0000 Subject: [PATCH 2/7] Fix calculating the PR diff stats on PR whose fork has been deleted Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/api/fork.py b/pagure/api/fork.py index 2ad88bc..d64059a 100644 --- a/pagure/api/fork.py +++ b/pagure/api/fork.py @@ -1525,19 +1525,18 @@ def api_pull_request_diffstats(repo, requestid, username=None, namespace=None): if not request: raise pagure.exceptions.APIError(404, error_code=APIERROR.ENOREQ) + repopath = None + parentpath = pagure.utils.get_repo_path(request.project) if request.remote: repopath = pagure.utils.get_remote_repo_path( request.remote_git, request.branch_from ) - parentpath = pagure.utils.get_repo_path(request.project) - else: - repo_from = request.project_from - parentpath = pagure.utils.get_repo_path(request.project) - repopath = parentpath - if repo_from: - repopath = pagure.utils.get_repo_path(repo_from) + elif request.project_from: + repopath = pagure.utils.get_repo_path(request.project_from) - repo_obj = pygit2.Repository(repopath) + repo_obj = None + if repopath: + repo_obj = pygit2.Repository(repopath) orig_repo = pygit2.Repository(parentpath) diff_commits = [] From 993f744b35609e5d42c99c4ab24cf05a2d594bc1 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 11 2018 15:14:10 +0000 Subject: [PATCH 3/7] Add tests checking actions on PR when there are no longer a fork Signed-off-by: Pierre-Yves Chibon --- diff --git a/tests/test_pagure_merge_pr_no_fork.py b/tests/test_pagure_merge_pr_no_fork.py new file mode 100644 index 0000000..181df6a --- /dev/null +++ b/tests/test_pagure_merge_pr_no_fork.py @@ -0,0 +1,245 @@ +# -*- coding: utf-8 -*- + +""" + (c) 2018 - Copyright Red Hat Inc + + Authors: + Pierre-Yves Chibon + +""" + +from __future__ import unicode_literals + + +import unittest +import sys +import os + +import json +from mock import patch, MagicMock + +sys.path.insert(0, os.path.join(os.path.dirname( + os.path.abspath(__file__)), '..')) + +import pagure.config +import pagure.lib.query +import pagure.lib.tasks +import tests + + +class PagureMergePrNoForkTest(tests.Modeltests): + """ Tests merging a PR in pagure when the fork no longer exists """ + + maxDiff = None + + def setUp(self): + """ Set up the environnment, ran before every tests. """ + super(PagureMergePrNoForkTest, self).setUp() + + tests.create_projects(self.session) + tests.create_projects_git( + os.path.join(self.path, "repos"), + bare=True + ) + tests.add_content_git_repo( + os.path.join(self.path, "repos", "test.git")) + tests.create_projects( + self.session, + is_fork=True, + hook_token_suffix='fork') + tests.create_projects_git( + os.path.join(self.path, "repos", "forks", "pingou"), + bare=True + ) + tests.add_content_git_repo( + os.path.join(self.path, "repos", "forks", "pingou", "test.git")) + tests.add_readme_git_repo( + os.path.join(self.path, "repos", "forks", "pingou", "test.git")) + project = pagure.lib.query.get_authorized_project( + self.session, 'test') + fork = pagure.lib.query.get_authorized_project( + self.session, + 'test', + user='pingou', + ) + + tests.create_tokens(self.session) + tests.create_tokens_acl(self.session) + + req = pagure.lib.query.new_pull_request( + session=self.session, + repo_from=fork, + branch_from='master', + repo_to=project, + branch_to='master', + title='test pull-request', + user='pingou', + ) + self.session.commit() + self.assertEqual(req.id, 1) + self.assertEqual(req.title, 'test pull-request') + + # Assert the PR is open + self.session = pagure.lib.query.create_session(self.dbpath) + project = pagure.lib.query.get_authorized_project( + self.session, 'test') + self.assertEqual(len(project.requests), 1) + self.assertEqual(project.requests[0].status, "Open") + # Check how the PR renders in the API and the UI + output = self.app.get('/api/0/test/pull-request/1') + self.assertEqual(output.status_code, 200) + output = self.app.get('/test/pull-request/1') + self.assertEqual(output.status_code, 200) + + @patch('pagure.lib.notify.send_email', MagicMock(return_value=True)) + def test_api_pull_request_diffstats(self): + """ Test the api_pull_request_merge method of the flask api. """ + + # Check the PR stats in the API + output = self.app.get( + '/api/0/test/pull-request/1/diffstats') + self.assertEqual(output.status_code, 200) + data = json.loads(output.get_data(as_text=True)) + self.assertDictEqual( + data, + { + "README.rst": { + "lines_added": 16, + "lines_removed": 0, + "new_id": "fb7093d2ba1cf8f80d10b45e4f15b10240727db5", + "old_id": "0000000000000000000000000000000000000000", + "old_path": "README.rst", + "status": "A" + } + } + ) + + @patch('pagure.lib.notify.send_email', MagicMock(return_value=True)) + def test_api_pull_request_diffstats_no_fork(self): + """ Test the api_pull_request_merge method of the flask api. """ + + pagure.lib.tasks.delete_project( + namespace=None, + name="test", + user="pingou", + action_user="pingou", + ) + + # Check the PR stats in the API + output = self.app.get( + '/api/0/test/pull-request/1/diffstats') + self.assertEqual(output.status_code, 200) + data = json.loads(output.get_data(as_text=True)) + self.assertDictEqual( + data, + { + "README.rst": { + "lines_added": 16, + "lines_removed": 0, + "new_id": "fb7093d2ba1cf8f80d10b45e4f15b10240727db5", + "old_id": "0000000000000000000000000000000000000000", + "old_path": "README.rst", + "status": "A" + } + } + ) + + @patch('pagure.lib.notify.send_email', MagicMock(return_value=True)) + def test_api_pull_request_merge(self): + """ Test the api_pull_request_merge method of the flask api. """ + + headers = {'Authorization': 'token aaabbbcccddd'} + + # Merge PR + output = self.app.post( + '/api/0/test/pull-request/1/merge', headers=headers) + self.assertEqual(output.status_code, 200) + data = json.loads(output.get_data(as_text=True)) + self.assertDictEqual( + data, + {"message": "Changes merged!"} + ) + + @patch('pagure.lib.notify.send_email', MagicMock(return_value=True)) + def test_api_pull_request_merge_no_fork(self): + """ Test the api_pull_request_merge method of the flask api. """ + + pagure.lib.tasks.delete_project( + namespace=None, + name="test", + user="pingou", + action_user="pingou", + ) + + headers = {'Authorization': 'token aaabbbcccddd'} + + # Merge PR + output = self.app.post( + '/api/0/test/pull-request/1/merge', headers=headers) + self.assertEqual(output.status_code, 200) + data = json.loads(output.get_data(as_text=True)) + self.assertDictEqual( + data, + {"message": "Changes merged!"} + ) + + @patch('pagure.lib.notify.send_email', MagicMock(return_value=True)) + def test_ui_pull_request_merge(self): + """ Test the api_pull_request_merge method of the flask UI. """ + + user = tests.FakeUser(username='pingou') + with tests.user_set(self.app.application, user): + data = { + 'csrf_token': self.get_csrf() + } + + # Merge PR + output = self.app.post( + '/test/pull-request/1/merge', data=data, follow_redirects=True) + self.assertEqual(output.status_code, 200) + output_text = output.get_data(as_text=True) + self.assertIn( + "Overview - test - Pagure", + output_text + ) + + self.session = pagure.lib.query.create_session(self.dbpath) + project = pagure.lib.query.get_authorized_project( + self.session, 'test') + self.assertEqual(project.requests[0].status, "Merged") + + @patch('pagure.lib.notify.send_email', MagicMock(return_value=True)) + def test_ui_pull_request_merge_no_fork(self): + """ Test the api_pull_request_merge method of the flask UI. """ + + pagure.lib.tasks.delete_project( + namespace=None, + name="test", + user="pingou", + action_user="pingou", + ) + + user = tests.FakeUser(username='pingou') + with tests.user_set(self.app.application, user): + data = { + 'csrf_token': self.get_csrf() + } + + # Merge PR + output = self.app.post( + '/test/pull-request/1/merge', data=data, follow_redirects=True) + self.assertEqual(output.status_code, 200) + output_text = output.get_data(as_text=True) + self.assertIn( + "Overview - test - Pagure", + output_text + ) + + self.session = pagure.lib.query.create_session(self.dbpath) + project = pagure.lib.query.get_authorized_project( + self.session, 'test') + self.assertEqual(project.requests[0].status, "Merged") + + +if __name__ == '__main__': + unittest.main(verbosity=2) From 28b763174d2cc6ba51a104389cef7563a4ea6d5f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 11 2018 15:14:10 +0000 Subject: [PATCH 4/7] Add testing the internal merge status endpoint with PR having no forks Signed-off-by: Pierre-Yves Chibon --- diff --git a/tests/test_pagure_merge_pr_no_fork.py b/tests/test_pagure_merge_pr_no_fork.py index 181df6a..cc7b4d0 100644 --- a/tests/test_pagure_merge_pr_no_fork.py +++ b/tests/test_pagure_merge_pr_no_fork.py @@ -240,6 +240,73 @@ class PagureMergePrNoForkTest(tests.Modeltests): self.session, 'test') self.assertEqual(project.requests[0].status, "Merged") + @patch('pagure.lib.notify.send_email', MagicMock(return_value=True)) + def test_internal_merge_status(self): + """ Test the api_pull_request_merge method of the flask UI. """ + + self.session = pagure.lib.query.create_session(self.dbpath) + project = pagure.lib.query.get_authorized_project( + self.session, 'test') + + user = tests.FakeUser(username='pingou') + with tests.user_set(self.app.application, user): + data = { + 'csrf_token': self.get_csrf(), + 'requestid': project.requests[0].uid, + } + + # Merge PR + output = self.app.post( + '/pv/pull-request/merge', data=data) + self.assertEqual(output.status_code, 200) + data = json.loads(output.get_data(as_text=True)) + self.assertDictEqual( + data, + { + u'code': u'FFORWARD', + u'message': u'The pull-request can be merged and ' + 'fast-forwarded', + u'short_code': u'Ok' + } + ) + + @patch('pagure.lib.notify.send_email', MagicMock(return_value=True)) + def test_internal_merge_status_no_fork(self): + """ Test the api_pull_request_merge method of the flask UI. """ + + pagure.lib.tasks.delete_project( + namespace=None, + name="test", + user="pingou", + action_user="pingou", + ) + + self.session = pagure.lib.query.create_session(self.dbpath) + project = pagure.lib.query.get_authorized_project( + self.session, 'test') + + user = tests.FakeUser(username='pingou') + with tests.user_set(self.app.application, user): + data = { + 'csrf_token': self.get_csrf(), + 'requestid': project.requests[0].uid, + } + + # Merge PR + output = self.app.post( + '/pv/pull-request/merge', data=data) + self.assertEqual(output.status_code, 200) + data = json.loads(output.get_data(as_text=True)) + self.assertDictEqual( + data, + { + u'code': u'FFORWARD', + u'message': u'The pull-request can be merged and ' + 'fast-forwarded', + u'short_code': u'Ok' + } + ) + if __name__ == '__main__': unittest.main(verbosity=2) From 017f493a191e70a4a04fab4e720970a44f562c00 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 11 2018 15:40:32 +0000 Subject: [PATCH 5/7] Bail on local PR without project_from when linking PRs to tickets Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/tasks.py b/pagure/lib/tasks.py index fc6623a..5cae1d2 100644 --- a/pagure/lib/tasks.py +++ b/pagure/lib/tasks.py @@ -1037,10 +1037,15 @@ def link_pr_to_ticket(self, session, pr_uid): request.remote_git, request.branch_from ) parentpath = pagure.utils.get_repo_path(request.project) - else: + elif request.project_from: repo_from = request.project_from repopath = pagure.utils.get_repo_path(repo_from) parentpath = get_parent_repo_path(repo_from) + else: + _log.info( + "LINK_PR_TO_TICKET: PR neither remote, nor with a " + "project_from, bailing: %s" % pr_uid) + return repo_obj = pygit2.Repository(repopath) orig_repo = pygit2.Repository(parentpath) From d91c53e57b40b77706a8872e7c06b929c55e3a0b Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 12 2018 08:56:40 +0000 Subject: [PATCH 6/7] Increase the logging in when rebasing a pull-request When testing rebasing a PR that had no project_from it was quite hard to follow up what was going on and why the rebasing wasn't working as expected. With these new logs entries, it gets much easier. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 9a11472..f1cbe86 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -1822,11 +1822,17 @@ def rebase_pull_request(request, username): # Get the fork repopath = pagure.utils.get_repo_path(request.project_from) else: + _log.info( + "PR is neither from a remote git repo or an existing local " + "repo, bailing") return if not request.project or not os.path.exists( pagure.utils.get_repo_path(request.project) ): + _log.info( + "Could not find the targeted git repository for %s", + request.project.fullname) raise pagure.exceptions.PagureException( "Could not find the targeted git repository for %s" % request.project.fullname @@ -1853,10 +1859,12 @@ def rebase_pull_request(request, username): remote.fetch() def _run_command(command): + _log.info("Running command: %s", command) try: out = subprocess.check_output( command, cwd=tempclone.repopath, stderr=subprocess.STDOUT ) + _log.info(" command ran successfully") _log.debug("Output: %s" % out) except subprocess.CalledProcessError as err: _log.debug( diff --git a/pagure/lib/tasks.py b/pagure/lib/tasks.py index 5cae1d2..6b3d200 100644 --- a/pagure/lib/tasks.py +++ b/pagure/lib/tasks.py @@ -711,15 +711,17 @@ def rebase_pull_request( project = pagure.lib.query._get_project( session, namespace=namespace, name=name, user=user ) + _log.info("Rebase PR: %s of project: %s" % (requestid, project.fullname)) with project.lock("WORKER"): request = pagure.lib.query.search_pull_requests( session, project_id=project.id, requestid=requestid ) _log.debug( - "Rebasing pull-request: %s/#%s", + "Rebasing pull-request: %s#%s, uid: %s", request.project.fullname, request.id, + request.uid, ) pagure.lib.git.rebase_pull_request(request, user_rebaser) From 924605344d9ed7e00d33089bb7adcf5a6ae66c16 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 12 2018 08:56:40 +0000 Subject: [PATCH 7/7] Tweak the logging when sending blinker signals Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/notify.py b/pagure/lib/notify.py index e782483..2ee36b8 100644 --- a/pagure/lib/notify.py +++ b/pagure/lib/notify.py @@ -100,9 +100,8 @@ def stomp_publish(topic, message): def blinker_publish(topic, message): - _log.info("Sending blinker signal to: pagure") + _log.info("Sending blinker signal to: pagure - topic: %s", topic) ready = blinker.signal("pagure") - _log.info(" Blinker payload: %s" % message) ready.send("pagure", topic=topic, message=message)