Skip to content

Commit c1c4852

Browse files
committed
added test for cherrypicking a stash commit
1 parent f3d385b commit c1c4852

1 file changed

Lines changed: 67 additions & 1 deletion

File tree

test/tests/cherrypick.js

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ describe("Cherrypick", function() {
7272
theirSignature: theirSignature,
7373

7474
ourFileName: ourFileName,
75-
theirFileName: theirFileName
75+
theirFileName: theirFileName,
76+
77+
ourFileContent: ourFileContent,
78+
theirFileContent: theirFileContent
7679
};
7780

7881
return Promise.all([
@@ -228,4 +231,67 @@ describe("Cherrypick", function() {
228231
repoInfo.theirFileName + " should exist");
229232
});
230233
});
234+
235+
it("can cherrypick a stash to apply it", function() {
236+
var repo = this.repository;
237+
var workDirPath = repo.workdir();
238+
var repoInfo;
239+
var cherrypickOid;
240+
241+
var addedContent = "\nIt makes things E-Z!";
242+
243+
return setupBranches(repo, true)
244+
.then(function(info) {
245+
repoInfo = info;
246+
247+
return repo.getStatus();
248+
})
249+
.then(function(statuses) {
250+
assert.equal(statuses.length, 0);
251+
252+
return fse.writeFile(path.join(workDirPath, repoInfo.ourFileName),
253+
repoInfo.ourFileContent + addedContent);
254+
})
255+
.then(function() {
256+
return repo.getStatus();
257+
})
258+
.then(function(statuses) {
259+
assert.equal(statuses.length, 1);
260+
261+
return NodeGit.Stash.save(repo, repoInfo.ourSignature, "our stash", 0);
262+
})
263+
.then(function(oid) {
264+
cherrypickOid = oid;
265+
266+
return fse.readFile(path.join(workDirPath, repoInfo.ourFileName));
267+
})
268+
.then(function(fileContent) {
269+
assert.equal(fileContent, repoInfo.ourFileContent);
270+
271+
return repo.getStatus();
272+
})
273+
.then(function(statuses) {
274+
assert.equal(statuses.length, 0);
275+
276+
return repo.getCommit(cherrypickOid);
277+
})
278+
.then(function(commit) {
279+
var opts = {
280+
mainline: 1
281+
};
282+
283+
return Cherrypick.cherrypick(repo, commit, opts);
284+
})
285+
.then(function() {
286+
return repo.getStatus();
287+
})
288+
.then(function(statuses) {
289+
assert.equal(statuses.length, 1);
290+
291+
return fse.readFile(path.join(workDirPath, repoInfo.ourFileName));
292+
})
293+
.then(function(fileContent) {
294+
assert.equal(fileContent, repoInfo.ourFileContent + addedContent);
295+
});
296+
});
231297
});

0 commit comments

Comments
 (0)