How to use the nodegit.Object 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 namshi / roger / src / git.js View on Github external
.then(function(ref) {
          // Convert tags to commit objects
          return ref.peel(Git.Object.TYPE.COMMIT);
        })
        .then(function(ref) {
github eclipse / orion.client / modules / orionode / lib / git / tags.js View on Github external
.then(function(object) {
		var type = object.type();
		if (type === git.Object.TYPE.TAG) {
			// referenced object is a tag, annotated tag then
			return true;
		} else if (type !== git.Object.TYPE.COMMIT) {
			// otherwise, should be pointing at a commit and not an annotated tag,
			// but if not, then something is wrong
			return "Invalid object type found for '" + theRef.name() + "' (" + type + ")";
		}
		return false;
	});
}
github eclipse / orion.client / modules / orionode / lib / git / tags.js View on Github external
function isAnnotated(repo, ref) {
	// get the object being referenced and check its type
	return git.Object.lookup(repo, ref.target(), git.Object.TYPE.ANY)
	.then(function(object) {
		var type = object.type();
		if (type === git.Object.TYPE.TAG) {
			// referenced object is a tag, annotated tag then
			return true;
		} else if (type !== git.Object.TYPE.COMMIT) {
			// otherwise, should be pointing at a commit and not an annotated tag,
			// but if not, then something is wrong
			return "Invalid object type found for '" + theRef.name() + "' (" + type + ")";
		}
		return false;
	});
}
github Shopify / js-buy-sdk / scripts / util / doc-builder.js View on Github external
return promise.then(() => {
        return reference.peel(NodeGit.Object.TYPE.COMMIT);
      }).then(object => {
        return repo.getCommit(object.id());
github twosigma / git-meta / node / lib / util / synthetic_branch_util.js View on Github external
if (skipCheckForURL(cfg,  url)) {
        return true;
    }

    if (skipCheckForPath(cfg, path)) {
        return true;
    }

    const localPath = yield *exports.urlToLocalPath(repo, url);
    const submoduleRepo = yield NodeGit.Repository.open(localPath);
    const submoduleCommitId = submoduleEntry.id();
    try {
        const subrepoCommit =
              yield NodeGit.Object.lookup(submoduleRepo, submoduleCommitId,
                                          NodeGit.Object.TYPE.COMMIT);
        return subrepoCommit !== null;
    } catch (e) {
        console.error("Could not look up ", submoduleCommitId, " in ",
                      localPath, ": ", e);
        return false;
    }
}
github twosigma / git-meta / node / lib / util / synthetic_branch_util.js View on Github external
assert.instanceOf(submoduleEntry, NodeGit.TreeEntry);

    if (skipCheckForURL(cfg,  url)) {
        return true;
    }

    if (skipCheckForPath(cfg, path)) {
        return true;
    }

    const localPath = yield *exports.urlToLocalPath(repo, url);
    const submoduleRepo = yield NodeGit.Repository.open(localPath);
    const submoduleCommitId = submoduleEntry.id();
    try {
        const subrepoCommit =
              yield NodeGit.Object.lookup(submoduleRepo, submoduleCommitId,
                                          NodeGit.Object.TYPE.COMMIT);
        return subrepoCommit !== null;
    } catch (e) {
        console.error("Could not look up ", submoduleCommitId, " in ",
                      localPath, ": ", e);
        return false;
    }
}
github googlefonts / fontbakery-dashboard / containers / base / javascript / node / manifestSources / CSVSpreadsheet.js View on Github external
function _getTreeFromTreeEntry(treeEntry) {
    if(treeEntry.isTree())
        return treeEntry.getTree();
    let path = treeEntry.path()
      , type = treeEntry.type()
      , typeName = 'UNKNOWN'
      ;
    for(let name of Object.keys(NodeGit.Object.TYPE))
        if (type === NodeGit.Object.TYPE[name]) {
            typeName = name;
            break;
        }
    throw new Error(['Entry at path: "', path, '" is not a directory (tree)!'
                        , 'Type is: ', typeName,' (',type,').'].join(' '));
}
github googlefonts / fontbakery-dashboard / containers / base / javascript / node / manifestSources / Git.js View on Github external
        .filter(treeEntry => treeEntry.type() === NodeGit.Object.TYPE.TREE)
        .map(entry=>entry.path())
github elementary / houston / src / lib / service / github.ts View on Github external
public async clone (p: string, reference = this.reference): Promise {
    const repo = await Git.Clone(this.url, p)

    const ref = await repo.getReference(reference)
    const commit = await ref.peel(Git.Object.TYPE.COMMIT)
    const branch = await repo.createBranch('houston', commit, true)

    await repo.checkoutBranch(branch, {})

    await this.recursiveClone(p)

    await fs.remove(path.resolve(p, '.git'))
  }
github creativechain / creativechain-universe / build / compile.js View on Github external
.then(function (ref) {
                                ref.peel(git.Object.TYPE.COMMIT)
                                    .then(function (ref2) {
                                        git.Commit.lookup(repository, ref2.id())
                                            .then(function (commit) {
                                                if (commit.sha() === COMMIT) {
                                                    COMMIT = null;
                                                } else {
                                                    COMMIT = COMMIT.substring(0, 7);
                                                }

                                                setBuildVersion();
                                                compile();
                                            });
                                    })
                            });
                    })