Skip to content

Instantly share code, notes, and snippets.

@groovehunter
Created February 20, 2012 23:47
Show Gist options
  • Save groovehunter/1872361 to your computer and use it in GitHub Desktop.
Save groovehunter/1872361 to your computer and use it in GitHub Desktop.
discover git details from commit id for diaspora pods
#!/bin/bash
declare -a podlist=( `cat "pods.csv" `)
cd /srv/projektstuff/data/dev/diaspora/diaspora
declare -a remotes=( `git remote` )
rm result.csv
touch result.csv
echo "pod, fork, branch, commit id" >> result.csv
for pod in "${podlist[@]}"
do
branch=n/a
res=n/a
fork=n/a
commitid=n/a
echo "DISCOVERING $pod"
cid=`curl -v https://$pod 2>&1 | grep X-Git-Revision | cut -d" " -f3`
if [ $cid ]
then
commitid=$cid
echo "commit id: $cid"
for remote in "${remotes[@]}"
do
echo "testing for $remote"
res=`git ls-remote $remote | grep ${cid//[[:space:]]}`
if [ -n "$res" ]
then
branch=`echo $res|cut -d" " -f2 | cut -d"/" -f3`
fork=$remote
fi
echo $res
done
fi
echo $pod, $fork, $branch, $commitid >> result.csv
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment