How to use the nodegit.Checkout 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 twosigma / git-meta / test / util / read_repo_ast_util.js View on Github external
let index = yield NodeGit.Merge.commits(repo,
                                                masterCommit,
                                                whamCommit,
                                                null);

        // Have to force set the submodule to the 'bar' commit.

        yield NodeGit.Reset.reset(subRepo,
                                  localBar,
                                  NodeGit.Reset.TYPE.HARD);

        yield index.conflictCleanup();
        yield index.writeTreeTo(repo);
        yield NodeGit.Checkout.index(repo, index, {
            checkoutStrategy: NodeGit.Checkout.STRATEGY.FORCE,
        });
        index = yield repo.index();
        yield index.addByPath("s");
        yield index.write();
        const id = yield index.writeTreeTo(repo);
        const mergeCommit = yield repo.createCommit(
                                                 "HEAD",
                                                 sig,
                                                 sig,
                                                 "message",
                                                 id,
                                                 [ masterCommit, whamCommit ]);
        const mergeSha = mergeCommit.tostrS();
        const Commit = RepoAST.Commit;
        const Submodule = RepoAST.Submodule;
github happo / happo.io / src / moveToSha.js View on Github external
// things out before continuing.
    if (!force) {
      throw new Error(
        'Working tree is dirty. Stash your changes before continuing, ' +
        'or use `--force` to have it done automatically'
      );
    }
    stashOid = await Git.Stash.save(
      repo,
      Git.Signature.default(repo),
      'auto-created by happo',
      Git.Stash.FLAGS.INCLUDE_UNTRACKED
    );
    console.log(`Stash saved with oid ${stashOid}.`)
  }
  await Git.Checkout.tree(repo, moveToCommit);

  // Return a cleanup function
  return {
    fullSha: moveToCommit.sha(),
    cleanup: async () => {
      await Git.Checkout.tree(repo, originalHeadCommit);
      if (stashOid) {
        await Git.Stash.pop(repo, 0);
      }
    },
  };
}
github twosigma / git-meta / node / lib / util / git_util.js View on Github external
exports.setHeadHard = co.wrap(function *(repo, commit) {
    assert.instanceOf(repo, NodeGit.Repository);
    assert.instanceOf(commit, NodeGit.Commit);

    const headId = yield repo.getHeadCommit();
    let oldHead;
    if (headId === null) {
        oldHead = "0000000000000000000000000000000000000000";
    } else {
        oldHead = headId.id().tostrS();
    }
    const newHead = commit.sha();

    yield NodeGit.Checkout.tree(repo, commit, {
        checkoutStrategy: NodeGit.Checkout.STRATEGY.FORCE,
    });
    repo.setHeadDetached(commit);
    yield Hook.execHook(repo, "post-checkout", [oldHead, newHead, "1"]);
});
github atom / atom / src / git-repository-async.js View on Github external
.then(repo => {
              const checkoutOptions = new Git.CheckoutOptions()
              checkoutOptions.paths = [this.relativize(_path, wd)]
              checkoutOptions.checkoutStrategy = Git.Checkout.STRATEGY.FORCE | Git.Checkout.STRATEGY.DISABLE_PATHSPEC_MATCH
              return Git.Checkout.head(repo, checkoutOptions)
            })
        })
github wix / Detox / website / gatherDocs.js View on Github external
.then(function(commit) {
      return git.Checkout.tree(repo, commit, {
        checkoutStrategy: git.Checkout.STRATEGY.FORCE
      }).then(function() {
        return repo.setHeadDetached(commit, repo.defaultSignature, 'Checkout: HEAD ' + commit.id());
      });
    });
}
github elementary / houston / src / flightcheck / pipeline.js View on Github external
await git.Submodule.foreach(subRepo, async (submodule) => {
            await submodule.update(1, new git.SubmoduleUpdateOptions())
            await recursiveClone(path.join(clonePath, submodule.path()))
          })
        }

        await recursiveClone(repoFolder)
      } else {
        throw e
      }
    }

    const ref = await repo.getReference(this.build.tag)

    await repo.checkoutRef(ref, {
      checkoutStrategy: git.Checkout.STRATEGY.FORCE
    })
  }
github wix / Detox / website / gatherDocs.js View on Github external
.then(function(commit) {
      return git.Checkout.tree(repo, commit, {
        checkoutStrategy: git.Checkout.STRATEGY.FORCE
      }).then(function() {
        return repo.setHeadDetached(commit, repo.defaultSignature, 'Checkout: HEAD ' + commit.id());
      });
    });
}
github fabric8io-images / fish-pepper / fp / block-loader / nodegit.js View on Github external
.then(function () {
        return Git.Checkout.head(repo, {
          checkoutStrategy: Git.Checkout.STRATEGY.FORCE
        });
      });
  }
github atom / atom / src / git-repository-async.js View on Github external
.then(repo => {
              const checkoutOptions = new Git.CheckoutOptions()
              checkoutOptions.paths = [this.relativize(_path, wd)]
              checkoutOptions.checkoutStrategy = Git.Checkout.STRATEGY.FORCE | Git.Checkout.STRATEGY.DISABLE_PATHSPEC_MATCH
              return Git.Checkout.head(repo, checkoutOptions)
            })
        })
github fabric8io-images / fish-pepper / fp / block-loader / nodegit.js View on Github external
.then(function () {
        return Git.Checkout.head(repo, {
          checkoutStrategy: Git.Checkout.STRATEGY.FORCE
        });
      });
  }