#!/bin/bash

if [ $# -eq 0 ];
then
	echo "no command provided"
	exit 0
fi

if [ -d .git ];
then
	echo "dont run this in a git directory"
	exit 1
fi

# https://serverfault.com/questions/72744/command-to-prepend-string-to-each-line
function prepend() { while read line; do echo "${1} ${line}"; done; }

for dirr in */ ;
do
	
	if [ -d "$dirr" ];
	then
		pushd "$dirr" > /dev/null

        #echo "$dirr"
        #git remote -v
        #basename -s .git `git config --get remote.origin.url`


		if [ -d .git ];
		then

			git $@ | prepend "$dirr" &


		fi

		popd > /dev/null
	fi

done

wait

echo "the end"


