Skip to content

Commit 109e917

Browse files
committed
feat: support skiping if no files found
Signed-off-by: Atkins Chang <atkinschang@gmail.com>
1 parent 1566bce commit 109e917

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

action.yml

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ inputs:
2929
description: 'Just fix files (`clang-format -i`) instead of returning a diff'
3030
required: false
3131
default: False
32+
skipIfNoFilesFound:
33+
description: 'Skip if no files found'
34+
required: false
35+
default: False
3236
runs:
3337
using: 'docker'
3438
image: 'Dockerfile'
@@ -46,4 +50,6 @@ runs:
4650
- ${{ inputs.extensions }}
4751
- --exclude
4852
- ${{ inputs.exclude }}
53+
- --skip-if-no-files-found
54+
- ${{ inputs.skipIfNoFilesFound }}
4955
- ${{ inputs.source }}

run-clang-format.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,14 @@ def main():
304304
type=lambda x: bool(strtobool(x)),
305305
default=False,
306306
help='Just fix files (`clang-format -i`) instead of returning a diff')
307+
parser.add_argument(
308+
'-s',
309+
'--skip-if-no-files-found',
310+
type=lambda x: bool(strtobool(x)),
311+
default=False,
312+
help='Skip if no files found')
313+
314+
307315

308316
args = parser.parse_args()
309317

@@ -356,7 +364,10 @@ def main():
356364

357365
if not files:
358366
print_trouble(parser.prog, 'No files found', use_colors=colored_stderr)
359-
return ExitStatus.TROUBLE
367+
if args.skip_if_no_files_found:
368+
return ExitStatus.SUCCESS
369+
else:
370+
return ExitStatus.TROUBLE
360371

361372
if not args.quiet:
362373
print('Processing %s files: %s' % (len(files), ', '.join(files)))

0 commit comments

Comments
 (0)