#4214 Do not notify about invalid identifier if none is specified
Merged 2 years ago by pingou. Opened 2 years ago by pingou.

file modified
+7 -4
@@ -398,10 +398,13 @@ 

          return flask.redirect(return_point)

  

      admins = pagure_config["ADMIN_GROUP"]

-     if isinstance(admins, list):

-         admins = set(admins)

-     else:  # pragma: no cover

-         admins = set([admins])

+     if admins:

+         if isinstance(admins, list):

+             admins = set(admins)

+         else:  # pragma: no cover

+             admins = set([admins])

+     else:

+         admins = set()

  

      if auth in ["fas", "openid"]:

          from pagure.ui.fas_login import FAS

file modified
+6 -5
@@ -962,11 +962,12 @@ 

                  if not repo_obj.head_is_unborn:

                      branchname = repo_obj.head.shorthand

                      commit = repo_obj[repo_obj.head.target]

-                     flask.flash(

-                         "'%s' not found in the git repository, going back to: "

-                         "%s" % (identifier, branchname),

-                         "error",

-                     )

+                     if identifier:

+                         flask.flash(

+                             "'%s' not found in the git repository, going back "

+                             "to: %s" % (identifier, branchname),

+                             "error",

+                         )

          # If we're arriving here from the release page, we may have a Tag

          # where we expected a commit, in this case, get the actual commit

          if isinstance(commit, pygit2.Tag):

@@ -3175,6 +3175,30 @@ 

          self.assertFalse(

              'No content found in this repository' in output_text)

  

+         # View tree, no identifier:

+         output = self.app.get('/test/tree/')

+         self.assertEqual(output.status_code, 200)

+         output_text = output.get_data(as_text=True)

+         self.assertIn('<title>Tree - test - Pagure</title>', output_text)

+         self.assertIn('README.rst', output_text)

+         self.assertNotIn(

+             'No content found in this repository', output_text)

+         self.assertNotIn(

+             "&#39;None&#39; not found in the git repository, going back to: "

+             "master", output_text)

+ 

+         # View tree, invalid identifier:

+         output = self.app.get('/test/tree/invalid')

+         self.assertEqual(output.status_code, 200)

+         output_text = output.get_data(as_text=True)

+         self.assertIn('<title>Tree - test - Pagure</title>', output_text)

+         self.assertIn('README.rst', output_text)

+         self.assertNotIn(

+             'No content found in this repository', output_text)

+         self.assertIn(

+             "&#39;invalid&#39; not found in the git repository, going back "

+             "to: master", output_text)

+ 

          # View tree by branch

          output = self.app.get('/test/tree/master')

          self.assertEqual(output.status_code, 200)