If a user launches a CircleCI pipeline using the API, the $CIRCLE_BRANCH variable is already populated with a /head or /merge suffix (e.g. pull/895/head) - this will cause the shallow checkout to fail.
Use a modified regex such that, if the suffix is already present, we fall through to the third case, where the suffix /head is not added.
If a user launches a CircleCI pipeline using the API, the
$CIRCLE_BRANCH
variable is already populated with a/head
or/merge
suffix (e.g.pull/895/head
) - this will cause the shallow checkout to fail.Use a modified regex such that, if the suffix is already present, we fall through to the third case, where the suffix
/head
is not added.