#! /bin/bash12# This file is part of t8code.3# t8code is a C library to manage a collection (a forest) of multiple4# connected adaptive space-trees of general element classes in parallel.5#6# Copyright (C) 2023 the developers7#8# t8code is free software; you can redistribute it and/or modify9# it under the terms of the GNU General Public License as published by10# the Free Software Foundation; either version 2 of the License, or11# (at your option) any later version.12#13# t8code is distributed in the hope that it will be useful,14# but WITHOUT ANY WARRANTY; without even the implied warranty of15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16# GNU General Public License for more details.17#18# You should have received a copy of the GNU General Public License19# along with t8code; if not, write to the Free Software Foundation, Inc.,20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.2122TYPOS=`which typos 2> /dev/null`23if [ -z "$TYPOS" ]24then25echo "ERROR: typos not found."26echo "Please install typos."27echo "See https://github.com/crate-ci/typos#install"28exit 129fi3031repo_main_dir=`git rev-parse --show-toplevel`32(cd $repo_main_dir && typos)3334echo "This script will correct all previously listed typos."35echo36read -p "Are you sure? ('Y' or 'y' to continue) " -n 1 -r37echo38if [[ $REPLY =~ ^[Yy]$ ]]39then40echo Correcting all typos...41(cd $repo_main_dir && typos -w)42echo done.4344echo45echo "Changed files according to git diff:"46changed_files=``47for file in `(cd $repo_main_dir && git diff --name-only)`48do49# only check existing files, this is necessary since if we rename or delete50# a file it is added to the committed files and we thus would try to indent a51# nonexisting file.52if [ ! -e $repo_main_dir/$file ]53then54continue55fi56# We only indent .c, .cxx, .h and .hxx files57#-a ${file: -2} != ".h" ]58FILE_ENDING="${file##*.}"59if [ $FILE_ENDING = "c" -o $FILE_ENDING = "h" -o $FILE_ENDING = "cxx" -o $FILE_ENDING = "hxx" ]60then61echo $file62changed_files="$changed_files $file"63fi64done65echo66echo "Should also all changed (according to git diff) files be indented?"67read -p "('Y' or 'y' to continue) " -n 1 -r68echo69if [[ $REPLY =~ ^[Yy]$ ]]70then71echo Indenting all files...72(cd $repo_main_dir && ./scripts/t8indent.sh $changed_files)73echo done.74else75echo Aborted.76fi77else78echo Aborted.79fi808182