UNPKG

747 BJavaScriptView Raw
1var GitCommit = require('./internal/git_commit').GitCommit,
2 GitTree = require('./internal/git_tree').GitTree,
3 GitTag = require('./internal/git_tag').GitTag,
4 GitBlob = require('./internal/git_blob').GitBlob;
5
6var GitObject = exports.GitObject = function() {}
7
8GitObject.from_raw = function(raw_object, repository) {
9 if(raw_object.type == "blob") {
10 return GitBlob.from_raw(raw_object, repository);
11 } else if(raw_object.type == "tree") {
12 return GitTree.from_raw(raw_object, repository);
13 } else if(raw_object.type == "commit") {
14 return GitCommit.from_raw(raw_object, repository);
15 } else if(raw_object.type == "tag") {
16 return GitTag.from_raw(raw_object, repository);
17 } else {
18 throw "got invalid object-type";
19 }
20}
\No newline at end of file