How to use the isomorphic-git.clone function in isomorphic-git

To help you get started, weโ€™ve selected a few isomorphic-git examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mizchi / next-editor / src / domain / git / commands / cloneRepository.ts View on Github external
onMessage?: (message: string) => void
    depth?: number
    singleBranch?: boolean
  } = {}
): Promise {
  const emitter = new EventEmitter()

  if (options.onProgress) {
    emitter.on("progress", options.onProgress)
  }
  if (options.onMessage) {
    emitter.on("message", options.onMessage)
  }

  // not async for test
  const clonePromise = git.clone({
    dir: projectRoot,
    url: cloneDest,
    ref: "master",
    emitter,
    ...options
  })

  while (true) {
    await delay(1000)
    try {
      const list = await git.listFiles({ dir: projectRoot })
      const e = await git.status({ dir: projectRoot, filepath: list[0] })
      console.log("status correct with", e)
      break
    } catch (e) {
      console.log("wait...", e.message)
github telstra / openapi-platform / packages / git-util / src / index.ts View on Github external
remoteSdkUrl: string,
  options,
) {
  // TODO: Rather than taking a logger, just provide callbacks
  const { logger } = options;
  const repoDir = await makeTempDir('repo');
  try {
    /*
      TODO: This isn't great. We clone the repo everytime we generate an SDK.
      Preferably, we'd only do it once or have some kind of cache for repos we've already cloned.
      Would have to probably git reset --hard HEAD~ or something before adding the SDK to the cloned repo
      just to make sure there aren't any stray files lying around in the cached repo.
    */
    // TODO: Should also be able to configure which branch to checkout, maybe?
    logger.verbose(`Cloning ${remoteSdkUrl} into ${repoDir}`);
    await clone({
      ref: gitInfo.branch,
      dir: repoDir,
      // Could use mz/fs but I don't trust it guarentees compatibility with isomorphic git
      fs: oldFs,
      url: gitInfo.repoUrl,
      singleBranch: true,
      depth: 1,
      ...gitInfo.auth,
    });

    await migrateSdkIntoLocalRepo(repoDir, remoteSdkUrl, options);
    const addedPaths = await getAllStageableFilepathsInRepo(repoDir);
    logger.verbose(`Staging ${addedPaths.length} paths`);
    for (const addedPath of addedPaths) {
      const relativeFilePath = relative(repoDir, addedPath);
      // TODO: Got a lot of "oldFs: fs", maybe make some sort of wrapper to avoid this?
github IBM / openapi-to-graphql / test / evaluation / load_apis_guru.js View on Github external
const downloadOas = () => {
  return git.clone({
    fs: fs,
    dir: FOLDER_PATH,
    url: REPO_URL,
    singleBranch: true,
    depth: 1
  })
}
github arjun27 / rubberduck / native-host / src / git / index.ts View on Github external
async clone() {
    await mkdir(this.clonePath);
    await git.clone({
      gitdir: this.clonePath,
      url: this.cloneUrl,
      noCheckout: true
    });
  }
github casual-simulation / aux / WebClient / GitManager.ts View on Github external
async cloneProject(): Promise {
        await clone({
            dir: this.projectDir,
            url: this._config.default_project_url,
            ref: 'master'
        });
    }