diff --git a/repo.sh b/repo.sh index cc4d22ad7b..5739316df5 100755 --- a/repo.sh +++ b/repo.sh @@ -75,6 +75,15 @@ non_release_ssh_repos=( "git@github.com:openedx/frontend-app-profile.git" "git@github.com:openedx/frontend-app-ora-grading.git" ) +# Space separated list of repos that use 2u specific branch should be +# set in your environment. example: +# export TWOU_MAIN_REPOS="ecommerce yourownrepo" +# +# If TWOU_MAIN_REPOS is set in the env, then TWOU_CHECKOUT_BRANCH must +# also be set. Here is an example of how to update your bashrc +# file, so that you can get these variables created (note, TWOU_MAIN_REPOS +# likely will grow over time, and not just use ecommerce'): +# $ echo -e "\nexport TWOU_CHECKOUT_BRANCH=\"2u/main\"\nexport TWOU_MAIN_REPOS=\"ecommerce yourownrepo\"" >> ~/.bash_profile if [ -n "${OPENEDX_RELEASE}" ]; then OPENEDX_GIT_BRANCH=open-release/${OPENEDX_RELEASE} @@ -133,11 +142,14 @@ _clone () _checkout_and_update_branch cd .. else - if [ -n "${OPENEDX_GIT_BRANCH:-}" ]; then + if [ -n "${TWOU_CHECKOUT_BRANCH}" ] && echo "${TWOU_MAIN_REPOS}" | grep -o "${name}"; then + CLONE_BRANCH="-b ${TWOU_CHECKOUT_BRANCH}" + elif [ -n "${OPENEDX_GIT_BRANCH:-}" ]; then CLONE_BRANCH="-b ${OPENEDX_GIT_BRANCH}" else CLONE_BRANCH="" fi + if [ "${SHALLOW_CLONE}" == "1" ]; then git clone ${CLONE_BRANCH} -c core.symlinks=true --depth=1 "${repo}" else @@ -152,11 +164,15 @@ _checkout_and_update_branch () { GIT_SYMBOLIC_REF="$(git symbolic-ref HEAD 2>/dev/null)" BRANCH_NAME=${GIT_SYMBOLIC_REF##refs/heads/} - if [ -n "${OPENEDX_GIT_BRANCH}" ]; then + + if [ -n "${TWOU_CHECKOUT_BRANCH}" ] && echo "${TWOU_MAIN_REPOS}" | grep -o "${name}"; then + CHECKOUT_BRANCH="${TWOU_CHECKOUT_BRANCH}" + elif [ -n "${OPENEDX_GIT_BRANCH}" ]; then CHECKOUT_BRANCH=${OPENEDX_GIT_BRANCH} else CHECKOUT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@') fi + echo "Checking out branch ${CHECKOUT_BRANCH}" if [ "${BRANCH_NAME}" == "${CHECKOUT_BRANCH}" ]; then git pull origin ${CHECKOUT_BRANCH}