Last active
December 26, 2015 15:38
-
-
Save Daij-Djan/7173749 to your computer and use it in GitHub Desktop.
Checks a folder full of subfolders if each subfolder is linked to a git repo and (in this case) if the repo is on github :)
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 | |
#config | |
validGitPattern1="@github.com" | |
echoValidRepos=0 | |
#check git paths | |
for path in `ls` | |
do | |
gistfile="" | |
giturl="" | |
if [ -d "${path}" ] ; then | |
#check gist override | |
if [ -f "${path}/GIST" ] ; then | |
gistfile="GIST" | |
fi | |
#get git url | |
if [ -d "${path}/.git" ] ; then | |
cd "$path" | |
giturl=`git config --get remote.origin.url` | |
cd .. | |
fi | |
#check giturl | |
if [ -n "$giturl" ] ; then | |
if [[ "$giturl" == *"$validGitPattern"* ]] ; then | |
if [[ $echoValidRepos>0 ]] ; then | |
echo "ok | $path on valid git @ $giturl" | |
fi | |
else | |
echo "fail | $path on invalid git @ $giturl" | |
failedReposCounter=$[failedReposCounter+1] | |
fi | |
else | |
if [ -n "$gistfile" ] ; then | |
if [[ $echoValidRepos>0 ]] ; then | |
echo "ok | $path is marked as a gist" | |
fi | |
else | |
echo "fail | $path not even a git repo or gist" | |
notEvenReposCounter=$[notEvenReposCounter+1] | |
fi | |
fi | |
fi | |
done | |
#print counters | |
if [[ $failedReposCounter > 0 ]] ; then | |
echo "$failedReposCounter invalid git repos" | |
fi | |
if [[ $notEvenReposCounter > 0 ]] ; then | |
echo "$notEvenReposCounter non git repos or gists (mark using GIST file if appropriate)" | |
fi |
I changed the pattern to not only accept git@github but github.com
therefore now accepts https remotes as valid
updated the gist to check git remotes @github but also allow marking folders with GIST files
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rev1 had a last minute bug that resulted from me trying to blindly optimize a thingy. I now shell scripting way too little. shouldn't have done that :D