Пример #1
0
  def mirrorRepo(self, name, url):
    """
    Mirror a repo.
    Note that only the FileSystem output supports non-compressed mode.
    """

    if not self.compress_repos:
      raise Exception("Non-compressed mode not implemented yet")

    # clone the git repo

    path = self.tmpPath + os.path.sep + name + '.git'

    self.logger.debug('Cloning git repo {url} to {path}'.format(
      url=url, path=path
    ))
    result = call(['git', 'clone', '--mirror', url, path])

    if result[0] != 0:
      raise Exception('Could not clone {repo}: {o}'.format(
        repo=url, o=result[1] + "\n\n" + result[2]
      ))
    
    fileName = name + '.git'
    
    if self.compress_repos != 'none':
        # Repo should be compressed.
        # We only have to write a single file here.
      
        self.logger.debug('Compressing repo into archive...')
        fileName += '.tar'

        if self.compress_repos != 'tar': fileName += '.' + self.compress_repos
        compression = self.compress_repos if self.compress_repos != 'tar' else None
        
        fileObject = self.output.getStream(fileName, name, 'w')
        createArchive(path, compression, fileObject)
        fileObject.close()
    else:
        # Copy the repo file by file.
        self.output.setFromLocalPath(fileName, path, name)
Пример #2
0
    def mirrorRepo(self, name, url):
        """
    Mirror a repo.
    Note that only the FileSystem output supports non-compressed mode.
    """

        if not self.compress_repos:
            raise Exception("Non-compressed mode not implemented yet")

        # clone the git repo

        path = self.tmpPath + os.path.sep + name + '.git'

        self.logger.debug('Cloning git repo {url} to {path}'.format(url=url,
                                                                    path=path))
        result = call(['git', 'clone', '--mirror', url, path])

        if result[0] != 0:
            raise Exception('Could not clone {repo}: {o}'.format(
                repo=url, o=result[1] + "\n\n" + result[2]))

        fileName = name + '.git'

        if self.compress_repos != 'none':
            # Repo should be compressed.
            # We only have to write a single file here.

            self.logger.debug('Compressing repo into archive...')
            fileName += '.tar'

            if self.compress_repos != 'tar':
                fileName += '.' + self.compress_repos
            compression = self.compress_repos if self.compress_repos != 'tar' else None

            fileObject = self.output.getStream(fileName, name, 'w')
            createArchive(path, compression, fileObject)
            fileObject.close()
        else:
            # Copy the repo file by file.
            self.output.setFromLocalPath(fileName, path, name)
Пример #3
0
 def checkForGit(self):
     if call(['git', '-h'])[0] != 0:
         raise Exception('Git command is not in path')
Пример #4
0
 def checkForGit(self):
   if call(['git', '-h'])[0] != 0:
     raise Exception('Git command is not in path')