-
Notifications
You must be signed in to change notification settings - Fork 696
Expand file tree
/
Copy pathgraph.js
More file actions
78 lines (69 loc) · 2.14 KB
/
graph.js
File metadata and controls
78 lines (69 loc) · 2.14 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
75
76
77
78
var assert = require("assert");
var path = require("path");
var local = path.join.bind(path, __dirname);
describe("Graph", function() {
var NodeGit = require("../../");
var Repository = NodeGit.Repository;
var Graph = NodeGit.Graph;
var reposPath = local("../repos/workdir");
beforeEach(function() {
var test = this;
return Repository.open(reposPath)
.then(function(repository) {
test.repository = repository;
});
});
it("can get commits ahead/behind for 2 different commits", function() {
return Graph.aheadBehind(
this.repository,
"32789a79e71fbc9e04d3eff7425e1771eb595150",
"1729c73906bb8467f4095c2f4044083016b4dfde")
.then(function(result) {
assert.equal(result.ahead, 1);
assert.equal(result.behind, 1);
});
});
it("can tell if a commit is a descendant of another", function() {
return Graph.descendantOf(
this.repository,
"32789a79e71fbc9e04d3eff7425e1771eb595150",
"e0aeedcff0584ebe00aed2c03c8ecd10839df908"
)
.then(function(result) {
assert.equal(result, 1);
});
});
it("can tell if a commit is not a descendant of another", function() {
return Graph.descendantOf(
this.repository,
"1528a019c504c9b5a68dc7d83bb2a887eb2473af",
"32789a79e71fbc9e04d3eff7425e1771eb595150"
)
.then(function(result) {
assert.equal(result, 0);
});
});
it("descendantOf will error if provided bad commits", function() {
return Graph.descendantOf(
this.repository,
"81b06facd90fe7a6e9bbd9cee59736a79105b7be",
"26744fc697849d370246749b67ac43b792a4af0c"
)
.catch(function(result) {
assert(~result.message.indexOf("object not found - no match for id"));
});
});
it("can tell if a commit is reachable from any of a list of commits", function() {
return Graph.reachableFromAny(
this.repository,
"32789a79e71fbc9e04d3eff7425e1771eb595150",
[
"1729c73906bb8467f4095c2f4044083016b4dfde",
"e0aeedcff0584ebe00aed2c03c8ecd10839df908"
]
)
.then(function(result) {
assert.equal(result, 0);
});
});
});