From e72a09ee274e0d50edcdcb3eacdd3aa4471a1350 Mon Sep 17 00:00:00 2001 From: nif Date: Mon, 1 Jul 2019 17:52:43 +0200 Subject: [PATCH 1/3] Make submodules work in forks Merges https://github.com/espressif/esp-idf/pull/3721 --- .gitmodules | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitmodules b/.gitmodules index 21a8c1df34..e32b97a7ab 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,11 +4,11 @@ [submodule "components/esptool_py/esptool"] path = components/esptool_py/esptool - url = ../esptool.git + url = ../../espressif/esptool.git [submodule "components/bt/controller/lib"] path = components/bt/controller/lib - url = ../esp32-bt-lib.git + url = ../../espressif/esp32-bt-lib.git [submodule "components/bootloader/subproject/components/micro-ecc/micro-ecc"] path = components/bootloader/subproject/components/micro-ecc/micro-ecc @@ -36,11 +36,11 @@ [submodule "components/mbedtls/mbedtls"] path = components/mbedtls/mbedtls - url = ../mbedtls.git + url = ../../espressif/mbedtls.git [submodule "components/asio/asio"] path = components/asio/asio - url = ../asio.git + url = ../../espressif/asio.git [submodule "components/expat/expat"] path = components/expat/expat @@ -48,11 +48,11 @@ [submodule "components/lwip/lwip"] path = components/lwip/lwip - url = ../esp-lwip.git + url = ../../espressif/esp-lwip.git [submodule "components/mqtt/esp-mqtt"] path = components/mqtt/esp-mqtt - url = ../esp-mqtt.git + url = ../../espressif/esp-mqtt.git [submodule "components/protobuf-c/protobuf-c"] path = components/protobuf-c/protobuf-c @@ -68,8 +68,8 @@ [submodule "components/esp_wifi/lib_esp32"] path = components/esp_wifi/lib_esp32 - url = ../esp32-wifi-lib.git + url = ../../espressif/esp32-wifi-lib.git [submodule "components/bt/host/nimble/nimble"] path = components/bt/host/nimble/nimble - url = ../esp-nimble.git + url = ../../espressif/esp-nimble.git From b54762597aa3e450ae212ca67c63e02da87d5b40 Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Tue, 2 Jul 2019 13:40:04 +0700 Subject: [PATCH 2/3] Avoid 'redirecting to' warnings when cloning --- .gitmodules | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index e32b97a7ab..150118b11e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -56,15 +56,15 @@ [submodule "components/protobuf-c/protobuf-c"] path = components/protobuf-c/protobuf-c - url = ../../protobuf-c/protobuf-c + url = ../../protobuf-c/protobuf-c.git [submodule "components/unity/unity"] path = components/unity/unity - url = ../../ThrowTheSwitch/Unity + url = ../../ThrowTheSwitch/Unity.git [submodule "examples/build_system/cmake/import_lib/main/lib/tinyxml2"] path = examples/build_system/cmake/import_lib/main/lib/tinyxml2 - url = ../../leethomason/tinyxml2 + url = ../../leethomason/tinyxml2.git [submodule "components/esp_wifi/lib_esp32"] path = components/esp_wifi/lib_esp32 From c9cf0afb6ef207af2cbc094f0028f2ce82b39619 Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Mon, 1 Jul 2019 15:19:10 +0700 Subject: [PATCH 3/3] tools: Add a script for switching to real submodules in forks --- .gitmodules | 1 + README.md | 8 ++++++ tools/ci/executable-list.txt | 1 + tools/set-submodules-to-github.sh | 41 +++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100755 tools/set-submodules-to-github.sh diff --git a/.gitmodules b/.gitmodules index 150118b11e..70bd0c478e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,5 +1,6 @@ # # All the relative URL paths are intended to be GitHub ones +# For Espressif's public projects please use '../../espressif/proj', not a '../proj' # [submodule "components/esptool_py/esptool"] diff --git a/README.md b/README.md index 55487c9b2c..bbb8d3a54b 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,14 @@ See setup guides for detailed instructions to set up the ESP-IDF: * [Getting Started Guide for the stable ESP-IDF version](https://docs.espressif.com/projects/esp-idf/en/stable/get-started/) * [Getting Started Guide for the latest (master branch) ESP-IDF version](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/) +### Non-GitHub forks + +ESP-IDF uses relative locations as its submodules URLs ([.gitmodules](.gitmodules)). So they link to GitHub. +If ESP-IDF is forked to a Git repository which is not on GitHub, you will need to run the script +[tools/set-submodules-to-github.sh](tools/set-submodules-to-github.sh) after git clone. +The script sets absolute URLs for all submodules, allowing `git submodule update --init --recursive` to complete. +If cloning ESP-IDF from GitHub, this step is not needed. + ## Finding a Project As well as the [esp-idf-template](https://github.com/espressif/esp-idf-template) project mentioned in Getting Started, ESP-IDF comes with some example projects in the [examples](examples) directory. diff --git a/tools/ci/executable-list.txt b/tools/ci/executable-list.txt index a3b2845577..e7b9715194 100644 --- a/tools/ci/executable-list.txt +++ b/tools/ci/executable-list.txt @@ -70,6 +70,7 @@ tools/ldgen/ldgen.py tools/ldgen/test/test_fragments.py tools/ldgen/test/test_generation.py tools/mass_mfg/mfg_gen.py +tools/set-submodules-to-github.sh tools/test_check_kconfigs.py tools/test_idf_monitor/run_test_idf_monitor.py tools/test_idf_size/test.sh diff --git a/tools/set-submodules-to-github.sh b/tools/set-submodules-to-github.sh new file mode 100755 index 0000000000..5495fb4a29 --- /dev/null +++ b/tools/set-submodules-to-github.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# +# Explicitly switches the relative submodules locations on GitHub to the original public URLs +# +# '../../group/repo.git' to 'https://github.com/group/repo.git' +# +# This can be useful for non-GitHub forks to automate getting of right submodules sources. +# + +# +# It makes sense to do +# +# git submodule deinit --force . +# git submodule init +# +# before running this, and +# +# git submodule update --recursive +# +# after that. These were not included over this script deliberately, to use the script flexibly +# + +set -o errexit +set -o pipefail +set -o nounset + +DEBUG_SHELL=${DEBUG_SHELL:-"0"} +[ "${DEBUG_SHELL}" = "1" ] && set -x + +### '../../' relative locations + +for LINE in $(git config -f .gitmodules --list | grep "\.url=../../[^.]") +do + SUBPATH=$(echo "${LINE}" | sed "s|^submodule\.\([^.]*\)\.url.*$|\1|") + LOCATION=$(echo "${LINE}" | sed 's|.*\.url=\.\./\.\./\(.*\)$|\1|') + SUBURL="https://github.com/$LOCATION" + + git config submodule."${SUBPATH}".url "${SUBURL}" +done + +git config --get-regexp '^submodule\..*\.url$'