mql-check-binary-surprises/check-surprises.sh

48 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2025-07-02 21:29:37 -07:00
#!/bin/bash
2025-07-02 21:58:39 -07:00
# Check if the current directory is already a git repository
2025-07-02 21:35:09 -07:00
if [ -d ".git" ]; then
echo "Error: Git repository already exists."
exit 1
fi
2025-07-02 23:31:14 -07:00
# Check if .gitignore already exists in the current directory or any subdirectory
gitignore_path=$(find . -name ".gitignore" -print -quit)
if [ -n "$gitignore_path" ]; then
echo "Error: .gitignore file already exists at '$gitignore_path'."
2025-07-02 23:31:14 -07:00
exit 1
fi
2025-07-02 21:58:39 -07:00
# Create .gitignore file
2025-07-02 21:29:37 -07:00
cat <<EOL > .gitignore
*
!*.mqh
!*.mq5
!*.mq4
!*/
!**/*.mqh
!**/*.mq5
!**/*.mq4
EOL
2025-07-02 21:58:39 -07:00
# Initialize git repository
2025-07-02 21:29:37 -07:00
git init
2025-07-02 21:58:39 -07:00
# Add all files to the staging area
2025-07-02 21:29:37 -07:00
git add .
2025-07-02 21:58:39 -07:00
# Count how many files are in the index
file_count=$(git ls-files | wc -l)
echo "Number of files in the index: $file_count"
2025-07-02 21:58:39 -07:00
# Execute the command to check eolinfo for files in the index
2025-07-02 23:15:18 -07:00
broken_files=$(git ls-files --format='%(eolinfo:index) %(path)' | column -t | grep '\-text')
# Check if any broken files were found and print the appropriate message
if [ -z "$broken_files" ]; then
echo "No broken files found."
else
echo "Broken files:"
echo "$broken_files"
fi