Skip to content

Commit 2a87e60

Browse files
author
John Haley
committed
Added checkout head method and tests
1 parent 6a4afa3 commit 2a87e60

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

generate/input/descriptor.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,27 @@
182182
}
183183
}
184184
},
185+
"checkout": {
186+
"functions": {
187+
"git_checkout_head": {
188+
"args": {
189+
"opts": {
190+
"isOptional": true
191+
}
192+
},
193+
"isAsync": true,
194+
"return": {
195+
"isErrorCode": true
196+
}
197+
},
198+
"git_checkout_index": {
199+
"ignore": true
200+
},
201+
"git_checkout_tree": {
202+
"ignore": true
203+
}
204+
}
205+
},
185206
"clone": {
186207
"functions": {
187208
"git_clone": {

test/tests/checkout.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
1+
var assert = require("assert");
12
var path = require("path");
23

34
describe("Checkout", function() {
5+
var packageJsonOid = "0fa56e90e096a4c24c785206b826ab914ea3de1e";
46
var reposPath = path.resolve("test/repos/workdir/.git");
57

68
var Repository = require("../../lib/repository");
9+
var Checkout = require("../../lib/checkout");
710

811
before(function() {
912
var test = this;
1013

11-
return Repository.open(reposPath).then(function(repository) {
12-
test.repository = repository;
14+
return Repository.open(reposPath).then(function(repo) {
15+
test.repo = repo;
16+
});
17+
});
18+
19+
it("can checkout the head", function() {
20+
var repo = this.repo;
21+
22+
Checkout.head(repo)
23+
.then(function() {
24+
return repo.getBlob(packageJsonOid);
25+
})
26+
.then(function(blob) {
27+
var packageJson = blob.toString();
28+
29+
assert.ok(~packageJson.indexOf("\"ejs\": \"~1.0.0\","));
1330
});
1431
});
1532
});

0 commit comments

Comments
 (0)