Ejemplo n.º 1
0
    def handle(self, **options):
        storage = git_storage.GitStorage()
        repository = storage.repository

        # Safely ignore pushing to another branch
        if repository.head.name != options['refname']:
            if options['verbosity']:
                self.stdout.write(
                    'Ignoring unexposed branch "{}", exiting.'.format(
                        options['refname']))
            return

        known_blobs = set(models.get_blob_metadata_model().objects.values_list(
            'id', flat=True))
        counter_before = len(known_blobs)

        start_oid = options['start_oid']
        end_oid = options['end_oid']
        if options['verbosity']:
            self.stdout.write("Synchronising metadata from {} to {}...".format(
                start_oid, end_oid))

        self.walk(repository, start_oid, end_oid, known_blobs)

        if options['verbosity']:
            counter_after = len(known_blobs)
            self.stdout.write(
                "Done, {} metadata created.".format(counter_after -
                                                    counter_before))
 def sync_tree(self, repository, tree, known_blobs):
     """Recursively traverse a tree and create metadata for every of its blobs."""
     for entry in tree:
         if entry.type == "tree":
             self.sync_tree(repository, repository[entry.id], known_blobs)
         elif entry.type == "blob":
             if entry.hex in known_blobs:
                 continue
             blob = repository[entry.id]
             metadata = models.get_blob_metadata_model()(id=entry.hex, size=blob.size)
             metadata.save()
             # Now we have saved, the instance have an ID for relations
             metadata.fill(repository, entry.name, blob)
             metadata.save()
             known_blobs.add(entry.hex)
Ejemplo n.º 3
0
 def sync_tree(self, repository, tree, known_blobs):
     """Recursively traverse a tree and create metadata for every of its blobs."""
     for entry in tree:
         if entry.type == "tree":
             self.sync_tree(repository, repository[entry.id], known_blobs)
         elif entry.type == "blob":
             if entry.hex in known_blobs:
                 continue
             blob = repository[entry.id]
             metadata = models.get_blob_metadata_model()(id=entry.hex,
                                                         size=blob.size)
             metadata.save()
             # Now we have saved, the instance have an ID for relations
             metadata.fill(repository, entry.name, blob)
             metadata.save()
             known_blobs.add(entry.hex)
    def handle(self, **options):
        storage = git_storage.GitStorage()
        repository = storage.repository

        # Safely ignore pushing to another branch
        if repository.head.name != options['refname']:
            if options['verbosity']:
                self.stdout.write('Ignoring unexposed branch "{}", exiting.'.format(options['refname']))
            return

        known_blobs = set(models.get_blob_metadata_model().objects.values_list('id', flat=True))
        counter_before = len(known_blobs)

        start_oid = options['start_oid']
        end_oid = options['end_oid']
        if options['verbosity']:
            self.stdout.write("Synchronising metadata from {} to {}...".format(start_oid, end_oid))

        self.walk(repository, start_oid, end_oid, known_blobs)

        if options['verbosity']:
            counter_after = len(known_blobs)
            self.stdout.write("Done, {} metadata created.".format(counter_after - counter_before))