Skip to content

Commit b17fbb0

Browse files
author
Sean Krail
committed
refactor: rename output deleted to removed
'removed' is the official name used by GitHub's API. 'deleted' will still be supported for backwards-compatibility, but not mentioned in the docs.
1 parent c6ae66a commit b17fbb0

File tree

5 files changed

+37
-28
lines changed

5 files changed

+37
-28
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,6 @@ jobs:
9191
echo 'steps.files.outputs.all=${{ steps.files.outputs.all }}'
9292
echo 'steps.files.outputs.added=${{ steps.files.outputs.added }}'
9393
echo 'steps.files.outputs.modified=${{ steps.files.outputs.modified }}'
94-
echo 'steps.files.outputs.deleted=${{ steps.files.outputs.deleted }}'
94+
echo 'steps.files.outputs.removed=${{ steps.files.outputs.removed }}'
9595
echo 'steps.files.outputs.renamed=${{ steps.files.outputs.renamed }}'
9696
echo 'steps.files.outputs.added_modified=${{ steps.files.outputs.added_modified }}'

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# Get All Changed Files
66

77
Get all of the files changed/modified in a pull request or push's commits.
8-
You can choose to get all changed files, only added files, only modified files, only deleted files, or all added and modified files.
8+
You can choose to get all changed files, only added files, only modified files, only removed files, only renamed files, or all added and modified files.
99
These outputs are available via the `steps` output context.
10-
The `steps` output context exposes the output names `all`, `added`, `modified`, `deleted`, `renamed`, and `added_modified`.
10+
The `steps` output context exposes the output names `all`, `added`, `modified`, `removed`, `renamed`, and `added_modified`.
1111

1212
# Usage
1313

@@ -26,7 +26,7 @@ See [action.yml](action.yml)
2626
2727
- [Get all changed files as space-delimited](#get-all-changed-files-as-space-delimited)
2828
- [Get all added and modified files as CSV](#get-all-added-and-modified-files-as-csv)
29-
- [Get all deleted files as JSON](#get-all-deleted-files-as-json)
29+
- [Get all removed files as JSON](#get-all-removed-files-as-json)
3030
3131
## Get all changed files as space-delimited
3232
@@ -56,17 +56,17 @@ Consider using one of the other formats if that's the case.
5656
done
5757
```
5858
59-
## Get all deleted files as JSON
59+
## Get all removed files as JSON
6060
6161
```yaml
6262
- id: files
6363
uses: jitterbit/get-changed-files@v1
6464
with:
6565
format: 'json'
6666
- run: |
67-
readarray -t deleted_files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.deleted }}')"
68-
for deleted_file in ${deleted_files[@]}; do
69-
echo "Do something with this ${deleted_file}."
67+
readarray -t removed_files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.removed }}')"
68+
for removed_file in ${removed_files[@]}; do
69+
echo "Do something with this ${removed_file}."
7070
done
7171
```
7272

action.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@ outputs:
3030
modified:
3131
description: >
3232
Array of modified files.
33-
deleted:
33+
removed:
3434
description: >
35-
Array of deleted files.
35+
Array of removed files.
3636
renamed:
3737
description: >
3838
Array of renamed files.
3939
added_modified:
4040
description: >
4141
Array of all added and modified files.
42+
# For backwards-compatibility
43+
deleted:
44+
description: >
45+
Array of deleted files.

dist/index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3572,7 +3572,7 @@ function run() {
35723572
}
35733573
// Get the changed files from the response payload.
35743574
const files = response.data.files;
3575-
const all = [], added = [], modified = [], deleted = [], renamed = [], addedModified = [];
3575+
const all = [], added = [], modified = [], removed = [], renamed = [], addedModified = [];
35763576
for (const file of files) {
35773577
const filename = file.filename;
35783578
// If we're using the 'space-delimited' format and any of the filenames have a space in them,
@@ -3592,17 +3592,17 @@ function run() {
35923592
addedModified.push(filename);
35933593
break;
35943594
case 'removed':
3595-
deleted.push(filename);
3595+
removed.push(filename);
35963596
break;
35973597
case 'renamed':
35983598
renamed.push(filename);
35993599
break;
36003600
default:
3601-
core.setFailed(`One of your files includes an unsupported file status '${file.status}', expected 'added', 'modified', or 'removed'.`);
3601+
core.setFailed(`One of your files includes an unsupported file status '${file.status}', expected 'added', 'modified', 'removed', or 'renamed'.`);
36023602
}
36033603
}
36043604
// Format the arrays of changed files.
3605-
let allFormatted, addedFormatted, modifiedFormatted, deletedFormatted, renamedFormatted, addedModifiedFormatted;
3605+
let allFormatted, addedFormatted, modifiedFormatted, removedFormatted, renamedFormatted, addedModifiedFormatted;
36063606
switch (format) {
36073607
case 'space-delimited':
36083608
// If any of the filenames have a space in them, then fail the step.
@@ -3613,23 +3613,23 @@ function run() {
36133613
allFormatted = all.join(' ');
36143614
addedFormatted = added.join(' ');
36153615
modifiedFormatted = modified.join(' ');
3616-
deletedFormatted = deleted.join(' ');
3616+
removedFormatted = removed.join(' ');
36173617
renamedFormatted = renamed.join(' ');
36183618
addedModifiedFormatted = addedModified.join(' ');
36193619
break;
36203620
case 'csv':
36213621
allFormatted = all.join(',');
36223622
addedFormatted = added.join(',');
36233623
modifiedFormatted = modified.join(',');
3624-
deletedFormatted = deleted.join(',');
3624+
removedFormatted = removed.join(',');
36253625
renamedFormatted = renamed.join(',');
36263626
addedModifiedFormatted = addedModified.join(',');
36273627
break;
36283628
case 'json':
36293629
allFormatted = JSON.stringify(all);
36303630
addedFormatted = JSON.stringify(added);
36313631
modifiedFormatted = JSON.stringify(modified);
3632-
deletedFormatted = JSON.stringify(deleted);
3632+
removedFormatted = JSON.stringify(removed);
36333633
renamedFormatted = JSON.stringify(renamed);
36343634
addedModifiedFormatted = JSON.stringify(addedModified);
36353635
break;
@@ -3638,16 +3638,18 @@ function run() {
36383638
core.info(`All: ${allFormatted}`);
36393639
core.info(`Added: ${addedFormatted}`);
36403640
core.info(`Modified: ${modifiedFormatted}`);
3641-
core.info(`Deleted: ${deletedFormatted}`);
3641+
core.info(`Removed: ${removedFormatted}`);
36423642
core.info(`Renamed: ${renamedFormatted}`);
36433643
core.info(`Added or modified: ${addedModifiedFormatted}`);
36443644
// Set step output context.
36453645
core.setOutput('all', allFormatted);
36463646
core.setOutput('added', addedFormatted);
36473647
core.setOutput('modified', modifiedFormatted);
3648-
core.setOutput('deleted', deletedFormatted);
3648+
core.setOutput('removed', removedFormatted);
36493649
core.setOutput('renamed', renamedFormatted);
36503650
core.setOutput('added_modified', addedModifiedFormatted);
3651+
// For backwards-compatibility
3652+
core.setOutput('deleted', removedFormatted);
36513653
}
36523654
catch (error) {
36533655
core.setFailed(error.message);

src/main.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async function run(): Promise<void> {
8787
const all = [] as string[],
8888
added = [] as string[],
8989
modified = [] as string[],
90-
deleted = [] as string[],
90+
removed = [] as string[],
9191
renamed = [] as string[],
9292
addedModified = [] as string[]
9393
for (const file of files) {
@@ -111,14 +111,14 @@ async function run(): Promise<void> {
111111
addedModified.push(filename)
112112
break
113113
case 'removed':
114-
deleted.push(filename)
114+
removed.push(filename)
115115
break
116116
case 'renamed':
117117
renamed.push(filename)
118118
break
119119
default:
120120
core.setFailed(
121-
`One of your files includes an unsupported file status '${file.status}', expected 'added', 'modified', or 'removed'.`
121+
`One of your files includes an unsupported file status '${file.status}', expected 'added', 'modified', 'removed', or 'renamed'.`
122122
)
123123
}
124124
}
@@ -127,7 +127,7 @@ async function run(): Promise<void> {
127127
let allFormatted: string,
128128
addedFormatted: string,
129129
modifiedFormatted: string,
130-
deletedFormatted: string,
130+
removedFormatted: string,
131131
renamedFormatted: string,
132132
addedModifiedFormatted: string
133133
switch (format) {
@@ -142,23 +142,23 @@ async function run(): Promise<void> {
142142
allFormatted = all.join(' ')
143143
addedFormatted = added.join(' ')
144144
modifiedFormatted = modified.join(' ')
145-
deletedFormatted = deleted.join(' ')
145+
removedFormatted = removed.join(' ')
146146
renamedFormatted = renamed.join(' ')
147147
addedModifiedFormatted = addedModified.join(' ')
148148
break
149149
case 'csv':
150150
allFormatted = all.join(',')
151151
addedFormatted = added.join(',')
152152
modifiedFormatted = modified.join(',')
153-
deletedFormatted = deleted.join(',')
153+
removedFormatted = removed.join(',')
154154
renamedFormatted = renamed.join(',')
155155
addedModifiedFormatted = addedModified.join(',')
156156
break
157157
case 'json':
158158
allFormatted = JSON.stringify(all)
159159
addedFormatted = JSON.stringify(added)
160160
modifiedFormatted = JSON.stringify(modified)
161-
deletedFormatted = JSON.stringify(deleted)
161+
removedFormatted = JSON.stringify(removed)
162162
renamedFormatted = JSON.stringify(renamed)
163163
addedModifiedFormatted = JSON.stringify(addedModified)
164164
break
@@ -168,17 +168,20 @@ async function run(): Promise<void> {
168168
core.info(`All: ${allFormatted}`)
169169
core.info(`Added: ${addedFormatted}`)
170170
core.info(`Modified: ${modifiedFormatted}`)
171-
core.info(`Deleted: ${deletedFormatted}`)
171+
core.info(`Removed: ${removedFormatted}`)
172172
core.info(`Renamed: ${renamedFormatted}`)
173173
core.info(`Added or modified: ${addedModifiedFormatted}`)
174174

175175
// Set step output context.
176176
core.setOutput('all', allFormatted)
177177
core.setOutput('added', addedFormatted)
178178
core.setOutput('modified', modifiedFormatted)
179-
core.setOutput('deleted', deletedFormatted)
179+
core.setOutput('removed', removedFormatted)
180180
core.setOutput('renamed', renamedFormatted)
181181
core.setOutput('added_modified', addedModifiedFormatted)
182+
183+
// For backwards-compatibility
184+
core.setOutput('deleted', removedFormatted)
182185
} catch (error) {
183186
core.setFailed(error.message)
184187
}

0 commit comments

Comments
 (0)