ubuntuでシェルスクリプトを使って.gitが存在するディレクトリのリポジトリURLを取得する
以下でOKのはず
test.sh
#!/bin/bash
GIT_DIRECTORY=`find . -name .git`
RESULT_ARR=()
for dir in ${GIT_DIRECTORY}
do
echo "--- directory"
echo ${dir}
echo "--- "
pushd ${dir}
REPOSITORY_URL=`git remote -v | grep fetch | cut -f2 | cut -d' ' -f1`
popd
STR="${dir}@${REPOSITORY_URL}" # 区切り文字を仮で@にしている事に注意
RESULT_ARR+=("${STR}")
done
echo "--- result"
for i in ${RESULT_ARR[@]}
do
echo ${i}
done
テスト
$ bash test.sh
./http/icecream/.git@https://github.com/seigot/icecream
# 区切り文字を仮で@にしている事に注意