Advertisement
Guest User

Untitled

a guest
May 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #! /bin/bash
  2. # Script used to checkout a repository,
  3. # and push all branches and tags to a new remote
  4. # This doesn't change the origin, simply pushes to a remote as script is designed
  5. # to just delete and recheckout so can be run multiple times over and over durring
  6. # migration process.
  7.  
  8.  
  9. checkout_update_original() {
  10. echo "Checkout/Update repository: ${1}/${2}"
  11. if [ -d "${2}" ]; then
  12. echo "- Repo exists, removing"
  13. rm -rf ${2}
  14. fi
  15. echo "- Checking out ${2}"
  16. git clone gerrit:${1}/${2}
  17. pushd ${2}
  18. echo "- Fetch all branches and update"
  19. echo ""
  20.  
  21. # Need to dettach for fetch origin command to work
  22. git checkout --detach
  23. git fetch origin '+refs/heads/*:refs/heads/*'
  24.  
  25. echo ""
  26. popd
  27. echo ""
  28. }
  29.  
  30. push_to_review() {
  31. echo "Pushing gerrit:${1}/${2} to review:${3}/${4}"
  32. pushd ${2}
  33. echo ""
  34. git push --all review:${3}/${4}
  35. git push --tags review:${3}/${4}
  36. echo ""
  37. popd
  38. echo ""
  39. }
  40.  
  41. sync_repository() {
  42. checkout_update_original ${1} ${2}
  43. push_to_review ${1} ${2} ${3} ${4}
  44. }
  45.  
  46. gerrit_master="gerrit-server-01"
  47. review_master="gerrit-server-02"
  48. sync_repository ${gerrit_master} "AppRepository" ${review_master} "app-repository"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement