Skip to content
Snippets Groups Projects
Commit d36848ab authored by Robert Lange's avatar Robert Lange
Browse files

[finc] find file on finc instances

* show unique occurences in all themes except foundation
* sort results
parent de4d0a3f
No related merge requests found
#!/bin/bash
# Copyright (C) 2022 Leipzig University Library
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# @author Robert Lange <lange@ub.uni-leipzig.de>
# @license https://opensource.org/licenses/GPL-3.0 GNU GPLv3
Help()
{
# Display Help
echo "This script looks for occurences of files on finc instance branches. Usage: find-file.sh [file name]"
echo "Example: \"./devops/find-file.sh myresearch/edit.phtml\""
}
while getopts ":h" option; do
case $option in
h) # display Help
Help
exit;;
\?) # incorrect option
echo "Error: Invalid option"
exit 1;
esac
done
declare -A stringFindings=()
declare -A arrFindings=()
for branch in $(git branch --list *instance*|cut -c 3-)
do
stringFindings+=" "
stringFindings+=$(git ls-tree -r --name-only $branch | grep "$1" | grep -v foundation5)
done
# use asscociative array to get unique values
for element in $(echo $stringFindings | tr ";" "\n")
do
if ! [[ -z "$element" ]]; then
arrFindings["${element}"]=${element}
fi
done
for elem in "${!arrFindings[@]}"
do
echo "${arrFindings[${elem}]}"
done | sort
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment