From dc5c8bda3c0e4ef108c2fe5b3a507a3e6cacb205 Mon Sep 17 00:00:00 2001 From: Breadman Da Date: Fri, 19 Aug 2022 02:35:48 -0700 Subject: [PATCH] Make CircleCI run shallow clones of the React Native repo (#34453) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/34453 # Changelog [General][Fixed] - Fix shallow cloning break on main. Introduced in [#34438](https://github.com/facebook/react-native/pull/34438) Differential Revision: D38858746 fbshipit-source-id: 7e3587ee73bd2b165485f42d0076ac6f61010171 --- .circleci/config.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 85c34eafd361c4..611c7caf118712 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -134,8 +134,15 @@ commands: name: Shallow clone repo command: | git clone --branch main --no-checkout "$CIRCLE_REPOSITORY_URL" --single-branch . - git fetch --force --depth 1 origin +refs/pull/$CIRCLE_PR_NUMBER/head:refs/remotes/origin/pull/$CIRCLE_PR_NUMBER - git checkout --force -B "$CIRCLE_BRANCH" "$CIRCLE_SHA1" + # Fetch from fork if applicable + if [ -z $CIRCLE_PR_NUMBER ] ; then + git fetch --force --depth 1 origin +refs/pull/$CIRCLE_PR_NUMBER/head:refs/remotes/origin/pull/$CIRCLE_PR_NUMBER + fi + if [ -z $CIRCLE_BRANCH ] ; then + git checkout --force -B "$CIRCLE_BRANCH" "$CIRCLE_SHA1" + else + git checkout main + fi # Checkout with cache, on machines that are using Docker the cache is ignored checkout_code_with_cache: