From c49154cb9b0f5d60e174b4dfb98f37cb2f5f080b Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Mon, 7 Nov 2016 22:02:34 -0600 Subject: Support commit= in git URLs --- libexec/build-fetch-git | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libexec/build-fetch-git b/libexec/build-fetch-git index 92c7962..5017f98 100755 --- a/libexec/build-fetch-git +++ b/libexec/build-fetch-git @@ -6,10 +6,12 @@ build_fetch_git() build_fetch_git_uri="${build_fetch_git_uri#git://}" build_fetch_git_uri="${build_fetch_git_uri%%\?*}" build_fetch_git_tag= + build_fetch_git_commit= build_fetch_git_var= for arg in $(build-url --arg "${1}"); do case "${arg}" in (archive=*) build_fetch_git_var="${arg##*=}";; + (commit=*) build_fetch_git_commit="${arg##*=}";; (*) build_fetch_git_tag="${arg}";; esac done @@ -60,6 +62,18 @@ build_fetch_git() fi ;; esac + elif [ ! -z "${build_fetch_git_commit}" ]; then + if ! git clone "${build_fetch_git_uri}" "${build_fetch_git_dir}"; then + die "failed to clone git source at '${build_fetch_git_uri}'" + fi + + if ! cd "${build_fetch_git_dir}"; then + die "failed to change working directory to '${build_fetch_git_dir}'" + fi + + if ! git checkout "${build_fetch_git_commit}"; then + die "failed to checkout git commit '${build_fetch_git_commit}'" + fi else if ! git clone --depth 1 "${build_fetch_git_uri}" "${build_fetch_git_dir}"; then die "failed to clone git source at '${build_fetch_git_uri}'" -- cgit v1.2.3-18-g5258