#3891 Create pseudo repos by creating an initial clone
Closed 4 years ago by pingou. Opened 5 years ago by puiterwijk.
puiterwijk/pagure manyfiles  into  master

file modified
+2 -34
@@ -900,42 +900,10 @@ 

              # pygit2.clone_repository does not have the "branches" attribute.

              self.repo = pygit2.Repository(self.repopath)

          else:

-             repourl, regioninfo = self._project.repospanner_repo_info(

-                 self._repotype

+             self.repo = self._project._repospanner_clone(

+                 self._repotype, False, self.repopath

              )

  

-             command = [

-                 "git",

-                 "-c",

-                 "protocol.ext.allow=always",

-                 "clone",

-                 "ext::%s %s"

-                 % (

-                     pagure_config["REPOBRIDGE_BINARY"],

-                     self._project._repospanner_repo_name(self._repotype),

-                 ),

-                 self.repopath,

-             ]

-             environ = os.environ.copy()

-             environ.update(

-                 {

-                     "USER": "pagure",

-                     "REPOBRIDGE_CONFIG": ":environment:",

-                     "REPOBRIDGE_BASEURL": regioninfo["url"],

-                     "REPOBRIDGE_CA": regioninfo["ca"],

-                     "REPOBRIDGE_CERT": regioninfo["push_cert"]["cert"],

-                     "REPOBRIDGE_KEY": regioninfo["push_cert"]["key"],

-                 }

-             )

-             with open(os.devnull, "w") as devnull:

-                 subprocess.check_call(

-                     command,

-                     stdout=devnull,

-                     stderr=subprocess.STDOUT,

-                     env=environ,

-                 )

-             self.repo = pygit2.Repository(self.repopath)

- 

          # Make sure that all remote refs are mapped to local ones.

          for branchname in self.repo.branches.remote:

              localname = branchname.replace("origin/", "")

file modified
+45 -10
@@ -21,6 +21,7 @@ 

  import operator

  import re

  import pygit2

+ import subprocess

  import os

  

  import six
@@ -540,6 +541,49 @@ 

              self.fullname,

          )

  

+     def _repospanner_clone(self, repotype, set_config, target):

+         """ Create a clone of a repoSpanner repo to filesystem.

+ 

+         """

+         repourl, regioninfo = self.repospanner_repo_info(repotype)

+ 

+         command = [

+             "git",

+             "-c",

+             "protocol.ext.allow=always",

+             "clone",

+             "ext::%s %s"

+             % (

+                 pagure_config["REPOBRIDGE_BINARY"],

+                 self._repospanner_repo_name(repotype),

+             ),

+             target,

+         ]

+         environ = os.environ.copy()

+         environ.update(

+             {

+                 "USER": "pagure",

+                 "REPOBRIDGE_CONFIG": ":environment:",

+                 "REPOBRIDGE_BASEURL": regioninfo["url"],

+                 "REPOBRIDGE_CA": regioninfo["ca"],

+                 "REPOBRIDGE_CERT": regioninfo["push_cert"]["cert"],

+                 "REPOBRIDGE_KEY": regioninfo["push_cert"]["key"],

+             }

+         )

+         with open(os.devnull, "w") as devnull:

+             subprocess.check_call(

+                 command, stdout=devnull, stderr=subprocess.STDOUT, env=environ

+             )

+ 

+         repo = pygit2.Repository(target)

+         if set_config:

+             repo.config["repospanner.url"] = repourl

+             repo.config["repospanner.cert"] = regioninfo["push_cert"]["cert"]

+             repo.config["repospanner.key"] = regioninfo["push_cert"]["key"]

+             repo.config["repospanner.cacert"] = regioninfo["ca"]

+             repo.config["repospanner.enabled"] = True

+         return repo

+ 

      def repopath(self, repotype):

          """ Return the full repository path of the git repo on the filesystem.

  
@@ -552,16 +596,7 @@ 

                  pagure_config["REPOSPANNER_PSEUDO_FOLDER"], repotype, self.path

              )

              if not os.path.exists(pseudopath):

-                 repourl, regioninfo = self.repospanner_repo_info(repotype)

-                 fake = pygit2.init_repository(pseudopath, bare=True)

-                 fake.config["repospanner.url"] = repourl

-                 fake.config["repospanner.cert"] = regioninfo["push_cert"][

-                     "cert"

-                 ]

-                 fake.config["repospanner.key"] = regioninfo["push_cert"]["key"]

-                 fake.config["repospanner.cacert"] = regioninfo["ca"]

-                 fake.config["repospanner.enabled"] = True

-                 del fake

+                 self._repospanner_clone(repotype, True, pseudopath)

              return pseudopath

  

          maindir = None

2 new commits added

  • Create pseudo repos by creating an initial clone
  • Implement pulling and pushing via repobridge instead of HTTPS
5 years ago

This will need some more finetuning and catching of edge cases.

rebased onto 6c0e3b2

5 years ago

This seems to conflict now. What do we want to do with it? Rebase, add tests and get it in or just close it for now?

I believe this can be closed now.

Pull-Request has been closed by pingou

4 years ago