mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-05 02:30:26 +08:00
fix: 修復 wsl install.sh 格式問題 (#78)
This commit is contained in:
22
.gitattributes
vendored
Normal file
22
.gitattributes
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Ensure shell scripts always use LF line endings on all platforms
|
||||||
|
*.sh text eol=lf
|
||||||
|
|
||||||
|
# Ensure Python files use LF line endings
|
||||||
|
*.py text eol=lf
|
||||||
|
|
||||||
|
# Auto-detect text files and normalize line endings to LF
|
||||||
|
* text=auto eol=lf
|
||||||
|
|
||||||
|
# Explicitly declare files that should always be treated as binary
|
||||||
|
*.exe binary
|
||||||
|
*.png binary
|
||||||
|
*.jpg binary
|
||||||
|
*.jpeg binary
|
||||||
|
*.gif binary
|
||||||
|
*.ico binary
|
||||||
|
*.mov binary
|
||||||
|
*.mp4 binary
|
||||||
|
*.mp3 binary
|
||||||
|
*.zip binary
|
||||||
|
*.gz binary
|
||||||
|
*.tar binary
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Get staged files
|
# Get staged files
|
||||||
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)
|
STAGED_FILES="$(git diff --cached --name-only --diff-filter=ACM)"
|
||||||
|
|
||||||
if [ -z "$STAGED_FILES" ]; then
|
if [ -z "$STAGED_FILES" ]; then
|
||||||
echo "No files to validate"
|
echo "No files to validate"
|
||||||
@@ -15,17 +15,32 @@ fi
|
|||||||
echo "Running pre-commit checks..."
|
echo "Running pre-commit checks..."
|
||||||
|
|
||||||
# Check Go files
|
# Check Go files
|
||||||
GO_FILES=$(echo "$STAGED_FILES" | grep '\.go$' || true)
|
GO_FILES="$(printf '%s\n' "$STAGED_FILES" | grep '\.go$' || true)"
|
||||||
if [ -n "$GO_FILES" ]; then
|
if [ -n "$GO_FILES" ]; then
|
||||||
echo "Checking Go files..."
|
echo "Checking Go files..."
|
||||||
|
|
||||||
# Format check
|
if ! command -v gofmt &> /dev/null; then
|
||||||
gofmt -l $GO_FILES | while read -r file; do
|
echo "❌ gofmt not found. Please install Go (gofmt is included with the Go toolchain)."
|
||||||
if [ -n "$file" ]; then
|
|
||||||
echo "❌ $file needs formatting (run: gofmt -w $file)"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
# Format check
|
||||||
|
GO_FILE_ARGS=()
|
||||||
|
while IFS= read -r file; do
|
||||||
|
if [ -n "$file" ]; then
|
||||||
|
GO_FILE_ARGS+=("$file")
|
||||||
|
fi
|
||||||
|
done <<< "$GO_FILES"
|
||||||
|
|
||||||
|
if [ "${#GO_FILE_ARGS[@]}" -gt 0 ]; then
|
||||||
|
UNFORMATTED="$(gofmt -l "${GO_FILE_ARGS[@]}")"
|
||||||
|
if [ -n "$UNFORMATTED" ]; then
|
||||||
|
echo "❌ The following files need formatting:"
|
||||||
|
echo "$UNFORMATTED"
|
||||||
|
echo "Run: gofmt -w <file>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
if command -v go &> /dev/null; then
|
if command -v go &> /dev/null; then
|
||||||
@@ -38,19 +53,26 @@ if [ -n "$GO_FILES" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check JSON files
|
# Check JSON files
|
||||||
JSON_FILES=$(echo "$STAGED_FILES" | grep '\.json$' || true)
|
JSON_FILES="$(printf '%s\n' "$STAGED_FILES" | grep '\.json$' || true)"
|
||||||
if [ -n "$JSON_FILES" ]; then
|
if [ -n "$JSON_FILES" ]; then
|
||||||
echo "Validating JSON files..."
|
echo "Validating JSON files..."
|
||||||
for file in $JSON_FILES; do
|
if ! command -v jq &> /dev/null; then
|
||||||
|
echo "❌ jq not found. Please install jq to validate JSON files."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
while IFS= read -r file; do
|
||||||
|
if [ -z "$file" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
if ! jq empty "$file" 2>/dev/null; then
|
if ! jq empty "$file" 2>/dev/null; then
|
||||||
echo "❌ Invalid JSON: $file"
|
echo "❌ Invalid JSON: $file"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done <<< "$JSON_FILES"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check Markdown files
|
# Check Markdown files
|
||||||
MD_FILES=$(echo "$STAGED_FILES" | grep '\.md$' || true)
|
MD_FILES="$(printf '%s\n' "$STAGED_FILES" | grep '\.md$' || true)"
|
||||||
if [ -n "$MD_FILES" ]; then
|
if [ -n "$MD_FILES" ]; then
|
||||||
echo "Checking markdown files..."
|
echo "Checking markdown files..."
|
||||||
# Add markdown linting if needed
|
# Add markdown linting if needed
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
if [ -z "${SKIP_WARNING:-}" ]; then
|
||||||
echo "⚠️ WARNING: install.sh is LEGACY and will be removed in future versions."
|
echo "⚠️ WARNING: install.sh is LEGACY and will be removed in future versions."
|
||||||
echo "Please use the new installation method:"
|
echo "Please use the new installation method:"
|
||||||
echo " python3 install.py --install-dir ~/.claude"
|
echo " python3 install.py --install-dir ~/.claude"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "Set SKIP_WARNING=1 to bypass this message"
|
||||||
echo "Continuing with legacy installation in 5 seconds..."
|
echo "Continuing with legacy installation in 5 seconds..."
|
||||||
sleep 5
|
sleep 5
|
||||||
|
fi
|
||||||
|
|
||||||
# Detect platform
|
# Detect platform
|
||||||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
|
|||||||
Reference in New Issue
Block a user