diff --git a/devops/find-file.sh b/devops/find-file.sh new file mode 100755 index 0000000000000000000000000000000000000000..4d2634ae88c84d4c0caf8fd9fb85b85ef4f94601 --- /dev/null +++ b/devops/find-file.sh @@ -0,0 +1,57 @@ +#!/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