dcapwell commented on code in PR #2114:
URL: https://github.com/apache/cassandra/pull/2114#discussion_r1094900749


##########
dev-support/git-hooks/post-checkout/100-update-submodules.sh:
##########
@@ -24,35 +25,17 @@ set -o nounset
 
 bin="$(cd "$(dirname "$0")" > /dev/null; pwd)"
 
-accord_repo='https://github.com/apache/cassandra-accord.git'
-accord_branch='1230eceb077c928123e6bf848a103964fe90c9f7'
-accord_src="$bin/cassandra-accord"
-
-checkout() {
-  cd "$accord_src"
-    git checkout "$accord_branch"
-    echo "$accord_branch" > .BRANCH
-  cd -
-}
-
 _main() {
-  # have we already cloned?
-  if [[ ! -e "$accord_src" ]] || [[ $(cat "$accord_src/.REPO" || true) != 
"$accord_repo" ]]; then
-    rm -rf "$accord_src" || true
-    git clone "$accord_repo" "$accord_src"
-    echo "$accord_repo" > "$accord_src/.REPO"
-    checkout
-  fi
-  if [[ $(cat "$accord_src"/.BRANCH || true) != "$accord_branch" ]]; then
-    checkout
-  fi
-  cd "$accord_src"
-  # are there changes?
-  git pull --rebase origin "$accord_branch"
-  if [[ $(git rev-parse HEAD) != $(cat .SHA || true) ]]; then
-    ./gradlew clean install -x test
-    git rev-parse HEAD > .SHA
+  # In case the usage happens at a different layer, make sure to cd to the 
toplevel
+  local root_dir
+  root_dir="$(git rev-parse --show-toplevel)"
+  cd "$root_dir"
+
+  if [[ ! -e .gitmodules ]]; then
+    # nothing to see here, look away!
+    return 0
   fi
+  git submodule update --init --recursive

Review Comment:
   originally didn't have `--init` but this is needed if someone adds a new 
submodule... `--init` becomes a noop if the submodule is already init, so safe 
to include.
   
   We don't need `--recursive` right now, but since the hooks no-op if they 
exist figured if we ever go that route best to add now...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to