Skip to content

Commit

Permalink
Support branch definition in URL for git clone command
Browse files Browse the repository at this point in the history
Required-by: s2i-python-container#423
  • Loading branch information
frenzymadness committed Feb 8, 2021
1 parent 509c137 commit b3d5a0a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ ct_show_resources()
# -----------------------------
# Argument: dockerfile - path to a Dockerfile that will be used for building an image
# (must work with an application directory called 'app-src')
# Argument: app_url - git URI with a testing application
# Argument: app_url - git URI with a testing application, supports "@" to indicate a different branch
# Argument: body_regexp - PCRE regular expression that must match the response body
# Argument: app_dir - name of the application directory that is used in the Dockerfile
# Argument: port - Optional port number (default: 8080)
Expand Down Expand Up @@ -865,7 +865,17 @@ ct_test_app_dockerfile() {
echo "Using this Dockerfile:"
cat Dockerfile

if ! git clone "${app_url}" "${app_dir}" ; then
# If app_url contains @, the string after @ is considered
# as a name of a branch to clone instead of the main/master branch
readarray -d "@" -t git_url_parts<<<"${app_url}"

if [ -n "${git_url_parts[1]}" ]; then
git_clone_cmd="git clone --branch ${git_url_parts[1]} ${git_url_parts[0]} ${app_dir}"
else
git_clone_cmd="git clone ${app_url} ${app_dir}"
fi

if ! $git_clone_cmd ; then
echo "ERROR: Git repository ${app_url} cannot be cloned into ${app_dir}."
echo "Terminating the Dockerfile build."
return 1
Expand Down

0 comments on commit b3d5a0a

Please sign in to comment.