FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Tests: generalized createConflict in index utils · nodegit/nodegit@078163c · GitHub

Repository navigation

Commit 078163c

Browse files
Kyle Smith
committed
Tests: generalized createConflict in index utils
Leave the repository in a conflicted state and return the index rather than the IndexEntries of the ancestor, ours, and theirs
1 parent a3f6bd4 commit 078163c

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

‎test/tests/index.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,13 @@ describe("Index", function() {
329329
fileName
330330
);
331331
})
332+
.then(function() {
333+
return repo.openIndex();
334+
})
335+
.then(function(conflictedIndex) {
336+
assert.ok(conflictedIndex.hasConflicts());
337+
return conflictedIndex.conflictGet(fileName);
338+
})
332339
.then(function(indexEntries) {
333340
// Store all indexEntries for conflict
334341
ancestorIndexEntry = indexEntries.ancestor_out;

‎test/utils/index_setup.js‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var assert = require("assert");
21
var NodeGit = require("../../");
32
var path = require("path");
43
var promisify = require("promisify-node");
@@ -80,20 +79,25 @@ var IndexSetup = {
8079
checkoutStrategy: NodeGit.Checkout.STRATEGY.FORCE
8180
};
8281

83-
return NodeGit.Checkout.head(repository, opts);
82+
return repository.checkoutBranch(ourBranchName, opts);
8483
})
8584
.then(function() {
86-
return repository.mergeBranches(ourBranchName, theirBranchName);
85+
return NodeGit.AnnotatedCommit.fromRef(repository, theirBranch);
8786
})
88-
.then(function(commit) {
89-
assert.fail(commit, undefined,
90-
"The index should have been thrown due to merge conflicts");
87+
.then(function(theirAnnotatedCommit) {
88+
var checkoutOpts = {
89+
checkoutStrategy: NodeGit.Checkout.STRATEGY.SAFE
90+
| NodeGit.Checkout.STRATEGY.RECREATE_MISSING
91+
};
92+
return NodeGit.Merge.merge(
93+
repository,
94+
theirAnnotatedCommit,
95+
null,
96+
checkoutOpts
97+
);
9198
})
92-
.catch(function(index) {
93-
assert.ok(index);
94-
assert.ok(index.hasConflicts());
95-
96-
return index.conflictGet(fileName);
99+
.then(function() {
100+
return repository.openIndex();
97101
});
98102
}
99103
};

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL