Skip to content

Commit

Permalink
Fix handling of renamed files so the old filename is not included in …
Browse files Browse the repository at this point in the history
…the lists.
  • Loading branch information
lots0logs committed Jun 9, 2020
1 parent 56647e5 commit fc7b3aa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,18 @@ async function processCommitData(result) {
}

if (isRenamed(file)) {
FILES_RENAMED.add(file.filename);
processRenamedFile(file.filename, file.previous_filename);
}
});
}

function processRenamedFile(prev_file, new_file) {
FILES.delete(prev_file) && FILES.add(new_file);
FILES_ADDED.delete(prev_file) && FILES_ADDED.add(new_file);
FILES_MODIFIED.delete(prev_file) && FILES_MODIFIED.add(new_file);
FILES_RENAMED.add(new_file);
}

function toJSON(value, pretty=true) {
return pretty
? JSON.stringify(value, null, 4)
Expand Down
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,18 @@ async function processCommitData(result) {
}

if (isRenamed(file)) {
FILES_RENAMED.add(file.filename);
processRenamedFile(file.filename, file.previous_filename);
}
});
}

function processRenamedFile(prev_file, new_file) {
FILES.delete(prev_file) && FILES.add(new_file);
FILES_ADDED.delete(prev_file) && FILES_ADDED.add(new_file);
FILES_MODIFIED.delete(prev_file) && FILES_MODIFIED.add(new_file);
FILES_RENAMED.add(new_file);
}

function toJSON(value, pretty=true) {
return pretty
? JSON.stringify(value, null, 4)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gh-action-get-changed-files",
"version": "2.1.1",
"version": "2.1.2",
"private": true,
"main": "dist/index.js",
"scripts":{
Expand Down

0 comments on commit fc7b3aa

Please sign in to comment.