Skip to content

Commit d64cf9e

Browse files
committed
Reset head after create commit test
This was done to have consistent hashes between running all tests sequentially and running a single test
1 parent 0ed299c commit d64cf9e

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

test/tests/commit.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ var promisify = require("thenify-all");
55
var fse = promisify(require("fs-extra"), ["writeFile"]);
66
var local = path.join.bind(path, __dirname);
77

8+
// Have to wrap exec, since it has a weird callback signature.
9+
var exec = promisify(function(command, opts, callback) {
10+
return require("child_process").exec(command, opts, callback);
11+
});
12+
813
describe("Commit", function() {
914
var NodeGit = require("../../");
1015
var Repository = NodeGit.Repository;
@@ -24,6 +29,10 @@ describe("Commit", function() {
2429
});
2530
}
2631

32+
function undoCommit() {
33+
return exec("git reset --hard HEAD~1", {cwd: reposPath});
34+
}
35+
2736
beforeEach(function() {
2837
return reinitialize(this);
2938
});
@@ -127,7 +136,10 @@ describe("Commit", function() {
127136
})
128137
.then(function(commitId) {
129138
assert.equal(expectedCommitId, commitId);
130-
return reinitialize(test);
139+
return undoCommit()
140+
.then(function(){
141+
return reinitialize(test);
142+
});
131143
}, function(reason) {
132144
return reinitialize(test)
133145
.then(function() {

0 commit comments

Comments
 (0)