Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

feat: checkout 2u/main branch if envvar is set #1268

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ non_release_ssh_repos=(
"[email protected]:openedx/frontend-app-profile.git"
"[email protected]: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}
Expand Down Expand Up @@ -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
Expand All @@ -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}
Expand Down