Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function encodeCommit(body) {
var str = "tree " + body.tree;
for (var i = 0, l = body.parents.length; i < l; ++i) {
str += "\nparent " + body.parents[i];
}
str += "\nauthor " + formatPerson(body.author) +
"\ncommitter " + formatPerson(body.committer) +
"\n\n" + body.message;
return binary.encodeUtf8(str);
}
function encodeBlob(blob) {
if (typeof blob === "string") return {
content: binary.encodeUtf8(blob),
encoding: "utf-8"
};
if (binary.isBinary(blob)) return {
content: binary.toBase64(blob),
encoding: "base64"
};
throw new TypeError("Invalid blob type, must be binary of string");
}
function encodeTag(body) {
var str = "object " + body.object +
"\ntype " + body.type +
"\ntag " + body.tag +
"\ntagger " + formatPerson(body.tagger) +
"\n\n" + body.message;
return binary.encodeUtf8(str);
}