Browse Source

use refspec to fetch exact copy of repositories

Tobias Simetsreiter 5 years ago
parent
commit
9b82e1fe80
1 changed files with 8 additions and 6 deletions
  1. 8 6
      gitmirror.py

+ 8 - 6
gitmirror.py

@@ -12,9 +12,9 @@ COM=sys.argv[0]
 def parser():
     from argparse import ArgumentParser
     p = ArgumentParser()
-    p.add_argument("source")
-    p.add_argument("-b", "--base", default="./repositories",help="local basedir for mirror")
-    p.add_argument("-t", "--threads", default=4, type=int,help="number of worker threads")
+    p.add_argument("source", help="git origin that will be used to fetch repos. Should support 'ssh <source> info'")
+    p.add_argument("-b", "--base", default="./repositories", help="local basedir for mirror")
+    p.add_argument("-t", "--threads", default=4, type=int, help="number of worker threads")
     return p
 
 def main():
@@ -62,12 +62,12 @@ class Repo():
 
             self.init()
 
-        self.update_local()
+        self.fetch()
 
         return True
 
-    def update_local(self):
-        proc = run(["git","fetch","-p","origin"], cwd=self.local_path)
+    def fetch(self):
+        proc = run(["git","fetch","-p","origin","refs/*:refs/*"], cwd=self.local_path)
         if not proc.returncode == 0:
             print(f"Error: {proc}, {local_repo}")
             _rm(self.local_path)
@@ -144,6 +144,8 @@ def map_threaded(target, args=[], threads=4, debug=None):
     while fillThread.is_alive():
         yield outq.get(block=True)
     fillThread.join()
+    while not outq.empty():
+        yield outq.get(block=True)
     for job in jobs:
         job.join()
     while not outq.empty():