Skip to content

Commit 31e549c

Browse files
authored
fix(update-checker): check for untracked files (#96)
1 parent 6c25668 commit 31e549c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

.github/scripts/update-checker.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,19 @@ check_gitattributes() {
279279
# Check for trailing newline and whitespace-only lines in all files
280280
check_file_formatting() {
281281
local file
282+
283+
# Check if git command exists
284+
if ! command -v git >/dev/null 2>&1; then
285+
info_messages+=("git command not found, skipping file formatting checks")
286+
return
287+
fi
288+
289+
# Check for untracked files
290+
if [[ -n "$(git ls-files --others --exclude-standard 2>/dev/null)" ]]; then
291+
actions+=("Untracked files exist. Please stage or remove them before running file formatting checks.")
292+
return
293+
fi
294+
282295
# Get all tracked files from git, excluding binary files and specific patterns
283296
while IFS= read -r -d '' file; do
284297
# Skip binary files and images
@@ -295,7 +308,7 @@ check_file_formatting() {
295308
if grep -qn '^[[:space:]]\+$' "$file" 2>/dev/null; then
296309
actions+=("$file contains lines with only spaces/tabs, remove trailing whitespace")
297310
fi
298-
done < <(git ls-files -z 2>/dev/null | grep -zv '^tests/testdata/' || find . -type f -not -path './.git/*' -not -path './tests/testdata/*' -print0 2>/dev/null)
311+
done < <(git ls-files -z 2>/dev/null | grep -zv '^tests/testdata/')
299312
}
300313

301314
# Main function

0 commit comments

Comments
 (0)