@@ -162,7 +162,13 @@ add_repo_to_monorepo () {
162
162
git -C " $BUILD_OUT " remote add " $REMOTE_NAME " " $( realpath " ${BUILD_TMP} " ) /${REPO_NAME} "
163
163
git -C " $BUILD_OUT " fetch --no-tags " $REMOTE_NAME "
164
164
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
166
172
case " $BRANCH " in
167
173
dependabot/* |greenkeeper/* |renovate/* )
168
174
continue # ignore these branches
@@ -175,10 +181,26 @@ add_repo_to_monorepo () {
175
181
else
176
182
DEST_BRANCH=" $BRANCH "
177
183
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
178
193
;;
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
182
204
;;
183
205
native)
184
206
if [ " $REPO_NAME " = " scratch-gui" ]; then
0 commit comments