mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-01-26 11:14:08 +00:00
42 lines
932 B
Bash
Executable File
42 lines
932 B
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Check git repo's files .gitattributes and ensure all of them are mapped.
|
|
# Ismo Vuorinen <https://github.com/ivuorinen> 2022
|
|
source "${DOTFILES}/config/shared.sh"
|
|
|
|
set -euo pipefail
|
|
|
|
# Enable verbosity with VERBOSE=1
|
|
VERBOSE="${VERBOSE:-0}"
|
|
|
|
# Function to check if git is installed
|
|
check_git_installed()
|
|
{
|
|
if ! command -v git &> /dev/null; then
|
|
msg_err "git could not be found, please install it first"
|
|
fi
|
|
}
|
|
|
|
# Function to check for missing .gitattributes
|
|
check_gitattributes()
|
|
{
|
|
local missing_attributes
|
|
missing_attributes=$(git ls-files | git check-attr -a --stdin | grep "text: auto" || true)
|
|
|
|
if [[ -n "$missing_attributes" ]]; then
|
|
echo ".gitattributes rule missing for the following files:"
|
|
echo "$missing_attributes"
|
|
else
|
|
echo "All files have a corresponding rule in .gitattributes"
|
|
fi
|
|
}
|
|
|
|
# Main function
|
|
main()
|
|
{
|
|
check_git_installed
|
|
check_gitattributes
|
|
}
|
|
|
|
main "$@"
|