return Promise.map(references, reference => { return Git.Commit .lookup(reference.repo, reference.target()) .then(commit => commit.getTree()) .then(tree => { return new Promise((resolve, reject) => { const walker = tree.walk(); walker.on('entry', entry => { if(entry.isBlob()) { entry.getBlob().then( blob => reduceDocuments( documents, blob, entry, ignores, reference, name, type ) ) } }); walker.on('end', resolve); walker.on('error', reject); walker.start(); }); }) }).then(() => documents);
const manipulator = co.wrap(function*(repos, maps) { const repo = repos.x; const index = yield SubmoduleUtil.getSubmoduleNames( repo); const open = yield SubmoduleUtil.listOpenSubmodules( repo); const resolvedPaths = SubmoduleUtil.resolvePaths(c.paths, index, open, true); let checkoutFromIndex; let annotated; if (c.commit === ":0") { checkoutFromIndex = true; } else { const mapped = maps.reverseCommitMap[c.commit]; annotated = yield NodeGit.Commit.lookup(repo, mapped); } yield Checkout.checkoutFiles(repo, { commit: annotated, resolvedPaths: resolvedPaths, checkoutFromIndex: checkoutFromIndex }); });
commitIds.map(async (commitId) => { console.log('Showing', commitId, commitIds.length); const commit = await Commit.lookup(repo, commitId); const diffs = await commit.getDiff(); diffs.map(async (diff) => { const patches = await diff.patches(); patches.map(async (patch) => { const hunks = await patch.hunks(); hunks.map(async (hunk, index) => { const lines = await hunk.lines(); const data = { hunkId: [commitId, index], commit: commit.sha(), isAdded: patch.isAdded(), isDeleted: patch.isDeleted(), isModified: patch.isModified(), context: hunk.header(), path: patch.newFile().path(), content: lines.map((line) => line.content()).join('') }; onData(data); }); }); }); });
.then(function (repo) { repos = repo; addCommand("git fetch"); addCommand("git checkout -b " + bn); var cid = remoteName[bn]; console.log("2.0 " + cid); return Git.Commit.lookup(repo, cid); })
.then(function(id) { if (mergeRequired) { // a merge commit was created, cleanup MERGE_* files in .git/ var retCode = repo.stateCleanup(); if (retCode !== git.Error.CODE.OK) { throw new Error("Internal merge cleanup failed (error code " + retCode + ")"); } } return git.Commit.lookup(repo, id); });
const populateLibgit2MergeBugData = co.wrap(function*(repo, data) { if (data.mergeBases === undefined) { const head = data.head; const targetCommit = data.targetCommit; const mergeBases = yield GitUtil.mergeBases(repo, head, targetCommit); data.mergeBases = []; for (const base of mergeBases) { const commit = yield NodeGit.Commit.lookup(repo, base); data.mergeBases.push(commit); } } return data.mergeBases; });
const prepSub = co.wrap(function*(subName) { const info = {}; const subRepo = yield SubmoduleUtil.getRepo(repo, subName); info.repo = subRepo; const paths = resolvedPaths[subName]; if (options.checkoutFromIndex) { const index = yield subRepo.index(); info.index = index; // libgit2 doesn't care if requested paths don't exist, // but we do. for (const path of paths) { if (undefined === index.getByPath(path, stage)) { errors.push(noSuchFileMessage(subName, path)); } } } else { const subCommit = subCommits[subName]; const resolvedSubCommit = yield NodeGit.Commit.lookup(subRepo, subCommit); info.resolvedSubCommit = resolvedSubCommit; // libgit2 doesn't care if requested paths don't exist, // but we do. const treeId = resolvedSubCommit.treeId(); const tree = yield NodeGit.Tree.lookup(subRepo, treeId); for (const path of paths) { const entry = yield tree.entryByPath(path); if (null === entry) { errors.push(noSuchFileMessage(subName, path)); } } } submoduleInfo[subName] = info; });
.then(function(head) { theHead = head; return git.Commit.lookup(theRepo, commitToCherrypick); })
.then(function(repo) { theRepo = repo; return git.Commit.lookup(repo, commitToRevert); })
.then(function(repo) { theRepo = repo; fileDir = clone.getfileDir(repo,req); return git.Commit.lookup(repo, commitId); })
.then(function(repo) { theRepo = repo; fileDir = api.join(fileRoot, repo.workdir().substring(req.user.workspaceDir.length + 1)); return git.Commit.lookup(repo, commitId); })
.then(function(id) { return git.Commit.lookup(repo, id); });