How to use the isomorphic-git.status 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
}

  // 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)
    }
  }

  await clonePromise
  return clonePromise
}
github adobe / helix-cli / src / git-utils.js View on Github external
static async isIgnored(dir, filepath, homedir = os.homedir()) {
    if (!(await fse.pathExists(path.resolve(dir, filepath)))) {
      return true;
    }
    if (!(await fse.pathExists(path.resolve(dir, '.git')))) {
      return true;
    }

    const status = await git.status({ dir, filepath });
    if (status === 'ignored') {
      return true;
    }

    // need to re-check the modified against the globally ignored
    // see: https://github.com/isomorphic-git/isomorphic-git/issues/444
    const globalConfig = path.resolve(homedir, '.gitconfig');
    const config = ini.parse(await fse.readFile(globalConfig, 'utf-8'));
    const globalIgnore = path.resolve(homedir, (config.core && config.core.excludesfile) || '.gitignore_global');
    if (await fse.pathExists(globalIgnore)) {
      const ign = ignore().add(await fse.readFile(globalIgnore, 'utf-8'));
      return ign.ignores(filepath);
    }

    return false;
  }
github mizchi / next-editor / src / lib / repository.ts View on Github external
export async function getGitStatusInRepository(
  projectRoot: string,
  relpath: string
): Promise {
  try {
    const status = await git.status({ fs, dir: projectRoot, filepath: relpath })
    return status
  } catch (e) {
    return "untracked"
  }
}
github mizchi / next-editor / src / domain / git / queries / getFileStatus.ts View on Github external
export async function getFileStatus(
  projectRoot: string,
  relpath: string,
  ref: string | null = null
): Promise {
  try {
    return await git.status({ dir: projectRoot, filepath: relpath, ref })
  } catch (e) {
    return "__error__"
  }
}
github felipemanga / FemtoIDE / plugins / git.js View on Github external
if( buffer.type == "directory" ){
            let action = {
                type:"button",
                label:"git",
                text:"Stage All",
                cb:gitAdd.bind(null, buffer)
            };

            APP.async(_=>{
                APP.setBufferAction( buffer, action );
            });
            return;
        }
        
        git.status({dir, filepath:relative})
            .then(result=>{
                let action = Object.assign({label:"git"}, statusMap[result]);
                if( action.cb )
                    action.cb = action.cb.bind(null, buffer);
                
                APP.setBufferAction( buffer, action );
                APP.setBufferColor( buffer, colorMap[result] );
            }).catch(ex=>{
                APP.error(relative);
                log(ex);
            });
    }