Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- # Script used to checkout a repository,
- # and push all branches and tags to a new remote
- # This doesn't change the origin, simply pushes to a remote as script is designed
- # to just delete and recheckout so can be run multiple times over and over durring
- # migration process.
- checkout_update_original() {
- echo "Checkout/Update repository: ${1}/${2}"
- if [ -d "${2}" ]; then
- echo "- Repo exists, removing"
- rm -rf ${2}
- fi
- echo "- Checking out ${2}"
- git clone gerrit:${1}/${2}
- pushd ${2}
- echo "- Fetch all branches and update"
- echo ""
- # Need to dettach for fetch origin command to work
- git checkout --detach
- git fetch origin '+refs/heads/*:refs/heads/*'
- echo ""
- popd
- echo ""
- }
- push_to_review() {
- echo "Pushing gerrit:${1}/${2} to review:${3}/${4}"
- pushd ${2}
- echo ""
- git push --all review:${3}/${4}
- git push --tags review:${3}/${4}
- echo ""
- popd
- echo ""
- }
- sync_repository() {
- checkout_update_original ${1} ${2}
- push_to_review ${1} ${2} ${3} ${4}
- }
- gerrit_master="gerrit-server-01"
- review_master="gerrit-server-02"
- sync_repository ${gerrit_master} "AppRepository" ${review_master} "app-repository"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement