Skip to content

git/clone: if ref is a name that returns multiple branches, the clone fails #306

@chris-lower

Description

@chris-lower

The get-latest-sha-for-ref isn't correctly detecting when two branches are returned for a ref. It's not a big deal because the clone still fails, but it doesn't give the nice error message that the script is designed to display.

if the ref passed in matches more than qa branch,

git ls-remote origin "qa"
7432eea9e31c99ad10e7d3382da1a8133b3a2511	refs/heads/chore/qa
8d2a8442997c89426d62100df723ea28ac03dff3	refs/heads/qa

the script will run

COMMAND="git $CREDENTIAL_ARG ls-remote \"${CHECKOUT_REPOSITORY}\" \"${CHECKOUT_REF}\""
LS_REMOTE_OUTPUT=$(eval "$COMMAND")
LS_REMOTE_LINE_COUNT=$(echo "$LS_REMOTE_OUTPUT" | wc -l)
if [ "$LS_REMOTE_LINE_COUNT" -gt 1 ]; then
...

For some reason, this check fails and the result of the script is

    $RWX_PACKAGE_PATH/bin/get-latest-sha-for-ref
Latest SHA for qa: 7432eea9e31c99ad10e7d3382da1a8133b3a2511
6a4d866279633c351b0241b56f3c66fc58efe78a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions