| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# |
| 4 |
# KIM-API: An API for interatomic models |
| 5 |
# Copyright (c) 2013--2022, Regents of the University of Minnesota. |
| 6 |
# All rights reserved. |
| 7 |
# |
| 8 |
# Contributors: |
| 9 |
# Ryan S. Elliott |
| 10 |
# |
| 11 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 12 |
# |
| 13 |
# This library is free software; you can redistribute it and/or |
| 14 |
# modify it under the terms of the GNU Lesser General Public |
| 15 |
# License as published by the Free Software Foundation; either |
| 16 |
# version 2.1 of the License, or (at your option) any later version. |
| 17 |
# |
| 18 |
# This library is distributed in the hope that it will be useful, |
| 19 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 |
# Lesser General Public License for more details. |
| 22 |
# |
| 23 |
# You should have received a copy of the GNU Lesser General Public License |
| 24 |
# along with this library; if not, write to the Free Software Foundation, |
| 25 |
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 26 |
# |
| 27 |
|
| 28 |
# |
| 29 |
# Release: This file is part of the kim-api.git repository. |
| 30 |
# |
| 31 |
|
| 32 |
|
| 33 |
# filter file list # NOTE: keep in sync with verion in git-hooks/pre-commit |
| 34 |
filter_file_list () { |
| 35 |
local file_list="$1" |
| 36 |
local ignore_file="`git rev-parse --show-toplevel`/.format-ignore" |
| 37 |
files_to_check_format="" |
| 38 |
|
| 39 |
for file in ${file_list}; do |
| 40 |
local keep=`printf ${file} | sed -e 's/^.*\.f90$//'` |
| 41 |
if test -f "${ignore_file}"; then |
| 42 |
if test `grep -c "^${file}$" "${ignore_file}"` -gt 0; then |
| 43 |
# ignore |
| 44 |
printf "File '${file}' is in format-ignore file: ignoring.\n" |
| 45 |
keep=no |
| 46 |
fi |
| 47 |
fi |
| 48 |
|
| 49 |
if test x"${keep}" = x""; then |
| 50 |
files_to_check_format="${files_to_check_format} ${file}" |
| 51 |
fi |
| 52 |
done |
| 53 |
} |
| 54 |
|
| 55 |
# goto the top level repo directory |
| 56 |
if THE_GIT_DIR="`git rev-parse --show-toplevel 2> /dev/null`"; then |
| 57 |
cd "${THE_GIT_DIR}" |
| 58 |
else |
| 59 |
printf "Not in the git repo. Exiting...\n" |
| 60 |
exit 1 |
| 61 |
fi |
| 62 |
|
| 63 |
files=`find . -name "*.f90" | \ |
| 64 |
sed -e 's|^\./||'` |
| 65 |
|
| 66 |
printf "Executing fprettify on all f90 files in directory ${PWD}.\n" |
| 67 |
|
| 68 |
files_to_check_format="" |
| 69 |
filter_file_list "${files}" |
| 70 |
|
| 71 |
fprettify ${files_to_check_format} |