How to use the nodegit.Repository.open function in nodegit

To help you get started, we’ve selected a few nodegit 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 surf-build / surf / src / git-api.ts View on Github external
return await using(async (ds) => {
    let repo = ds(await Repository.open(targetDirname));
    let commit = ds(await repo.getCommit(sha));

    let opts: any = {};

    // Equivalent of `git reset --hard HEAD && git clean -xdf`
    d(`Found commit: ${targetDirname}:${commit.sha()}`);
    opts.checkoutStrategy = Checkout.STRATEGY.FORCE |
      Checkout.STRATEGY.RECREATE_MISSING |
      Checkout.STRATEGY.REMOVE_UNTRACKED |
      Checkout.STRATEGY.USE_THEIRS;

    await Checkout.tree(repo, commit, opts);
  });
}
github surf-build / surf / src / git-api.ts View on Github external
return await using(async (ds) => {
    let repo = ds(await Repository.open(repoDir));
    let origin = ds(await Remote.lookup(repo, 'origin', () => {}));

    let cb = {
      credentials: () => {
        d(`Returning ${token} for authentication token`);
        return Cred.userpassPlaintextNew(token || '', 'x-oauth-basic');
      },
      certificateCheck: () => {
        // Yolo
        return 1;
       }
    };

    await origin.connect(0, cb, null, null, null);

    try {
github surf-build / surf / src / git-api.ts View on Github external
return await using(async (ds) => {
    d('Opening repo');
    let repo = ds(await Repository.open(targetDir));

    d('Looking up origin');
    let origin = await Remote.lookup(repo, 'origin', () => {});

    let refspec = 'refs/heads/master:refs/heads/master';
    let pushopts: any = {
      callbacks: {
        credentials: () => {
          d(`Returning ${token} for authentication token`);
          return Cred.userpassPlaintextNew(token, 'x-oauth-basic');
        },
        certificateCheck: () => {
          // Yolo
          return 1;
        }
      }
github huangruichang / treex / app / src / actions / project / index.js View on Github external
}, (filenames) => {
      if (!filenames) return
      if (filenames.length > 0) {
        const filePath = filenames[0]
        const projectName = filePath.split('\/').reverse()[0]
        Repository.open(filePath).then((repo) => {
          db.get('projects').push({
            name: projectName,
            path: filePath,
          }).value()
          dispatch({
            type: LOAD_PROJECT,
            repo: repo,
          })
          dispatch(listProject())
          let win = new BrowserWindow({
            width: 1048,
            height: 604,
          })

          win.loadURL(`file:\/\/${join(__dirname, `index.html#\/repo\/${projectName}/history`)}`)
          win.show()
github realMorrisLiu / lightmerge / app / models / branch.js View on Github external
const runLightmerge = async (path, list, baseBranch) => {
  io.emit(WS_EVENT.CLEAR);

  const repo = await Repository.open(path);
  const baseCommit = await repo.getBranchCommit(baseBranch);
  repo.checkoutBranch('master', {});

  const canWrite = await hsetnx(`${path}/lock`, 'lock', 1);
  if (canWrite === 0) {
    io.emit(WS_EVENT.MESSAGE, 'Other user is lightmerging, please wait!');
  } else {
    io.emit(WS_EVENT.MESSAGE, 'Start lightmerge');
  }

  io.emit(WS_EVENT.MESSAGE, `Overwrite lightmerge with ${baseBranch}`);

  const signature = Signature.default(repo);
  let currentBranch;
  let conflictFiles;
  let conflictBranch;
github realMorrisLiu / lightmerge / app / models / branch.js View on Github external
const runLightmerge = async (path, list) => {
  const repo = await Repository.open(path);
  const masterCommit = await repo.getMasterCommit();

  const canWrite = await hsetnx(`${path}/lock`, 'lock', 1);
  Log.debug(canWrite);
  const CannotLightmerge = {
    message: 'Other user is lightmerging, please wait!',
  };
  if (canWrite === 0) {
    throw CannotLightmerge;
  }

  Log.debug('Overwrite lightmerge with master');
  await repo.createBranch('lightmerge', masterCommit, true);

  const signature = Signature.default(repo);
  let conflictFiles;
github surf-build / surf / src / git-api.ts View on Github external
await using(async (ds) => {
    let repo = ds(await Repository.open(target));
    Remote.setUrl(repo, 'origin', url);
  });
}
github realMorrisLiu / lightmerge / app / models / branch.js View on Github external
const getBranchList = async (pathToRepo) => {
  const repo = await Repository.open(pathToRepo);
  const refs = await repo.getReferences(Reference.TYPE.LISTALL);
  const list = await Promise.all(refs.reduce((total, ref) => total.concat(Branch.name(ref)), []));

  return list || [];
};