rename_submodules.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) 2020 Project CHIP Authors
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. # Temporary transition script to remove submodules added with previous names
  18. # and re-add them with the new names.
  19. CHIP_ROOT="$(dirname "$0")/../.."
  20. if [[ ! -e "$CHIP_ROOT/.git" ]]; then
  21. exit 0
  22. fi
  23. # Transitional: Remove keys for submodules with mismatched names
  24. OLD_SUBMODULE_KEYS='submodule\.third_party/.*|submodule\.examples/.*'
  25. if ! git -C "$CHIP_ROOT" config --get-regexp "$OLD_SUBMODULE_KEYS" >&/dev/null; then
  26. exit 0
  27. fi
  28. # Remove renamed submodules from config
  29. git -C "$CHIP_ROOT" config --get-regexp "$OLD_SUBMODULE_KEYS" | while read key value; do
  30. git -C "$CHIP_ROOT" config --unset "$key"
  31. done
  32. # Re-init with new submodule names.
  33. git submodule update --init