Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
feat: add filtered diff
Browse files Browse the repository at this point in the history
  • Loading branch information
technote-space committed Feb 18, 2020
1 parent 84c3fd5 commit 818b774
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
35 changes: 20 additions & 15 deletions __tests__/process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ describe('setResult', () => {

stdoutCalledWith(mockStdout, [
'::group::Dump output',
'::set-output name=diff::test1 test2',
'::set-env name=GIT_DIFF::test1 test2',
'"diff: test1 test2"',
'::set-output name=diff_all::test1 test2 test4',
'"diff_all: test1 test2 test4"',
'::set-output name=diff::test1 test2 test4',
'::set-env name=GIT_DIFF::test1 test2 test4',
'"diff: test1 test2 test4"',
'::set-output name=filtered_diff::test1 test2',
'::set-env name=GIT_DIFF_FILTERED::test1 test2',
'"filtered_diff: test1 test2"',
'::set-output name=count::3',
'"count: 3"',
'::set-output name=insertions::3',
Expand All @@ -128,10 +129,11 @@ describe('setResult', () => {

stdoutCalledWith(mockStdout, [
'::group::Dump output',
'::set-output name=diff::test1 test2',
'"diff: test1 test2"',
'::set-output name=diff_all::test1 test2 test4',
'"diff_all: test1 test2 test4"',
'::set-output name=diff::test1 test2 test4',
'"diff: test1 test2 test4"',
'::set-output name=filtered_diff::test1 test2',
'::set-env name=GIT_DIFF_FILTERED::test1 test2',
'"filtered_diff: test1 test2"',
'::set-output name=count::3',
'::set-env name=FILE_COUNT::3',
'"count: 3"',
Expand Down Expand Up @@ -242,8 +244,9 @@ describe('execute', () => {
'::set-output name=diff::\'package.json\' \'abc/composer.json\' \'README.md\' \'src/main.ts\'',
'::set-env name=GIT_DIFF::\'package.json\' \'abc/composer.json\' \'README.md\' \'src/main.ts\'',
'"diff: \'package.json\' \'abc/composer.json\' \'README.md\' \'src/main.ts\'"',
'::set-output name=diff_all::\'package.json\' \'abc/composer.json\' \'README.md\' \'src/main.ts\'',
'"diff_all: \'package.json\' \'abc/composer.json\' \'README.md\' \'src/main.ts\'"',
'::set-output name=filtered_diff::\'package.json\' \'abc/composer.json\' \'README.md\' \'src/main.ts\'',
'::set-env name=GIT_DIFF_FILTERED::\'package.json\' \'abc/composer.json\' \'README.md\' \'src/main.ts\'',
'"filtered_diff: \'package.json\' \'abc/composer.json\' \'README.md\' \'src/main.ts\'"',
'::set-output name=count::4',
'"count: 4"',
'::set-output name=insertions::100',
Expand Down Expand Up @@ -273,8 +276,9 @@ describe('execute', () => {
'::set-output name=diff::',
'::set-env name=GIT_DIFF::',
'"diff: "',
'::set-output name=diff_all::',
'"diff_all: "',
'::set-output name=filtered_diff::',
'::set-env name=GIT_DIFF_FILTERED::',
'"filtered_diff: "',
'::set-output name=count::0',
'"count: 0"',
'::set-output name=insertions::0',
Expand Down Expand Up @@ -317,8 +321,9 @@ describe('execute', () => {
'::set-output name=diff::',
'::set-env name=GIT_DIFF::',
'"diff: "',
'::set-output name=diff_all::',
'"diff_all: "',
'::set-output name=filtered_diff::',
'::set-env name=GIT_DIFF_FILTERED::',
'"filtered_diff: "',
'::set-output name=count::0',
'"count: 0"',
'::set-output name=insertions::0',
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ inputs:
description: Env name (diff).
default: GIT_DIFF
required: false
SET_ENV_NAME_FILTERED_DIFF:
description: Env name (filtered_diff).
default: GIT_DIFF_FILTERED
required: false
SET_ENV_NAME_COUNT:
description: Env name (count).
required: false
Expand All @@ -56,6 +60,8 @@ inputs:
outputs:
diff:
description: The results of diff file names.
filtered_diff:
description: The results of diff file names.
count:
description: The number of diff files.
insertions:
Expand Down
4 changes: 2 additions & 2 deletions src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const setResult = (diffs: DiffResult[], logger: Logger): void => {

logger.startProcess('Dump output');
[
{name: 'diff', value: getDiffFiles(diffs, true), envNameSuffix: ''},
{name: 'diff_all', value: getDiffFiles(diffs, false)},
{name: 'diff', value: getDiffFiles(diffs, false), envNameSuffix: ''},
{name: 'filtered_diff', value: getDiffFiles(diffs, true)},
{name: 'count', value: diffs.length},
{name: 'insertions', value: insertions},
{name: 'deletions', value: deletions},
Expand Down

0 comments on commit 818b774

Please sign in to comment.