diff --git a/js/diff.js b/js/diff.js index d8086998ed..42081bc8e7 100644 --- a/js/diff.js +++ b/js/diff.js @@ -444,16 +444,17 @@ class Diff getDeletedFileList (versionFrom) { process.chdir(this.espoPath); - var deletedFileList = []; + var deletedFileList = this.getRepositoryDeletedFileList(versionFrom); + var previousAllFileList = this.getPreviousAllFileList(versionFrom); + var actualAllFileList = this.getActualAllFileList(); - var stdout = cp.execSync('git diff --name-only --diff-filter=D ' + versionFrom).toString(); - - (stdout || '').trim().split('\n').forEach(function (file) { - if (file == '') { - return; + previousAllFileList.forEach(function (file) { + if ( + ! ~actualAllFileList.indexOf(file) && + ! ~deletedFileList.indexOf(file) + ) { + deletedFileList.push(file); } - - deletedFileList.push(file); }); deletedFileList = deletedFileList.filter(function (item) { @@ -469,6 +470,54 @@ class Diff return deletedFileList; } + + getRepositoryDeletedFileList (versionFrom) { + var deletedFileList = []; + + var stdout = cp.execSync('git diff --name-only --diff-filter=D ' + versionFrom).toString(); + + (stdout || '').trim().split('\n').forEach(function (file) { + if (file == '') { + return; + } + + deletedFileList.push(file); + }); + + return deletedFileList; + } + + getActualAllFileList () { + var actualAllFileList = []; + + var stdout = cp.execSync('git ls-tree -r --name-only HEAD').toString(); + + (stdout || '').trim().split('\n').forEach(function (file) { + if (file == '') { + return; + } + + actualAllFileList.push(file); + }); + + return actualAllFileList; + } + + getPreviousAllFileList (versionFrom) { + var previousAllFileList = []; + + var stdout = cp.execSync('git ls-tree -r --name-only ' + versionFrom).toString(); + + (stdout || '').trim().split('\n').forEach(function (file) { + if (file == '') { + return; + } + + previousAllFileList.push(file); + }); + + return previousAllFileList; + } } function execute (command, callback) {