#2981 Fix the rtd hook
Merged 6 years ago by pingou. Opened 6 years ago by cverna.
cverna/pagure fix_rtd_hook  into  master

file modified
+1 -1
@@ -16,7 +16,7 @@ 

        - type: volume

          source: ../lcl/repos

          target: /repos

-         read_only: true

+         read_only: false

        - type: volume

          source: ../lcl/attachments

          target: /attachments

@@ -22,8 +22,7 @@ 

  import pagure.lib.link  # noqa: E402

  import pagure.lib.plugins  # noqa: E402

  

- 

- _config = pagure.config.config.reload_config()

+ _config = pagure.config.config

  abspath = os.path.abspath(os.environ['GIT_DIR'])

  

  
@@ -31,18 +30,22 @@ 

      reponame = pagure.lib.git.get_repo_name(abspath)

      username = pagure.lib.git.get_username(abspath)

      namespace = pagure.lib.git.get_repo_namespace(abspath)

+     session = pagure.lib.create_session(_config['DB_URL'])

      if _config.get('HOOK_DEBUG', False):

          print('repo:     ', reponame)

          print('user:     ', username)

          print('namespace:', namespace)

  

      repo = pagure.lib.get_authorized_project(

-         pagure.SESSION, reponame, user=username, namespace=namespace)

+         session, reponame, user=username, namespace=namespace)

      if not repo:

          print('Unknown repo %s of username: %s' % (reponame, username))

+         session.close()

          sys.exit(1)

  

-     pagure.lib.plugins.get_plugin('Read the Doc')

+     hook = pagure.lib.plugins.get_plugin('Read the Doc')

+     hook.db_object()

+ 

      # Get the list of branches

      branches = [

          branch.strip()
@@ -75,6 +78,8 @@ 

                    repo.rtd_hook.project_name.strip()))

              requests.post(url)

  

+     session.close()

+ 

  

  def main(args):

      run_as_post_receive_hook()

Fixes #2308

We need to make sure to call db_object() on the hook so that we can access the rtd_hook attribute.

This PR also fixes some issues coming from the re architecture.

Let's create the session within the function so we can close it at the end

2 new commits added

  • Make it possible for the webapp to write in the repos
  • Fix the rtd hook by creating the database relation
6 years ago

Seeing the next line, I doubt we reach the one you're referring to ;-)

rebased onto 40d2e3e

6 years ago

Pull-Request has been merged by pingou

6 years ago