How to use the nodegit.AnnotatedCommit 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 DefinitelyTyped / DefinitelyTyped / types / nodegit / nodegit-tests.ts View on Github external
const id = new Git.Oid();
const ref = new Git.Reference();
const tree = new Git.Tree();

tree.walk().start();
tree.getEntry("/").then(entry => {
    // Use entry
});

// AnnotatedCommit Tests

Git.AnnotatedCommit.fromFetchhead(repo, "branch_name", "remote_url", id).then((annotatedCommit) => {
    // Use annotatedCommit
});

Git.AnnotatedCommit.fromRef(repo, ref).then((annotatedCommit) => {
    // Use annotatedCommit
});

Git.AnnotatedCommit.fromRevspec(repo, "revspec").then((annotatedCommit) => {
    // Use annotatedCommit
});

Git.AnnotatedCommit.lookup(repo, id).then((annotatedCommit) => {
    // Use annotatedCommit
    annotatedCommit.free();
    annotatedCommit.id();
});

// Attr tests

let result = Git.Attr.addMacro(repo, "name", "values");
github DefinitelyTyped / DefinitelyTyped / types / nodegit / nodegit-tests.ts View on Github external
// Use repository
});

const repo = new Git.Repository();
const id = new Git.Oid();
const ref = new Git.Reference();
const tree = new Git.Tree();

tree.walk().start();
tree.getEntry("/").then(entry => {
    // Use entry
});

// AnnotatedCommit Tests

Git.AnnotatedCommit.fromFetchhead(repo, "branch_name", "remote_url", id).then((annotatedCommit) => {
    // Use annotatedCommit
});

Git.AnnotatedCommit.fromRef(repo, ref).then((annotatedCommit) => {
    // Use annotatedCommit
});

Git.AnnotatedCommit.fromRevspec(repo, "revspec").then((annotatedCommit) => {
    // Use annotatedCommit
});

Git.AnnotatedCommit.lookup(repo, id).then((annotatedCommit) => {
    // Use annotatedCommit
    annotatedCommit.free();
    annotatedCommit.id();
});
github twosigma / git-meta / node / lib / util / submodule_rebase_util.js View on Github external
if (null === upstream) {
        if (yield NodeGit.Graph.descendantOf(repo, branchSha, headSha)) {
            yield GitUtil.setHeadHard(repo, branch);
            result.ffwd = true;
            return result;                                            // RETURN
        }
    }

    const ontoAnnotated = yield NodeGit.AnnotatedCommit.fromRef(repo, head);
    const branchAnnotated =
                       yield NodeGit.AnnotatedCommit.lookup(repo, branch.id());
    let upstreamAnnotated = null;
    if (null !== upstream) {
        upstreamAnnotated =
                     yield NodeGit.AnnotatedCommit.lookup(repo, upstream.id());
    }
    const rebase = yield NodeGit.Rebase.init(repo,
                                             branchAnnotated,
                                             upstreamAnnotated,
                                             ontoAnnotated,
                                             null);
    const op = yield exports.callNext(rebase);
    return yield exports.processRebase(repo, rebase, op);
});
github twosigma / git-meta / node / lib / util / write_repo_ast_util.js View on Github external
if (!ast.bare) {

        let indexHead = ast.head;

        // Set up a rebase if there is one, this has to come right before
        // setting up the workdir, otherwise the rebase won't be allowed to
        // start.

        if (null !== ast.rebase) {
            const rebase = ast.rebase;
            const originalSha = commitMap[rebase.originalHead];
            const ontoSha = commitMap[rebase.onto];
            const original = yield NodeGit.AnnotatedCommit.lookup(repo,
                                                                  originalSha);
            const onto = yield NodeGit.AnnotatedCommit.lookup(repo, ontoSha);

            // `init` creates the rebase, but it's not actually started (some
            // files are not made) until the first call to `next`.

            const rb  =
                   yield NodeGit.Rebase.init(repo, original, onto, null, null);
            yield rb.next();
            const gitDir = repo.path();
            const rbDir = yield RebaseFileUtil.findRebasingDir(gitDir);
            const headNamePath = path.join(gitDir,
                                           rbDir,
                                           RebaseFileUtil.headFileName);
            yield fs.writeFile(headNamePath, rebase.headName + "\n");

            // Starting a rebase will change the HEAD  If we render the index
            // against `ast.head`, it will be incorrect; we must adjust so that
github twosigma / git-meta / node / lib / util / submodule_rebase_util.js View on Github external
}

    // We can do a fast-forward if `branch` and its entire history should be
    // included.  This requires two things to be true:
    // 1. `branch` is a descendant of `head` or equal to `head`
    // 2. `null === upstream` (implying that all ancestors are to be included)

    if (null === upstream) {
        if (yield NodeGit.Graph.descendantOf(repo, branchSha, headSha)) {
            yield GitUtil.setHeadHard(repo, branch);
            result.ffwd = true;
            return result;                                            // RETURN
        }
    }

    const ontoAnnotated = yield NodeGit.AnnotatedCommit.fromRef(repo, head);
    const branchAnnotated =
                       yield NodeGit.AnnotatedCommit.lookup(repo, branch.id());
    let upstreamAnnotated = null;
    if (null !== upstream) {
        upstreamAnnotated =
                     yield NodeGit.AnnotatedCommit.lookup(repo, upstream.id());
    }
    const rebase = yield NodeGit.Rebase.init(repo,
                                             branchAnnotated,
                                             upstreamAnnotated,
                                             ontoAnnotated,
                                             null);
    const op = yield exports.callNext(rebase);
    return yield exports.processRebase(repo, rebase, op);
});
github thisconnect / nodegit-kit / lib / get.js View on Github external
.catch(function(){
            return Git.AnnotatedCommit.fromRevspec(repo, o.commit)
            .then(function(annotatedCommit){
                debug('annotated commit %s', o.commit);
                return annotatedCommit.id();
            })
            .then(function(id){
                return repo.getCommit(id);
            });
        });
    });
github twosigma / git-meta / node / lib / util / submodule_util.js View on Github external
exports.getSubmoduleShasForCommitish = co.wrap(function *(repo, commitish) {
    assert.instanceOf(repo, NodeGit.Repository);
    assert.isString(commitish);
    const annotated = yield NodeGit.AnnotatedCommit.fromRevspec(repo,
                                                                commitish);
    const commit = yield NodeGit.Commit.lookup(repo, annotated.id());
    const submoduleNames =
                    yield exports.getSubmoduleNamesForCommit(repo, commit);

    return yield exports.getSubmoduleShasForCommit(repo,
                                                   submoduleNames,
                                                   commit);
});
github eclipse / orion.client / modules / orionode / lib / git / commit.js View on Github external
function forceMerge(repo, head, commit, branchToMerge, createMergeCommit, conflictingPathsCallback) {
	return git.AnnotatedCommit.lookup(repo, commit.id())
	.then(function(annotated) {
		return git.Merge.merge(repo, annotated, null, null).then(function() {
			if (repo.state() !== git.Repository.STATE.MERGE) {
				throw new Error("Internal merge failure ");
			}
	
			if (createMergeCommit) {
				var signature = repo.defaultSignature();
				var message = "Merged branch '" + branchToMerge + "'"; 
				return createCommit(repo,
					signature.name(), signature.email(),
					signature.name(), signature.email(),
					message, false, false);
			}
		}).catch (function(err) {
			return getConflictingPaths(repo, head, commit).then(conflictingPathsCallback);
github twosigma / git-meta / node / lib / util / git_util.js View on Github external
exports.resolveCommitish = co.wrap(function *(repo, commitish) {
    assert.instanceOf(repo, NodeGit.Repository);
    assert.isString(commitish);

    try {
        return yield NodeGit.AnnotatedCommit.fromRevspec(repo, commitish);
    }
    catch (e) {
        return null;
    }
});
github twosigma / git-meta / node / lib / util / git_util.js View on Github external
exports.resolveCommitish = co.wrap(function *(repo, commitish) {
    assert.instanceOf(repo, NodeGit.Repository);
    assert.isString(commitish);

    try {
        return yield NodeGit.AnnotatedCommit.fromRevspec(repo, commitish);
    }
    catch (e) {
        return null;
    }
});