Skip to content

Commit 651fbd4

Browse files
committed
Trim git diff output to modified files only
Signed-off-by: Kyle Harding <[email protected]>
1 parent 3f97ae9 commit 651fbd4

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

.github/workflows/flowzone.yml

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flowzone.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,6 +2794,7 @@ jobs:
27942794
with:
27952795
script: |
27962796
const { execSync } = require('child_process');
2797+
const { format } = require('util');
27972798
27982799
// Parse the JSON input
27992800
const stacks = JSON.parse(process.env.TEMPLATES_JSON);
@@ -2814,16 +2815,17 @@ jobs:
28142815
// Get modified files between BASE and HEAD
28152816
const getModifiedFiles = () => {
28162817
const diff = execSync(
2817-
`git diff --submodule=diff "${process.env.BASE_SHA}" "${process.env.HEAD_SHA}"`,
2818+
format('sh -c "git diff --submodule=diff %s %s | sed -rn \'s|^--- a/(.*)$|\\1|p\'"',
2819+
process.env.BASE_SHA,
2820+
process.env.HEAD_SHA
2821+
),
28182822
{ encoding: 'utf8' }
28192823
);
2820-
return diff
2821-
.split('\n')
2822-
.filter(line => line.startsWith('--- a/'))
2823-
.map(line => line.replace('--- a/', ''));
2824+
return diff.split('\n').filter(f => f != null && !!f.trim())
28242825
};
28252826
28262827
const modifiedFiles = getModifiedFiles();
2828+
console.log(`modifiedFiles:\n${modifiedFiles}`)
28272829
28282830
// Filter out unmodified stacks
28292831
stackNames = stackNames.filter(stackName => {

0 commit comments

Comments
 (0)