Skip to content

Commit 2ab9726

Browse files
committed
build: include every workspace in main and develop branches
1 parent 7b3dc43 commit 2ab9726

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

scripts/build-monorepo.sh

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,13 @@ add_repo_to_monorepo () {
162162
git -C "$BUILD_OUT" remote add "$REMOTE_NAME" "$(realpath "${BUILD_TMP}")/${REPO_NAME}"
163163
git -C "$BUILD_OUT" fetch --no-tags "$REMOTE_NAME"
164164

165-
git -C "${BUILD_TMP}/${REPO_NAME}" branch --format="%(refname:short)" | while read BRANCH; do
165+
(
166+
# some repos use "master" and some use "main" -- 'sed' is here to make it consistent
167+
git -C "${BUILD_TMP}/${REPO_NAME}" branch --format="%(refname:short)" | sed 's/^master$/main/'
168+
# guarantee we have these branches
169+
echo develop
170+
echo main
171+
) | sort -u | while read BRANCH; do
166172
case "$BRANCH" in
167173
dependabot/*|greenkeeper/*|renovate/*)
168174
continue # ignore these branches
@@ -175,10 +181,26 @@ add_repo_to_monorepo () {
175181
else
176182
DEST_BRANCH="$BRANCH"
177183
fi
184+
# Some repos don't have a develop branch. In that case, create it from main or master.
185+
if [ -z "$(git -C "${BUILD_TMP}/${REPO_NAME}" branch --list "$BRANCH")" ]; then
186+
echo "Branch $BRANCH not found. Trying main..."
187+
BRANCH="main"
188+
if [ -z "$(git -C "${BUILD_TMP}/${REPO_NAME}" branch --list "$BRANCH")" ]; then
189+
echo "Branch $BRANCH not found. Trying master..."
190+
BRANCH="master"
191+
fi
192+
fi
178193
;;
179-
master)
180-
# some repos use "master" and some use "main" -- let's make it consistent
181-
DEST_BRANCH="main"
194+
main)
195+
# Some repos don't have a develop branch. In that case, create it from master or develop.
196+
if [ -z "$(git -C "${BUILD_TMP}/${REPO_NAME}" branch --list "$BRANCH")" ]; then
197+
echo "Branch $BRANCH not found. Trying master..."
198+
BRANCH="master"
199+
if [ -z "$(git -C "${BUILD_TMP}/${REPO_NAME}" branch --list "$BRANCH")" ]; then
200+
echo "Branch $BRANCH not found. Trying develop..."
201+
BRANCH="develop"
202+
fi
203+
fi
182204
;;
183205
native)
184206
if [ "$REPO_NAME" = "scratch-gui" ]; then

0 commit comments

Comments
 (0)