#4626 Send oldrev as old_commit for git.receive event
Merged 2 years ago by pingou. Opened 2 years ago by fbo.
fbo/pagure oldrev  into  master

file modified
+12 -2
@@ -160,7 +160,9 @@ 

          send_webhook_notifications(project, topic, msg)

  

  

- def send_notifications(session, project, repodir, user, refname, revs, forced):

+ def send_notifications(

+     session, project, repodir, user, refname, revs, forced, oldrev

+ ):

      """ Send out-going notifications about the commits that have just been

      pushed.

      """
@@ -187,6 +189,7 @@ 

              total_commits=len(revs),

              start_commit=revs[0],

              end_commit=revs[-1],

+             old_commit=oldrev,

              branch=refname,

              forced=forced,

              authors=list(authors),
@@ -402,7 +405,14 @@ 

              # This one is sending fedmsg and web-hook notifications for project

              # that set them up

              send_notifications(

-                 session, project, repodir, username, refname, commits, forced

+                 session,

+                 project,

+                 repodir,

+                 username,

+                 refname,

+                 commits,

+                 forced,

+                 oldrev,

              )

  

              # Now display to the user if this isn't the default branch links to

@@ -62,6 +62,7 @@ 

  

      @mock.patch("pagure.hooks.default.send_fedmsg_notifications")

      def test_send_notifications(self, fedmsg):

+         oldrev = "9e5f51c951c6cab20fe81419320ed740533e2f2f"

          project, sha = self.init_test_repo()

          pagure.hooks.default.send_notifications(

              self.session,
@@ -71,12 +72,14 @@ 

              "master",

              [sha],

              False,

+             oldrev,

          )

          (_, args, kwargs) = fedmsg.mock_calls[0]

          self.assertEqual(args[1], "git.receive")

          self.assertEqual(args[2]["repo"]["name"], "test")

          self.assertEqual(args[2]["start_commit"], sha)

          self.assertEqual(args[2]["forced"], False)

+         self.assertEqual(args[2]["old_commit"], oldrev)

  

  

  if __name__ == "__main__":

Some events consumers like Zuul expects to find the previous
rev of the tip of the branch. This commit send the oldrev
part of the event's message.

pretty please pagure-ci rebuild

2 years ago

pretty please pagure-ci rebuild

2 years ago

pretty please pagure-ci rebuild

2 years ago

Pull-Request has been merged by pingou

2 years ago