Check to see if file exists or not before running uncrustify.
The file in change list may be a deleted file.

Signed-off-by: Nickle Wang <nick...@nvidia.com>
Cc: Abner Chang <abner.ch...@amd.com>
Cc: Igor Kulchytskyy <ig...@ami.com>
---
 .github/workflows/uncrustify-check.sh | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/uncrustify-check.sh 
b/.github/workflows/uncrustify-check.sh
index 7c1765cff..e6cf00b1f 100755
--- a/.github/workflows/uncrustify-check.sh
+++ b/.github/workflows/uncrustify-check.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights 
reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -40,12 +40,17 @@ fi
 
 for file in $CHANGED_FILES
 do
-  echo "Uncrustify check file: $file"
-  uncrustify -c $CONFIG_FILE -f $file --check
-  if [ $? -ne 0 ]
+  if [ -e "$file" ]
   then
-    echo "Uncrustify check failure on file: $file"
-    FAILURE=1
+    echo "Uncrustify check file: $file"
+    uncrustify -c $CONFIG_FILE -f $file --check
+    if [ $? -ne 0 ]
+    then
+      echo "Uncrustify check failure on file: $file"
+      FAILURE=1
+    fi
+  else
+    echo "File does not exist (deleted file?): $file"
   fi
 done
 
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116141): https://edk2.groups.io/g/devel/message/116141
Mute This Topic: https://groups.io/mt/104640215/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to