Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tree: encodeTree,
blob: encodeBlob
};
var decoders = {
commit: decodeCommit,
tag: decodeTag,
tree: decodeTree,
blob: decodeBlob,
};
var typeCache = {};
// Precompute hashes for empty blob and empty tree since github won't
var empty = bodec.create(0);
var emptyBlob = sha1(frame({ type: "blob", body: empty }));
var emptyTree = sha1(frame({ type: "tree", body: empty }));
// Implement the js-git object interface using github APIs
module.exports = function (repo, root, accessToken, githubHostname) {
var apiRequest = xhr(root, accessToken, githubHostname);
repo.loadAs = loadAs; // (type, hash) -> value, hash
repo.saveAs = saveAs; // (type, value) -> hash, value
repo.listRefs = listRefs; // (filter='') -> [ refs ]
repo.readRef = readRef; // (ref) -> hash
repo.updateRef = updateRef; // (ref, hash) -> hash
repo.deleteRef = deleteRef // (ref) -> null
repo.createTree = createTree; // (entries) -> hash, tree
repo.hasHash = hasHash;
blob: encodeBlob
};
var decoders = {
commit: decodeCommit,
tag: decodeTag,
tree: decodeTree,
blob: decodeBlob,
};
var typeCache = {};
// Precompute hashes for empty blob and empty tree since github won't
var empty = bodec.create(0);
var emptyBlob = sha1(frame({ type: "blob", body: empty }));
var emptyTree = sha1(frame({ type: "tree", body: empty }));
// Implement the js-git object interface using github APIs
module.exports = function (repo, root, accessToken) {
var apiRequest = xhr(root, accessToken);
repo.loadAs = loadAs; // (type, hash) -> value, hash
repo.saveAs = saveAs; // (type, value) -> hash, value
repo.readRef = readRef; // (ref) -> hash
repo.updateRef = updateRef; // (ref, hash) -> hash
repo.createTree = createTree; // (entries) -> hash, tree
repo.hasHash = hasHash;
function loadAs(type, hash, callback) {
if (!callback) return loadAs.bind(repo, type, hash);
// Github doesn't like empty trees, but we know them already.
function hashAs(type, body) {
var buffer = frame({type: type, body: body});
return sha1(buffer);
}
function hashAs(type, body) {
var buffer = frame({type: type, body: body});
return sha1(buffer);
}