Skip to content

Instantly share code, notes, and snippets.

@gorshunovr
Last active September 7, 2020 14:14
Show Gist options
  • Save gorshunovr/1a919a2dc0f16838ecc8233bd7db43d6 to your computer and use it in GitHub Desktop.
Save gorshunovr/1a919a2dc0f16838ecc8233bd7db43d6 to your computer and use it in GitHub Desktop.
Airship repositories updater
#!/usr/bin/env bash
# Pulls/updates local Airship repositories
airship_git_repo_root="https://opendev.org/airship"
airship_projects=(
'airshipctl'
'armada'
'berth'
'deckhand'
'divingbell'
'docs'
'drydock'
'election'
'governance'
'maas'
'pegleg'
'promenade'
'shipyard'
'specs'
'spyglass'
'spyglass-plugin-xls'
'tempest-plugin'
'treasuremap'
'utils'
)
function clone () {
for p in "${airship_projects[@]}"; do
if [[ "${1}" == "-f" ]]; then
echo "Removing "airship-${p}" directory"
rm -rf ./"airship-${p}"
fi
echo "Cloning project: "${p}""
git clone "${airship_git_repo_root}"/"${p}".git "${p}" &
done
}
function update ()
{
for p in "${airship_projects[@]}"; do
echo "Updating project: "airship-${p}""
pushd "airship-${p}"
git remote update
git checkout master
git pull --ff-only origin master
popd
done
}
function usage ()
{
echo "Usage: $(basename "$0") [-h] {clone [-f]|update}" 1>&2
echo " -h this help" 1>&2
echo " clone [-f] clone all Airship projects; -f removes project directories before cloning" 1>&2
echo " update update all Airship projects" 1>&2
}
# See how we were called.
case "${1}" in
"clone" ) clone "${2}";;
"update" ) update;;
"-h"|* ) usage; exit 1;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment