Example #1
0
 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);
Example #2
0
                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
                    });
                });
Example #3
0
File: gitzo.js Project: unkhz/gitzo
 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);
       });
     });
   });
 });
Example #4
0
     .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);
 })
Example #5
0
	.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);
	});
Example #6
0
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;
});
Example #7
0
    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;
    });
Example #8
0
	.then(function(head) {
		theHead = head;
		return git.Commit.lookup(theRepo, commitToCherrypick);
	})
Example #9
0
	.then(function(repo) {
		theRepo = repo;
		return git.Commit.lookup(repo, commitToRevert);
	})
Example #10
0
	.then(function(repo) {
		theRepo = repo;
		fileDir = clone.getfileDir(repo,req);
		return git.Commit.lookup(repo, commitId);
	})
Example #11
0
	.then(function(repo) {
		theRepo = repo;
		fileDir = api.join(fileRoot, repo.workdir().substring(req.user.workspaceDir.length + 1));
		return git.Commit.lookup(repo, commitId);
	})
Example #12
0
	.then(function(id) {
		return git.Commit.lookup(repo, id);
	});