forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtag.js
More file actions
74 lines (58 loc) · 1.96 KB
/
Copy pathtag.js
File metadata and controls
74 lines (58 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var assert = require("assert");
var path = require("path");
describe("Tag", function() {
var reposPath = path.resolve("test/repos/workdir/.git");
var Repository = require("../../lib/repository");
var Tag = require("../../lib/tag");
var Obj = require("../../lib/object");
var Oid = require("../../lib/oid");
var tagName = "annotated-tag";
var tagFullName = "refs/tags/" + tagName;
var tagOid = "dc800017566123ff3c746b37284a24a66546667e";
var commitPointedTo = "32789a79e71fbc9e04d3eff7425e1771eb595150";
var tagMessage = "This is an annotated tag\n";
function testTag(tag) {
assert.equal(tag.name(), tagName);
assert.equal(tag.targetType(), Obj.TYPE.COMMIT);
assert.equal(tag.message(), tagMessage);
var target = tag.target();
assert.ok(target.isCommit());
assert.equal(target.id().toString(), commitPointedTo);
}
before(function() {
var test = this;
return Repository.open(reposPath).then(function(repo) {
test.repo = repo;
return repo;
});
});
it("can get a tag from a repo via the tag name", function() {
return this.repo.getTagByName(tagName).then(function(tag) {
testTag(tag);
});
});
it("can get a tag from a repo via the long tag name", function() {
return this.repo.getTagByName(tagFullName).then(function(tag) {
testTag(tag);
});
});
it("can get a tag from a repo via the tag's OID as a string", function() {
return this.repo.getTag(tagOid).then(function(tag) {
testTag(tag);
});
});
it("can get a tag from a repo via the tag's OID object", function() {
var oid = Oid.fromString(tagOid);
return this.repo.getTag(oid).then(function(tag) {
testTag(tag);
});
});
it("can list tags in a repo", function() {
return Tag.list(this.repo).then(function(tagNames) {
tagNames = tagNames.filter(function(tagNameTest) {
return tagNameTest == tagName;
});
assert.equal(tagNames.length, 1);
});
});
});