osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43168?usp=email )
Change subject: deps: move "update url" logic into update.sh ......................................................................
deps: move "update url" logic into update.sh
Prepare to add a function that gets the proper git clone URL for gitlab repos in the next patch. In order to do this, we need to have the update url logic in update.sh first.
Change-Id: I18a56cae6b0c35b205f15ef117d9d4354aef6c79 --- M deps/Makefile M deps/update.sh 2 files changed, 14 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/68/43168/1
diff --git a/deps/Makefile b/deps/Makefile index 4a6bd90..7df5746 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -140,10 +140,6 @@ ifeq ($$($(1)_MODIFIED),1) @echo "WARNING: $(1) skipped because it contains uncommitted modifications!" else -ifneq ($$($(1)_ORIGIN),$(2)/$(1)) - @echo "[$(1)] Updating URL to $(2)/$(1)" - @cd $(1) && git remote set-url origin $(2)/$(1) && git fetch -endif ifneq ($$($(1)_HEAD),$($(1)_commit)) @./update.sh "$(1)" "$($(1)_commit)" "$(2)" endif diff --git a/deps/update.sh b/deps/update.sh index 4a52279..332ce23 100755 --- a/deps/update.sh +++ b/deps/update.sh @@ -3,7 +3,20 @@ COMMIT="$2" URL_PREFIX="$3"
-if ! [ -d "$DIR" ]; then +update_url() { + local current="$(git -C "$DIR" remote get-url origin)" + local full_url="$URL_PREFIX"/"$DIR" + + if [ "$current" != "$full_url" ]; then + echo "[$DIR] Updating URL to $full_url" + git -C "$DIR" remote set-url origin "$full_url" + git -C "$DIR" fetch + fi +} + +if [ -d "$DIR" ]; then + update_url +else echo "[$DIR] Initial git clone" git clone -q "$URL_PREFIX"/"$DIR" fi