Surely update local git working copy

This commit is contained in:
Yamashita Yuu 2014-04-17 00:35:38 +09:00
parent 28dcc3f85b
commit 07ef88d7c8
2 changed files with 13 additions and 5 deletions

View file

@ -357,9 +357,9 @@ fetch_git() {
pushd "$RUBY_BUILD_CACHE_PATH" >&4 pushd "$RUBY_BUILD_CACHE_PATH" >&4
local clone_name="$(sanitize "$git_url")" local clone_name="$(sanitize "$git_url")"
if [ -e "${clone_name}" ]; then if [ -e "${clone_name}" ]; then
( cd "${clone_name}" { cd "${clone_name}"
git fetch --force "$git_url" "+${git_ref}:${git_ref}" git fetch --force "$git_url" "+${git_ref}:${git_ref}"
) >&4 2>&1 } >&4 2>&1
else else
git clone --bare --branch "$git_ref" "$git_url" "${clone_name}" >&4 2>&1 git clone --bare --branch "$git_ref" "$git_url" "${clone_name}" >&4 2>&1
fi fi
@ -369,7 +369,8 @@ fetch_git() {
if [ -e "${package_name}" ]; then if [ -e "${package_name}" ]; then
( cd "${package_name}" ( cd "${package_name}"
git fetch --force --update-head-ok "$git_url" "+${git_ref}:${git_ref}" git fetch --depth 1 origin "+${git_ref}"
git checkout -q -B "$git_ref" "origin/${git_ref}"
) >&4 2>&1 ) >&4 2>&1
else else
git clone --depth 1 --branch "$git_ref" "$git_url" "${package_name}" >&4 2>&1 git clone --depth 1 --branch "$git_ref" "$git_url" "${package_name}" >&4 2>&1

View file

@ -4,6 +4,11 @@ load test_helper
export RUBY_BUILD_SKIP_MIRROR=1 export RUBY_BUILD_SKIP_MIRROR=1
export RUBY_BUILD_CACHE_PATH= export RUBY_BUILD_CACHE_PATH=
setup() {
export RUBY_BUILD_BUILD_PATH="${TMP}/source"
mkdir -p "${RUBY_BUILD_BUILD_PATH}"
}
@test "failed download displays error message" { @test "failed download displays error message" {
stub curl false stub curl false
@ -29,10 +34,12 @@ OUT
} }
@test "updating existing git repository" { @test "updating existing git repository" {
stub git "fetch --force --update-head-ok http://example.com/packages/package.git +master:master : true" mkdir -p "${RUBY_BUILD_BUILD_PATH}/package-dev"
stub git \
"fetch --depth 1 origin +master : true" \
"checkout -q -B master origin/master : true"
run_inline_definition <<DEF run_inline_definition <<DEF
mkdir "\${BUILD_PATH}/package-dev"
install_git "package-dev" "http://example.com/packages/package.git" master copy install_git "package-dev" "http://example.com/packages/package.git" master copy
DEF DEF
assert_success assert_success