Skip to content

Instantly share code, notes, and snippets.

@bernbecht
Created April 5, 2016 12:09
Show Gist options
  • Save bernbecht/3c0a4aafbab2347b0b981a165a32e115 to your computer and use it in GitHub Desktop.
Save bernbecht/3c0a4aafbab2347b0b981a165a32e115 to your computer and use it in GitHub Desktop.
Find a branch in certain repos
#!/bin/bash
REPO_NAMES=(
hiroto
izumi
kato
kaze
kishimoto
kojima
kuwabara
kurono
reika
suzumura
app_seller
tokyo
yazawa
)
NUMBER_OF_REPOS=${#REPO_NAMES[@]}
reposWithBranch=()
function lookForRepos() {
i="0"
echo "Looking with care for repos... s2"
while [ $i -lt $NUMBER_OF_REPOS ]
do
cmd_output=$(git ls-remote --heads git@bitbucket.org:tenzen/${REPO_NAMES[$i]}.git $branch)
if [[ "$cmd_output" != '' ]]
then reposWithBranch[$i]=${REPO_NAMES[$i]}; fi
i=$[$i+1]
done
echo "Repos with this branch: "
echo ${reposWithBranch[*]}
}
while true; do
read -p "Which branch you want to look for? (n/N for exit)" branch
case $branch in
[Nn]* ) echo "Bye, pretty ;)"; exit;;
* ) lookForRepos $branch;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment