forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbranch.js
More file actions
59 lines (47 loc) · 1.56 KB
/
branch.js
File metadata and controls
59 lines (47 loc) · 1.56 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
var assert = require("assert");
var path = require("path");
var Promise = require("nodegit-promise");
var local = path.join.bind(path, __dirname);
describe("Branch", function() {
var NodeGit = require("../../");
var Repository = NodeGit.Repository;
var Branch = NodeGit.Branch;
var branchName = "test-branch";
var fullBranchName = "refs/heads/" + branchName;
var reposPath = local("../repos/workdir");
beforeEach(function() {
var test = this;
return Repository.open(reposPath)
.then(function(repository) {
test.repository = repository;
return repository.getMasterCommit();
})
.then(function(masterCommit) {
test.masterCommit = masterCommit;
return test.repository.createBranch(branchName, masterCommit, true);
})
.then(function(branch) {
test.branch = branch;
});
});
it("can create a branch", function() {
var branch = this.branch;
var masterCommit = this.masterCommit;
assert.equal(branch.name(), fullBranchName);
assert.equal(branch.target().toString(), masterCommit.sha());
});
it("can delete a branch", function() {
var repo = this.repository;
Branch.delete(this.branch);
return repo.getBranch(branchName)
// Reverse the results, since if we found it it wasn't deleted
.then(Promise.reject, Promise.resolve);
});
it("can see if the branch is pointed to by head", function() {
var repo = this.repository;
return repo.getBranch("master")
.then(function(branch) {
assert.ok(branch.isHead());
});
});
});