Skip to content

Commit 89b4446

Browse files
authored
Merge pull request #4239 from graphql-java/copilot/rename-windows-incompatible-files
Fix Windows compatibility: rename files with reserved chars, split large files, add pre-commit hook and CI validation
2 parents 2f0dc5b + 12cc43a commit 89b4446

249 files changed

Lines changed: 106420 additions & 106175 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.githooks/pre-commit‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
3+
# Pre-commit hook to enforce Windows compatibility and file size limits
4+
#
5+
# 1. Windows filenames: prevents characters that are reserved on Windows (< > : " | ? * \)
6+
# so the repo can be cloned on Windows systems.
7+
# 2. File size: rejects files larger than 10 MB. Many enterprise users mirror graphql-java
8+
# into internal repositories that enforce file size limits.
9+
10+
# ANSI color codes for better output readability
11+
RED='\033[0;31m'
12+
YELLOW='\033[1;33m'
13+
NC='\033[0m' # No Color
14+
15+
# Track if we found any errors
16+
ERRORS_FOUND=0
17+
18+
echo "Running pre-commit checks..."
19+
20+
# Check 1: Windows-incompatible filenames
21+
echo " Checking for Windows-incompatible filenames..."
22+
23+
# Windows reserved characters: < > : " | ? * \
24+
# Note: We escape the backslash in the regex pattern
25+
INVALID_CHARS='[<>:"|?*\\]'
26+
27+
# Get list of staged files
28+
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACR)
29+
30+
if [ -n "$STAGED_FILES" ]; then
31+
# Check each staged file for invalid characters
32+
INVALID_FILES=$(echo "$STAGED_FILES" | grep -E "$INVALID_CHARS" || true)
33+
34+
if [ -n "$INVALID_FILES" ]; then
35+
echo -e "${RED}Error: The following files have Windows-incompatible characters in their names:${NC}"
36+
echo "$INVALID_FILES" | while read -r file; do
37+
echo " - $file"
38+
done
39+
echo -e "${YELLOW}Please rename these files to remove characters: < > : \" | ? * \\${NC}"
40+
echo -e "${YELLOW}For ISO timestamps, replace colons with hyphens (e.g., 08:40:24 -> 08-40-24)${NC}"
41+
ERRORS_FOUND=1
42+
fi
43+
fi
44+
45+
# Check 2: Files larger than 10MB
46+
echo " Checking for files larger than 10MB..."
47+
48+
MAX_SIZE=$((10 * 1024 * 1024)) # 10 MB in bytes
49+
LARGE_FILES=""
50+
51+
if [ -n "$STAGED_FILES" ]; then
52+
while IFS= read -r file; do
53+
if [ -f "$file" ]; then
54+
# Try to get file size with cross-platform compatibility
55+
size=$(stat -c%s "$file" 2>/dev/null || stat -f%z "$file" 2>/dev/null)
56+
if [ -z "$size" ]; then
57+
echo -e "${YELLOW}Warning: Could not determine size of $file, skipping size check${NC}"
58+
continue
59+
fi
60+
if [ "$size" -gt "$MAX_SIZE" ]; then
61+
# Format size in human-readable format using awk (more portable than bc)
62+
size_mb=$(awk "BEGIN {printf \"%.2f\", $size/1024/1024}")
63+
LARGE_FILES="${LARGE_FILES} - $file (${size_mb} MB)\n"
64+
fi
65+
fi
66+
done <<< "$STAGED_FILES"
67+
fi
68+
69+
if [ -n "$LARGE_FILES" ]; then
70+
echo -e "${RED}Error: The following files exceed 10MB:${NC}"
71+
echo -e "$LARGE_FILES"
72+
echo -e "${YELLOW}Please consider one of these options:${NC}"
73+
echo -e "${YELLOW} 1. Split the file into smaller parts with suffixes .part1, .part2, etc.${NC}"
74+
echo -e "${YELLOW} 2. Remove unnecessary content from the file${NC}"
75+
ERRORS_FOUND=1
76+
fi
77+
78+
# Exit with error if any checks failed
79+
if [ "$ERRORS_FOUND" -eq 1 ]; then
80+
echo -e "${RED}Pre-commit checks failed. Please fix the issues above and try again.${NC}"
81+
exit 1
82+
fi
83+
84+
echo " All pre-commit checks passed!"
85+
exit 0
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Validate Files
2+
3+
# This workflow validates that all files in the repository comply with:
4+
# 1. Windows filename compatibility — no reserved characters (< > : " | ? * \)
5+
# so the repo can be cloned on Windows systems.
6+
# 2. File size limits — no files larger than 10 MB. Many enterprise users mirror
7+
# graphql-java into internal repositories that enforce file size limits.
8+
9+
on:
10+
push:
11+
branches:
12+
- master
13+
- '**'
14+
pull_request:
15+
branches:
16+
- master
17+
- 23.x
18+
- 22.x
19+
- 21.x
20+
- 20.x
21+
- 19.x
22+
23+
jobs:
24+
validate-filenames-and-size:
25+
runs-on: ubuntu-latest
26+
name: Validate Windows Compatibility and File Sizes
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v6
30+
with:
31+
fetch-depth: 0 # Fetch all history to check all files
32+
33+
- name: Check for Windows-incompatible filenames
34+
run: |
35+
echo "Checking for Windows-incompatible filenames..."
36+
37+
# Windows reserved characters: < > : " | ? * \
38+
INVALID_CHARS='[<>:"|?*\\]'
39+
40+
# Get all files in the repository (excluding .git directory)
41+
ALL_FILES=$(git ls-files)
42+
43+
# Check each file for invalid characters
44+
INVALID_FILES=$(echo "$ALL_FILES" | grep -E "$INVALID_CHARS" || true)
45+
46+
if [ -n "$INVALID_FILES" ]; then
47+
echo "::error::The following files have Windows-incompatible characters in their names:"
48+
echo "$INVALID_FILES" | while read -r file; do
49+
echo "::error file=${file}::File contains Windows-incompatible characters"
50+
echo " - $file"
51+
done
52+
echo ""
53+
echo "Please rename these files to remove characters: < > : \" | ? * \\"
54+
echo "For ISO timestamps, replace colons with hyphens (e.g., 08:40:24 -> 08-40-24)"
55+
exit 1
56+
else
57+
echo "✓ All filenames are Windows-compatible"
58+
fi
59+
60+
- name: Check for files larger than 10MB
61+
run: |
62+
echo "Checking for files larger than 10MB..."
63+
64+
MAX_SIZE=$((10 * 1024 * 1024)) # 10 MB in bytes
65+
LARGE_FILES=""
66+
67+
# Get all files in the repository (excluding .git directory)
68+
ALL_FILES=$(git ls-files)
69+
70+
# Check each file's size
71+
while IFS= read -r file; do
72+
if [ -f "$file" ]; then
73+
size=$(stat -c%s "$file" 2>/dev/null || stat -f%z "$file" 2>/dev/null)
74+
if [ -z "$size" ]; then
75+
echo "::warning file=${file}::Could not determine size of file"
76+
continue
77+
fi
78+
if [ "$size" -gt "$MAX_SIZE" ]; then
79+
size_mb=$(awk "BEGIN {printf \"%.2f\", $size/1024/1024}")
80+
echo "::error file=${file}::File size (${size_mb} MB) exceeds 10MB limit"
81+
LARGE_FILES="${LARGE_FILES}${file} (${size_mb} MB)\n"
82+
fi
83+
fi
84+
done <<< "$ALL_FILES"
85+
86+
if [ -n "$LARGE_FILES" ]; then
87+
echo ""
88+
echo "The following files exceed 10MB:"
89+
echo -e "$LARGE_FILES"
90+
echo ""
91+
echo "Please consider one of these options:"
92+
echo " 1. Split the file into smaller parts with suffixes .part1, .part2, etc."
93+
echo " 2. Remove unnecessary content from the file"
94+
exit 1
95+
else
96+
echo "✓ All files are within the 10MB size limit"
97+
fi

‎CONTRIBUTING.md‎

Lines changed: 27 additions & 0 deletions

performance-results/2024-11-28T01:53:48Z-1d50c655aaf1a907b65f39e2eba310f3463ba5d5-jdk17.json renamed to performance-results/2024-11-28T01-53-48Z-1d50c655aaf1a907b65f39e2eba310f3463ba5d5-jdk17.json

File renamed without changes.

performance-results/2024-11-28T03:56:43Z-a3fcfcb843b2104f40e75940cea4ed03e6de12c0-jdk17.json renamed to performance-results/2024-11-28T03-56-43Z-a3fcfcb843b2104f40e75940cea4ed03e6de12c0-jdk17.json

File renamed without changes.

performance-results/2024-12-03T01:09:26Z-9d6e31e367f7b2929dd393a694dc05a0c5bb6e1a-jdk17.json renamed to performance-results/2024-12-03T01-09-26Z-9d6e31e367f7b2929dd393a694dc05a0c5bb6e1a-jdk17.json

File renamed without changes.

performance-results/2024-12-04T02:33:30Z-3e5c77ba3f27de559a65c42684fc7deb9dead263-jdk17.json renamed to performance-results/2024-12-04T02-33-30Z-3e5c77ba3f27de559a65c42684fc7deb9dead263-jdk17.json

File renamed without changes.

performance-results/2024-12-05T21:56:29Z-08cf1702ce0c96ee0ed414ee8085a75696bc6cae-jdk17.json renamed to performance-results/2024-12-05T21-56-29Z-08cf1702ce0c96ee0ed414ee8085a75696bc6cae-jdk17.json

File renamed without changes.

performance-results/2024-12-08T08:18:55Z-3d46b3737bf4f0c617425af4c63036a1336a7423-jdk17.json renamed to performance-results/2024-12-08T08-18-55Z-3d46b3737bf4f0c617425af4c63036a1336a7423-jdk17.json

File renamed without changes.

performance-results/2024-12-08T22:54:25Z-46c03234896e2ffad02a5dbf704a721ea0717c67-jdk17.json renamed to performance-results/2024-12-08T22-54-25Z-46c03234896e2ffad02a5dbf704a721ea0717c67-jdk17.json

File renamed without changes.

0 commit comments

Comments
 (0)