Skip to content

Commit a3d1380

Browse files
committed
scalar: verify that we can use a GVFS-enabled repository
Azure Repos does not support partial clones at the moment, but it does support the GVFS protocol. To that end, the Microsoft fork of Git has a `gvfs-helper` command that is optionally used to perform essentially the same functionality as partial clone. Let's verify that `scalar clone` detects that situation and enables the GVFS helper. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 7b43037 commit a3d1380

File tree

1 file changed

+157
-0
lines changed

1 file changed

+157
-0
lines changed

t/t9210-scalar.sh

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,161 @@ test_expect_success UNZIP 'scalar diagnose' '
305305
grep "^Total: [1-9]" out
306306
'
307307

308+
GIT_TEST_ALLOW_GVFS_VIA_HTTP=1
309+
export GIT_TEST_ALLOW_GVFS_VIA_HTTP
310+
311+
test_set_port GIT_TEST_GVFS_PROTOCOL_PORT
312+
HOST_PORT=127.0.0.1:$GIT_TEST_GVFS_PROTOCOL_PORT
313+
PID_FILE="$(pwd)"/pid-file.pid
314+
SERVER_LOG="$(pwd)"/OUT.server.log
315+
316+
test_atexit '
317+
test -f "$PID_FILE" || return 0
318+
319+
# The server will shutdown automatically when we delete the pid-file.
320+
rm -f "$PID_FILE"
321+
322+
test -z "$verbose$verbose_log" || {
323+
echo "server log:"
324+
cat "$SERVER_LOG"
325+
}
326+
327+
# Give it a few seconds to shutdown (mainly to completely release the
328+
# port before the next test start another instance and it attempts to
329+
# bind to it).
330+
for k in $(test_seq 5)
331+
do
332+
grep -q "Starting graceful shutdown" "$SERVER_LOG" &&
333+
return 0 ||
334+
sleep 1
335+
done
336+
337+
echo "stop_gvfs_protocol_server: timeout waiting for server shutdown"
338+
return 1
339+
'
340+
341+
start_gvfs_enabled_http_server () {
342+
GIT_HTTP_EXPORT_ALL=1 \
343+
test-gvfs-protocol --verbose \
344+
--listen=127.0.0.1 \
345+
--port=$GIT_TEST_GVFS_PROTOCOL_PORT \
346+
--reuseaddr \
347+
--pid-file="$PID_FILE" \
348+
2>"$SERVER_LOG" &
349+
350+
for k in 0 1 2 3 4
351+
do
352+
if test -f "$PID_FILE"
353+
then
354+
return 0
355+
fi
356+
sleep 1
357+
done
358+
return 1
359+
}
360+
361+
test_expect_success 'start GVFS-enabled server' '
362+
git config uploadPack.allowFilter false &&
363+
git config uploadPack.allowAnySHA1InWant false &&
364+
start_gvfs_enabled_http_server
365+
'
366+
367+
test_expect_success '`scalar clone` with GVFS-enabled server' '
368+
: the fake cache server requires fake authentication &&
369+
git config --global core.askPass true &&
370+
371+
# We must set credential.interactive=true to bypass a setting
372+
# in "scalar clone" that disables interactive credentials during
373+
# an unattended command.
374+
scalar -c credential.interactive=true clone --single-branch -- http://$HOST_PORT/ using-gvfs &&
375+
376+
: verify that the shared cache has been configured &&
377+
cache_key="url_$(printf "%s" http://$HOST_PORT/ |
378+
tr A-Z a-z |
379+
test-tool sha1)" &&
380+
echo "$(pwd)/using-gvfs/.scalarCache/$cache_key" >expect &&
381+
git -C using-gvfs/src config gvfs.sharedCache >actual &&
382+
test_cmp expect actual &&
383+
384+
second=$(git rev-parse --verify second:second.t) &&
385+
(
386+
cd using-gvfs/src &&
387+
test_path_is_missing 1/2 &&
388+
GIT_TRACE=$PWD/trace.txt git cat-file blob $second >actual &&
389+
: verify that the gvfs-helper was invoked to fetch it &&
390+
test_grep gvfs-helper trace.txt &&
391+
echo "second" >expect &&
392+
test_cmp expect actual
393+
)
394+
'
395+
396+
test_expect_success '`scalar register` parallel to worktree is unsupported' '
397+
git init test-repo/src &&
398+
mkdir -p test-repo/out &&
399+
400+
: parallel to worktree is unsupported &&
401+
test_must_fail env GIT_CEILING_DIRECTORIES="$(pwd)" \
402+
scalar register test-repo/out &&
403+
test_must_fail git config --get --global --fixed-value \
404+
maintenance.repo "$(pwd)/test-repo/src" &&
405+
scalar list >scalar.repos &&
406+
! grep -F "$(pwd)/test-repo/src" scalar.repos &&
407+
408+
: at enlistment root, i.e. parent of repository, is supported &&
409+
GIT_CEILING_DIRECTORIES="$(pwd)" scalar register test-repo &&
410+
git config --get --global --fixed-value \
411+
maintenance.repo "$(pwd)/test-repo/src" &&
412+
scalar list >scalar.repos &&
413+
grep -F "$(pwd)/test-repo/src" scalar.repos &&
414+
415+
: scalar delete properly unregisters enlistment &&
416+
scalar delete test-repo &&
417+
test_must_fail git config --get --global --fixed-value \
418+
maintenance.repo "$(pwd)/test-repo/src" &&
419+
scalar list >scalar.repos &&
420+
! grep -F "$(pwd)/test-repo/src" scalar.repos
421+
'
422+
423+
test_expect_success '`scalar register` & `unregister` with existing repo' '
424+
git init existing &&
425+
scalar register existing &&
426+
git config --get --global --fixed-value \
427+
maintenance.repo "$(pwd)/existing" &&
428+
scalar list >scalar.repos &&
429+
grep -F "$(pwd)/existing" scalar.repos &&
430+
scalar unregister existing &&
431+
test_must_fail git config --get --global --fixed-value \
432+
maintenance.repo "$(pwd)/existing" &&
433+
scalar list >scalar.repos &&
434+
! grep -F "$(pwd)/existing" scalar.repos
435+
'
436+
437+
test_expect_success '`scalar unregister` with existing repo, deleted .git' '
438+
scalar register existing &&
439+
rm -rf existing/.git &&
440+
scalar unregister existing &&
441+
test_must_fail git config --get --global --fixed-value \
442+
maintenance.repo "$(pwd)/existing" &&
443+
scalar list >scalar.repos &&
444+
! grep -F "$(pwd)/existing" scalar.repos
445+
'
446+
447+
test_expect_success '`scalar register` existing repo with `src` folder' '
448+
git init existing &&
449+
mkdir -p existing/src &&
450+
scalar register existing/src &&
451+
scalar list >scalar.repos &&
452+
grep -F "$(pwd)/existing" scalar.repos &&
453+
scalar unregister existing &&
454+
scalar list >scalar.repos &&
455+
! grep -F "$(pwd)/existing" scalar.repos
456+
'
457+
458+
test_expect_success '`scalar delete` with existing repo' '
459+
git init existing &&
460+
scalar register existing &&
461+
scalar delete existing &&
462+
test_path_is_missing existing
463+
'
464+
308465
test_done

0 commit comments

Comments
 (0)