code: def clone_repo(self, repo_name, remote_repo, ref):
          
          self.shallow_clone = False
          dirname, repo = self.set_up_clone(repo_name, remote_repo)
          if os.path.isdir("%s/.git" % dirname):
              log.debug("Updating %s to %s", repo.download_location, dirname)
              self.executor(
                  "cd %s && git checkout master" % dirname)
              self.pull(dirname)
          else:
              log.debug("Cloning %s to %s", repo.download_location, dirname)
              self.executor(
                  "git clone %s %s" % (repo.download_location, dirname))
  
          if remote_repo is not None:
              log.debug("Pulling remote branch from %s", remote_repo.url)
              self.add_remote(dirname,
                              remote_repo.name,
                              remote_repo.url)
              self.pull(dirname)
          return repo
docs: Clones the given repo and returns the Repository object.