Skip to content

Commit 7549963

Browse files
committed
Convert DOS to UNIX
1 parent e30aaac commit 7549963

6 files changed

Lines changed: 131 additions & 126 deletions

File tree

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ensure shell scripts always use LF line endings
2+
*.sh text eol=lf
3+
4+
# Ensure Gradle wrapper script uses LF line endings
5+
gradlew text eol=lf

.github/workflows/_copyright.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ jobs:
1616
uses: actions/checkout@v4
1717

1818
- name: Check for missing copyright headers
19-
run: ./scripts/check-copyright.sh
19+
run: bash ./scripts/check-copyright.sh

.github/workflows/_format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ jobs:
3535
run: chmod +x gradlew
3636

3737
- name: Run Spotless check
38-
run: ./scripts/check-format.sh
38+
run: bash ./scripts/check-format.sh

scripts/check-copyright.sh

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
#!/bin/bash
2-
3-
# Check for missing MIT copyright headers in Kotlin files
4-
# Returns 0 if all files have headers, 1 if any are missing
5-
6-
MISSING_FILES=()
7-
8-
while IFS= read -r file; do
9-
if ! grep -q "SPDX-License-Identifier: MIT" "$file"; then
10-
MISSING_FILES+=("$file")
11-
fi
12-
done < <(find . -type f \( -name "*.kt" -o -name "*.kts" \) \
13-
-not -path "*/build/*" \
14-
-not -path "*/.gradle/*")
15-
16-
if [ ${#MISSING_FILES[@]} -gt 0 ]; then
17-
echo ""
18-
echo "ERROR: The following files are missing the MIT copyright header:"
19-
echo ""
20-
for file in "${MISSING_FILES[@]}"; do
21-
echo " - $file"
22-
done
23-
echo ""
24-
echo "Required header format:"
25-
echo "/*"
26-
echo " * Copyright (c) 2025 Alexander Farber"
27-
echo " * SPDX-License-Identifier: MIT"
28-
echo " *"
29-
echo " * This file is part of the OpenMapView project (https://github.com/afarber/OpenMapView)"
30-
echo " */"
31-
echo ""
32-
echo "Run './gradlew spotlessApply' to automatically add headers."
33-
echo ""
34-
exit 1
35-
fi
36-
37-
echo "All Kotlin files have proper copyright headers."
38-
exit 0
1+
#!/bin/bash
2+
3+
# Check for missing MIT copyright headers in Kotlin files
4+
# Returns 0 if all files have headers, 1 if any are missing
5+
6+
MISSING_FILES=()
7+
8+
while IFS= read -r file; do
9+
if ! grep -q "SPDX-License-Identifier: MIT" "$file"; then
10+
MISSING_FILES+=("$file")
11+
fi
12+
done < <(find . -type f \( -name "*.kt" -o -name "*.kts" \) \
13+
-not -path "*/build/*" \
14+
-not -path "*/.gradle/*")
15+
16+
if [ ${#MISSING_FILES[@]} -gt 0 ]; then
17+
echo ""
18+
echo "ERROR: The following files are missing the MIT copyright header:"
19+
echo ""
20+
for file in "${MISSING_FILES[@]}"; do
21+
echo " - $file"
22+
done
23+
echo ""
24+
echo "Required header format:"
25+
echo "/*"
26+
echo " * Copyright (c) 2025 Alexander Farber"
27+
echo " * SPDX-License-Identifier: MIT"
28+
echo " *"
29+
echo " * This file is part of the OpenMapView project (https://github.com/afarber/OpenMapView)"
30+
echo " */"
31+
echo ""
32+
echo "Run './gradlew spotlessApply' to automatically add headers."
33+
echo ""
34+
exit 1
35+
fi
36+
37+
echo "All Kotlin files have proper copyright headers."
38+
exit 0

scripts/check-format.sh

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
#!/bin/bash
2-
3-
# Check code formatting with Spotless
4-
# Returns 0 if formatting is correct, 1 if issues are found
5-
6-
echo "Checking code formatting with Spotless..."
7-
8-
./gradlew spotlessCheck
9-
10-
if [ $? -ne 0 ]; then
11-
echo ""
12-
echo "Code formatting check failed!"
13-
echo "Run './gradlew spotlessApply' to fix formatting issues."
14-
echo ""
15-
exit 1
16-
fi
17-
18-
echo "Code formatting is correct."
19-
exit 0
1+
#!/bin/bash
2+
3+
# Check code formatting with Spotless
4+
# Returns 0 if formatting is correct, 1 if issues are found
5+
6+
echo "Checking code formatting with Spotless..."
7+
8+
./gradlew spotlessCheck
9+
10+
if [ $? -ne 0 ]; then
11+
echo ""
12+
echo "Code formatting check failed!"
13+
echo "Run './gradlew spotlessApply' to fix formatting issues."
14+
echo ""
15+
exit 1
16+
fi
17+
18+
echo "Code formatting is correct."
19+
exit 0

scripts/setup-git-hooks.sh

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
1-
#!/bin/bash
2-
3-
# Setup Git hooks for OpenMapView
4-
# This script installs a pre-commit hook that checks code formatting and copyright headers
5-
6-
HOOKS_DIR=".git/hooks"
7-
HOOK_FILE="$HOOKS_DIR/pre-commit"
8-
9-
# Check if .git directory exists
10-
if [ ! -d ".git" ]; then
11-
echo "Error: .git directory not found. Run this script from the repository root."
12-
exit 1
13-
fi
14-
15-
# Create hooks directory if it doesn't exist
16-
mkdir -p "$HOOKS_DIR"
17-
18-
# Create pre-commit hook
19-
cat > "$HOOK_FILE" << 'EOF'
20-
#!/bin/bash
21-
22-
echo "Running pre-commit checks..."
23-
echo ""
24-
25-
# Check code formatting
26-
echo "1. Checking code formatting..."
27-
./scripts/check-format.sh > /dev/null 2>&1
28-
29-
if [ $? -ne 0 ]; then
30-
echo ""
31-
echo "Code formatting check failed!"
32-
echo "Run './gradlew spotlessApply' to fix formatting issues."
33-
echo ""
34-
exit 1
35-
fi
36-
37-
echo " Code formatting: OK"
38-
39-
# Check copyright headers
40-
echo "2. Checking copyright headers..."
41-
./scripts/check-copyright.sh > /dev/null 2>&1
42-
43-
if [ $? -ne 0 ]; then
44-
echo ""
45-
echo "Copyright header check failed!"
46-
echo "Run './gradlew spotlessApply' to fix issues."
47-
echo ""
48-
exit 1
49-
fi
50-
51-
echo " Copyright headers: OK"
52-
echo ""
53-
echo "All pre-commit checks passed!"
54-
EOF
55-
56-
# Make hook executable
57-
chmod +x "$HOOK_FILE"
58-
59-
echo "Git hooks installed successfully!"
60-
echo ""
61-
echo "Pre-commit hook will now:"
62-
echo " - Check code formatting before each commit"
63-
echo " - Check copyright headers on all Kotlin files"
64-
echo " - Block commits if issues are found"
65-
echo " - Prompt to run './gradlew spotlessApply' to fix issues"
66-
echo ""
67-
echo "To bypass the hook (not recommended), use: git commit --no-verify"
1+
#!/bin/bash
2+
3+
# Setup Git hooks for OpenMapView
4+
# This script installs a pre-commit hook that checks code formatting and copyright headers
5+
6+
HOOKS_DIR=".git/hooks"
7+
HOOK_FILE="$HOOKS_DIR/pre-commit"
8+
9+
# Check if .git directory exists
10+
if [ ! -d ".git" ]; then
11+
echo "Error: .git directory not found. Run this script from the repository root."
12+
exit 1
13+
fi
14+
15+
# Create hooks directory if it doesn't exist
16+
mkdir -p "$HOOKS_DIR"
17+
18+
# Create pre-commit hook
19+
cat > "$HOOK_FILE" << 'EOF'
20+
#!/bin/bash
21+
22+
echo "Running pre-commit checks..."
23+
echo ""
24+
25+
# Check code formatting
26+
echo "1. Checking code formatting..."
27+
./scripts/check-format.sh > /dev/null 2>&1
28+
29+
if [ $? -ne 0 ]; then
30+
echo ""
31+
echo "Code formatting check failed!"
32+
echo "Run './gradlew spotlessApply' to fix formatting issues."
33+
echo ""
34+
exit 1
35+
fi
36+
37+
echo " Code formatting: OK"
38+
39+
# Check copyright headers
40+
echo "2. Checking copyright headers..."
41+
./scripts/check-copyright.sh > /dev/null 2>&1
42+
43+
if [ $? -ne 0 ]; then
44+
echo ""
45+
echo "Copyright header check failed!"
46+
echo "Run './gradlew spotlessApply' to fix issues."
47+
echo ""
48+
exit 1
49+
fi
50+
51+
echo " Copyright headers: OK"
52+
echo ""
53+
echo "All pre-commit checks passed!"
54+
EOF
55+
56+
# Make hook executable
57+
chmod +x "$HOOK_FILE"
58+
59+
echo "Git hooks installed successfully!"
60+
echo ""
61+
echo "Pre-commit hook will now:"
62+
echo " - Check code formatting before each commit"
63+
echo " - Check copyright headers on all Kotlin files"
64+
echo " - Block commits if issues are found"
65+
echo " - Prompt to run './gradlew spotlessApply' to fix issues"
66+
echo ""
67+
echo "To bypass the hook (not recommended), use: git commit --no-verify"

0 commit comments

Comments
 (0)