Commit 0f0b8c90 authored by Tyler Wanek's avatar Tyler Wanek Committed by GitHub

Merge pull request #1327 from cjhoward92/feature/blob_methods

BREAKING: Added blob methods and converted to async
parents 427f9872 cdfad45b
......@@ -130,7 +130,7 @@
"selfFreeing": true,
"functions": {
"git_blob_create_frombuffer": {
"isAsync": false,
"isAsync": true,
"args": {
"id": {
"isReturn": true
......@@ -141,11 +141,59 @@
}
}
},
"git_blob_create_fromworkdir": {
"isAsync": true,
"args": {
"id": {
"isReturn": true
}
},
"return": {
"isErrorCode": true
}
},
"git_blob_create_fromdisk": {
"isAsync": true,
"args": {
"id": {
"isReturn": true
}
},
"return": {
"isErrorCode": true
}
},
"git_blob_create_fromchunks": {
"ignore": true
},
"git_blob_filtered_content": {
"ignore": true
"isAsync": true,
"isPrototypeMethod": false,
"args": {
"out": {
"isReturn": true,
"cppClassName": "GitBuf",
"jsClassName": "Buffer"
},
"blob": {
"cppClassName": "GitBlob",
"jsClassName": "Blob",
"isSelf": false
},
"as_path": {
"cppClassName": "String",
"jsClassName": "String",
"cType": "const char *"
},
"check_for_binary_data": {
"cppClassName": "Number",
"jsClassName": "Number",
"cType": "int"
}
},
"return": {
"isErrorCode": true
}
},
"git_blob_id": {
"return": {
......
......@@ -511,8 +511,8 @@ Repository.prototype.createBranch = function(name, commit, force) {
* @param {Buffer} buffer
* @return {Oid}
*/
Repository.prototype.createBlobFromBuffer = function(buffer, callback) {
return Blob.createFromBuffer(this, buffer, buffer.length, callback);
Repository.prototype.createBlobFromBuffer = function(buffer) {
return Blob.createFromBuffer(this, buffer, buffer.length);
};
/**
......@@ -1784,9 +1784,9 @@ Repository.prototype.stageLines =
.then(function(newContent) {
var newContentBuffer = new Buffer(newContent);
var newOid = repo.createBlobFromBuffer(newContentBuffer);
return repo.getBlob(newOid);
return repo.createBlobFromBuffer(newContentBuffer);
})
.then(newOid => repo.getBlob(newOid))
.then(function(newBlob) {
var entry = index.getByPath(filePath, 0);
entry.id = newBlob.id();
......
This diff is collapsed.
......@@ -247,10 +247,13 @@ describe("Diff", function() {
function(done) {
var evilString = "Unicode’s fun!\nAnd it’s good for you!\n";
var buffer = new Buffer(evilString);
var oid = Blob.createFromBuffer(this.repository, buffer, buffer.length);
Blob.lookup(this.repository, oid)
var test = this;
Blob.createFromBuffer(test.repository, buffer, buffer.length)
.then(function(oid) {
return Blob.lookup(test.repository, oid);
})
.then(function(blob) {
blob.repo = this.repository;
blob.repo = test.repository;
return Diff.blobToBuffer(
blob,
null,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment