Created
December 29, 2020 13:43
-
-
Save baerla/e3bdc6c06c8e29f0ad215816a006c6f9 to your computer and use it in GitHub Desktop.
Returns all remote urls from all git repositories on beneath <dir> saved at <file>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ -z $1 ]]; then | |
echo "no search place given!" | |
exit 1 | |
fi | |
if [[ -z $2 ]]; then | |
echo "no file for saving given!" | |
exit 1 | |
fi | |
#echo $3 | |
i=$(($3+1)) | |
while read dir; do | |
if [[ $? -ne 0 ]]; then | |
#echo "$(pwd) $dir" | |
exit 0 | |
fi | |
if [[ $3 > 4 ]]; then | |
exit 0 | |
fi | |
if [[ $dir != $(pwd) && $dir != "gitRepos/" ]]; then | |
#echo "${dir#./} $1" | |
cd $dir | |
gitUrl=$(git remote get-url origin 2> /dev/null) | |
if [[ ${gitUrl} != "" && $gitUrl != $4 ]]; then | |
echo $gitUrl | |
#echo "found git repo" | |
fi | |
~/installedGit.sh $(pwd) $2 $i $gitUrl | |
if [[ $? -ne 0 ]]; then | |
#echo "$(pwd) $dir" | |
exit 0 | |
fi | |
fi | |
done <<< $(find $1 -maxdepth 1 -type d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment