UNPKG

sourcecontrol

Version:

A modern TypeScript CLI application for source control

30 lines 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ObjectReader = void 0; const exceptions_1 = require("./exceptions"); const objects_1 = require("../../core/objects"); class ObjectReader { static async readCommit(repository, commitSha) { const obj = await repository.readObject(commitSha); if (!objects_1.ObjectValidator.isCommit(obj)) { throw new exceptions_1.RepositoryException(`Invalid commit: ${commitSha}`); } return obj; } static async readTree(repository, treeSha) { const obj = await repository.readObject(treeSha); if (!objects_1.ObjectValidator.isTree(obj)) { throw new exceptions_1.RepositoryException(`Invalid tree: ${treeSha}`); } return obj; } static async readBlob(repository, blobSha) { const obj = await repository.readObject(blobSha); if (!objects_1.ObjectValidator.isBlob(obj)) { throw new exceptions_1.RepositoryException(`Invalid blob: ${blobSha}`); } return obj; } } exports.ObjectReader = ObjectReader; //# sourceMappingURL=object-reader.js.map