-git checkout -b "${BRANCH,,}" "origin/${BRANCH,,}"
+# Fail if branch cutting is not on master
+if [ "$BRANCH_CUT" = "true" ] && [ "$BRANCH" != "master" ]; then
+ echo "ERROR: Cannot branch cut on $BRANCH, its required to be on the master branch."
+ exit 1
+fi
+
+if [ "$BRANCH_CUT" = "false" ]; then
+ git checkout -b "${BRANCH,,}" "origin/${BRANCH,,}"
+
+ # TODO: Simplify once stable/nitrogen is no longer supported.
+ for module in $(git submodule | awk '{ print $2 }')
+ do
+ pushd "$module"
+ if [ "$GERRIT_BRANCH" == "stable/nitrogen" ] && [ "$module" == "yangtools" ]; then
+ git checkout -b "v1.2.x" "origin/v1.2.x"
+ else
+ git checkout -b "${BRANCH,,}" "origin/${BRANCH,,}"
+ fi
+ popd
+ done
+fi