示例#1
0
文件: repos.py 项目: bavaria95/jens
def _create_new_repositories(settings, new_repositories, partition, definition,
                             inventory, desired):
    created = []
    for repository in new_repositories:
        logging.info("Cloning and expanding %s/%s..." %
                     (partition, repository))
        bare_path = _compose_bare_repository_path(settings, repository,
                                                  partition)
        bare_url = definition['repositories'][partition][repository]
        try:
            git.clone(bare_path, bare_url, bare=True)
        except JensGitError, error:
            logging.error("Unable to clone '%s' (%s). Skipping." %
                          (repository, error))
            if os.path.exists(bare_path):
                shutil.rmtree(bare_path)
            continue
        try:
            refs = git.get_refs(bare_path).keys()
        except JensGitError, error:
            logging.error("Unable to get refs of '%s' (%s). Skipping." %
                          (repository, error))
            shutil.rmtree(bare_path)
            logging.debug("Bare repository %s has been removed" % bare_path)
            continue
示例#2
0
文件: repos.py 项目: bavaria95/jens
def _expand_clones(settings, partition, name, inventory, inventory_lock,
                   new_refs, moved_refs, deleted_refs):
    bare_path = _compose_bare_repository_path(settings, name, partition)
    if new_refs:
        logging.debug("Processing new refs of %s/%s (%s)..." % \
            (partition, name, new_refs))
    for refname in new_refs:
        clone_path = _compose_clone_repository_path(settings, name, partition,
                                                    refname)
        logging.info("Populating new ref '%s'" % clone_path)
        try:
            if ref_is_commit(settings, refname):
                commit_id = refname.replace(settings.HASHPREFIX, '')
                logging.debug("Will create a clone pointing to '%s'" %
                              commit_id)
                git.clone(clone_path, "%s" % bare_path, shared=True)
                git.reset(clone_path, commit_id, hard=True)
            else:
                git.clone(clone_path, "%s" % bare_path, branch=refname)
            # Needs reset so the proxy notices about the change on the mutable
            # http://docs.python.org/2.7/library/multiprocessing.html#managers
            # Locking on the assignment is guarateed by the library, but
            # additional locking is needed as A = A + 1 is a critical section.
            if inventory_lock:
                inventory_lock.acquire()
            inventory[name] += [refname]
            if inventory_lock:
                inventory_lock.release()
        except JensGitError, error:
            if os.path.isdir(clone_path):
                shutil.rmtree(clone_path)
            logging.error("Unable to create clone '%s' (%s)" % \
                (clone_path, error))
示例#3
0
文件: repos.py 项目: nbarrientos/jens
def _expand_clones(settings, partition, name, inventory, inventory_lock,
        new_refs, moved_refs, deleted_refs):
    bare_path = _compose_bare_repository_path(settings,
                name, partition) 
    if new_refs:
        logging.debug("Processing new refs of %s/%s (%s)..." % \
            (partition, name, new_refs))
    for refname in new_refs:
        clone_path = _compose_clone_repository_path(settings,
                name, partition, refname)
        logging.info("Populating new ref '%s'" % clone_path)
        try:
            if ref_is_commit(settings, refname):
                commit_id = refname.replace(settings.HASHPREFIX, '')
                logging.debug("Will create a clone pointing to '%s'" % commit_id)
                git.clone(clone_path, "%s" % bare_path, shared=True)
                git.reset(clone_path, commit_id, hard=True)
            else:
                git.clone(clone_path, "%s" % bare_path, branch=refname)
            # Needs reset so the proxy notices about the change on the mutable
            # http://docs.python.org/2.7/library/multiprocessing.html#managers
            # Locking on the assignment is guarateed by the library, but
            # additional locking is needed as A = A + 1 is a critical section.
            if inventory_lock:
                inventory_lock.acquire()
            inventory[name] += [refname]
            if inventory_lock:
                inventory_lock.release()
        except JensGitError, error:
            if os.path.isdir(clone_path):
                shutil.rmtree(clone_path)
            logging.error("Unable to create clone '%s' (%s)" % \
                (clone_path, error))
示例#4
0
    def setUp(self):
        super(MetadataTest, self).setUp()

        (self.environments_bare, self.environments) = \
            create_fake_repository(self.settings, self.sandbox_path)
        shutil.rmtree(self.settings.ENV_METADATADIR)
        clone(self.settings.ENV_METADATADIR, self.environments_bare, \
            branch='master')

        (self.repositories_bare, self.repositories) = \
            create_fake_repository(self.settings, self.sandbox_path)
        shutil.rmtree(self.settings.REPO_METADATADIR)
        clone(self.settings.REPO_METADATADIR, self.repositories_bare, \
            branch='master')
示例#5
0
    def setUp(self):
        super(MetadataTest, self).setUp()

        (self.environments_bare, self.environments) = \
            create_fake_repository(self.settings, self.sandbox_path)
        shutil.rmtree(self.settings.ENV_METADATADIR)
        clone(self.settings.ENV_METADATADIR, self.environments_bare, \
            branch='master')

        (self.repositories_bare, self.repositories) = \
            create_fake_repository(self.settings, self.sandbox_path)
        shutil.rmtree(self.settings.REPO_METADATADIR)
        clone(self.settings.REPO_METADATADIR, self.repositories_bare, \
            branch='master')
示例#6
0
文件: repos.py 项目: nbarrientos/jens
def _create_new_repositories(settings, new_repositories, partition,
            definition, inventory, desired):
    created = []
    for repository in new_repositories:
        logging.info("Cloning and expanding %s/%s..." % (partition, repository))
        bare_path = _compose_bare_repository_path(settings,
            repository, partition) 
        bare_url = definition['repositories'][partition][repository]
        try:
            git.clone(bare_path, bare_url, bare=True)
        except JensGitError, error:
            logging.error("Unable to clone '%s' (%s). Skipping." % (repository, error))
            if os.path.exists(bare_path):
                shutil.rmtree(bare_path)
            continue
        try:
            refs = git.get_refs(bare_path).keys()
        except JensGitError, error:
            logging.error("Unable to get refs of '%s' (%s). Skipping." % (repository, error))
            shutil.rmtree(bare_path)
            logging.debug("Bare repository %s has been removed" % bare_path)
            continue