#5023 Forward the username when updating the pull-request
Merged 3 years ago by pingou. Opened 3 years ago by pingou.

file modified
+10 -3
@@ -224,7 +224,7 @@ 

  

  

  def inform_pull_request_urls(

-     session, project, commits, refname, default_branch

+     session, project, commits, refname, default_branch, username

  ):

      """ Inform the user about the URLs to open a new pull-request or visit

      the existing one.
@@ -260,7 +260,9 @@ 

          seen = len(prs) != 0

          for pr in prs:

              # Refresh the PR in the db and everywhere else where needed

-             pagure.lib.tasks.update_pull_request.delay(pr.uid)

+             pagure.lib.tasks.update_pull_request.delay(

+                 pr.uid, username=username

+             )

  

              # Link tickets with pull-requests if the commit mentions it

              pagure.lib.tasks.link_pr_to_ticket.delay(pr.uid)
@@ -429,7 +431,12 @@ 

              # open a new pr or review the existing one

              pr_uids.extend(

                  inform_pull_request_urls(

-                     session, project, commits, refname, default_branch

+                     session,

+                     project,

+                     commits,

+                     refname,

+                     default_branch,

+                     username,

                  )

              )

  

@@ -227,9 +227,9 @@ 

              output_text = output.get_data(as_text=True)

              self.assertIn("rebased onto", output_text)

              repo = pagure.lib.query._get_project(self.session, "test")

-             # This should be pingou, but we have some bug that adds the

-             # rebase message as PR author instead of rebaser

-             self.assertEqual(repo.requests[0].comments[0].user.username, "foo")

+             self.assertEqual(

+                 repo.requests[0].comments[0].user.username, "pingou"

+             )

  

      def test_rebase_api_ui_logged_in_different_user(self):

          """ Test the rebase PR API endpoint when logged in from the UI and
@@ -295,9 +295,7 @@ 

              output_text = output.get_data(as_text=True)

              self.assertIn("rebased onto", output_text)

              repo = pagure.lib.query._get_project(self.session, "test")

-             # This should be bar, but we have some bug that adds the

-             # rebase message as PR author instead of rebaser

-             self.assertEqual(repo.requests[0].comments[0].user.username, "foo")

+             self.assertEqual(repo.requests[0].comments[0].user.username, "bar")

  

      def test_rebase_api_ui_logged_in_pull_request_author(self):

          """ Test the rebase PR API endpoint when logged in from the UI and
@@ -623,9 +621,9 @@ 

              output_text = output.get_data(as_text=True)

              self.assertIn("rebased onto", output_text)

              repo = pagure.lib.query._get_project(self.session, "test")

-             # This should be pingou, but we have some bug that adds the

-             # rebase message as PR author instead of rebaser

-             self.assertEqual(repo.requests[0].comments[0].user.username, "foo")

+             self.assertEqual(

+                 repo.requests[0].comments[0].user.username, "pingou"

+             )

  

      def test_rebase_api_ui_logged_in_different_user(self):

          """ Test the rebase PR API endpoint when logged in from the UI and
@@ -713,9 +711,7 @@ 

              output_text = output.get_data(as_text=True)

              self.assertIn("rebased onto", output_text)

              repo = pagure.lib.query._get_project(self.session, "test")

-             # This should be bar, but we have some bug that adds the

-             # rebase message as PR author instead of rebaser

-             self.assertEqual(repo.requests[0].comments[0].user.username, "foo")

+             self.assertEqual(repo.requests[0].comments[0].user.username, "bar")

  

      def test_rebase_api_api_logged_in(self):

          """ Test the rebase PR API endpoint when using an API token and

This way the update of the PR is linked to the person who made the push
which solves the bug we had where when a PR was rebased it was shown as
having been rebased by the author of the PR rather than the person who
actually rebased the PR.

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

Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr

rebased onto 522a66674360255b7807c7e07dc4fee6c9909ea3

3 years ago

rebased onto 69a50daa01b74e332fed6d2f9132858547c2541d

3 years ago

rebased onto 38ee917

3 years ago

pretty please pagure-ci rebuild

3 years ago

Pull-Request has been merged by pingou

3 years ago