From 2ec8f0f0a487b5aee65aab426c7eb3af6803db34 Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Mon, 9 Jun 2014 22:41:43 +0900 Subject: [PATCH] Fix `fetch_git` with `--keep` (sstephenson/ruby-build#549) --- plugins/python-build/bin/python-build | 9 ++++++- plugins/python-build/test/fetch.bats | 38 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 53ce4a27..97c9a3d1 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -394,7 +394,14 @@ fetch_git() { popd >&4 fi - git clone --depth 1 --branch "$git_ref" "$git_url" "${package_name}" >&4 2>&1 + if [ -e "${package_name}" ]; then + ( cd "${package_name}" + git fetch --depth 1 origin "+${git_ref}" + git checkout -q -B "$git_ref" "origin/${git_ref}" + ) >&4 2>&1 + else + git clone --depth 1 --branch "$git_ref" "$git_url" "${package_name}" >&4 2>&1 + fi else echo "error: please install \`git\` and try again" >&2 exit 1 diff --git a/plugins/python-build/test/fetch.bats b/plugins/python-build/test/fetch.bats index 709aca5c..0c61c2cc 100644 --- a/plugins/python-build/test/fetch.bats +++ b/plugins/python-build/test/fetch.bats @@ -4,6 +4,11 @@ load test_helper export PYTHON_BUILD_SKIP_MIRROR=1 export PYTHON_BUILD_CACHE_PATH= +setup() { + export PYTHON_BUILD_BUILD_PATH="${TMP}/source" + mkdir -p "${PYTHON_BUILD_BUILD_PATH}" +} + @test "failed download displays error message" { stub curl false @@ -12,3 +17,36 @@ export PYTHON_BUILD_CACHE_PATH= assert_output_contains "> http://example.com/packages/package-1.0.0.tar.gz" assert_output_contains "error: failed to download package-1.0.0.tar.gz" } + +@test "fetching from git repository" { + stub git "clone --depth 1 --branch master http://example.com/packages/package.git package-dev : mkdir package-dev" + + run_inline_definition <