#!/usr/bin/env bash # # Check git repo's files .gitattributes and ensure all of them are mapped. # Ismo Vuorinen 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 "$@"