update_chibios_mirror.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. ################################
  3. # Configuration
  4. # The branches to mirror
  5. branches="trunk stable_20.3.x stable_21.6.x"
  6. # The tags to mirror
  7. tags="ver19.1.3 ver20.3.1 ver20.3.2 ver20.3.3 ver21.6.0"
  8. ################################
  9. # Actions
  10. set -eEuo pipefail
  11. umask 022
  12. this_script="$(realpath "${BASH_SOURCE[0]}")"
  13. script_dir="$(realpath "$(dirname "$this_script")")"
  14. qmk_firmware_dir="$(realpath "$script_dir/../")"
  15. chibios_dir="$qmk_firmware_dir/lib/chibios"
  16. chibios_git_location=$(realpath "$chibios_dir/$(cat "$chibios_dir/.git" | awk '/gitdir:/ {print $2}')")
  17. chibios_git_config=$(realpath "$chibios_git_location/config")
  18. cd "$chibios_dir"
  19. if [[ -z "$(cat "$chibios_git_config" | grep '\[svn-remote "svn"\]')" ]] ; then
  20. git svn init --stdlayout --prefix='svn/' http://svn.osdn.net/svnroot/chibios/
  21. fi
  22. if [[ -z "$(cat "$chibios_git_config" | grep '\[remote "qmk"\]')" ]] ; then
  23. git remote add qmk git@github.com:qmk/ChibiOS.git
  24. git remote set-url qmk git@github.com:qmk/ChibiOS.git --push
  25. fi
  26. echo "Updating remotes..."
  27. git fetch --all --tags --prune
  28. echo "Fetching latest from subversion..."
  29. git svn fetch
  30. echo "Updating branches..."
  31. for branch in $branches ; do
  32. echo "Creating branch 'svn-mirror/$branch' from 'svn/$branch'..."
  33. git branch -f svn-mirror/$branch svn/$branch \
  34. && git push qmk svn-mirror/$branch
  35. done
  36. echo "Updating tags..."
  37. for tagname in $tags ; do
  38. echo "Creating tag 'svn-mirror/$tagname' from 'svn/tags/$tagname'..."
  39. GIT_COMMITTER_DATE="$(git log -n1 --pretty=format:'%ad' svn/tags/$tagname)" git tag -f -a -m "Tagging $tagname" svn-mirror/$tagname svn/tags/$tagname
  40. git push qmk svn-mirror/$tagname
  41. done