Commit f4cd5777 authored by Tyler Wanek's avatar Tyler Wanek

Hot fix historywalk

was dropping deleted events due to rename detection.
parent 743c2a47
......@@ -164,6 +164,14 @@ void GitRevwalk::FileHistoryWalkWorker::Execute()
}
baton->out->push_back(historyEntry);
flag = true;
} else if (isEqualOldFile) {
std::pair<git_commit *, std::pair<char *, git_delta_t> > *historyEntry;
historyEntry = new std::pair<git_commit *, std::pair<char *, git_delta_t> >(
nextCommit,
std::pair<char *, git_delta_t>(strdup(delta->new_file.path), delta->status)
);
baton->out->push_back(historyEntry);
flag = true;
}
git_patch_free(nextPatch);
......@@ -220,7 +228,7 @@ void GitRevwalk::FileHistoryWalkWorker::HandleOKCallback()
Nan::Set(historyEntry, Nan::New("commit").ToLocalChecked(), GitCommit::New(batonResult->first, true));
Nan::Set(historyEntry, Nan::New("status").ToLocalChecked(), Nan::New<Number>(batonResult->second.second));
if (batonResult->second.second == GIT_DELTA_RENAMED) {
Nan::Set(historyEntry, Nan::New("oldName").ToLocalChecked(), Nan::New(batonResult->second.first).ToLocalChecked());
Nan::Set(historyEntry, Nan::New("altname").ToLocalChecked(), Nan::New(batonResult->second.first).ToLocalChecked());
}
Nan::Set(result, Nan::New<Number>(i), historyEntry);
......
......@@ -129,7 +129,7 @@ Revwalk.prototype.getCommits = function(count) {
* @type {Object}
* @property {Commit} commit the commit for this entry
* @property {Number} status the status of the file in the commit
* @property {String} oldName the old name that is provided when status is
* @property {String} altname the other name that is provided when status is
* renamed
*/
......
......@@ -235,6 +235,8 @@ describe("Revwalk", function() {
var repoPath = local("../repos/renamedFileRepo");
var signature = NodeGit.Signature.create("Foo bar",
"foo@bar.com", 123456789, 60);
var headCommit;
return RepoUtils.createRepository(repoPath)
.then(function(r) {
repo = r;
......@@ -276,6 +278,7 @@ describe("Revwalk", function() {
return NodeGit.Reference.nameToId(repo, "HEAD");
})
.then(function(commitOid) {
headCommit = commitOid.tostrS();
var walker = repo.createRevWalk();
walker.sorting(NodeGit.Revwalk.SORT.TIME);
walker.push(commitOid.tostrS());
......@@ -283,7 +286,17 @@ describe("Revwalk", function() {
})
.then(function(results) {
assert.equal(results[0].status, NodeGit.Diff.DELTA.RENAMED);
assert.equal(results[0].oldName, fileNameA);
assert.equal(results[0].altname, fileNameA);
})
.then(function() {
var walker = repo.createRevWalk();
walker.sorting(NodeGit.Revwalk.SORT.TIME);
walker.push(headCommit);
return walker.fileHistoryWalk(fileNameA, 5);
})
.then(function(results) {
assert.equal(results[0].status, NodeGit.Diff.DELTA.RENAMED);
assert.equal(results[0].altname, fileNameB);
})
.then(function() {
return fse.remove(repoPath);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment