#!/bin/sh global test_description := ''fetching via git:// using core.gitproxy'' source ./test-lib.sh test_expect_success 'setup remote repo' ' git init remote && (cd remote && echo content >file && git add file && git commit -m one ) ' test_expect_success 'setup proxy script' ' write_script proxy-get-cmd "$PERL_PATH" <<-\EOF && read(STDIN, $buf, 4); my $n = hex($buf) - 4; read(STDIN, $buf, $n); my ($cmd, $other) = split /\0/, $buf; # drop absolute-path on repo name $cmd =~ s{ /}{ }; print $cmd; EOF write_script proxy <<-\EOF echo >&2 "proxying for $*" cmd=$(./proxy-get-cmd) echo >&2 "Running $cmd" exec $cmd EOF ' test_expect_success 'setup local repo' ' git remote add fake git://example.com/remote && git config core.gitproxy ./proxy ' test_expect_success 'fetch through proxy works' ' git fetch fake && echo one >expect && git log -1 --format=%s FETCH_HEAD >actual && test_cmp expect actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"fetching via git:// using core.gitproxy">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <"setup remote repo">)} { (SQ <"\n"> <"\tgit init remote &&\n"> <"\t(cd remote &&\n"> <"\t echo content >file &&\n"> <"\t git add file &&\n"> <"\t git commit -m one\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup proxy script">)} { (SQ <"\n"> <"\twrite_script proxy-get-cmd \"$PERL_PATH\" <<-\\EOF &&\n"> <"\tread(STDIN, $buf, 4);\n"> <"\tmy $n = hex($buf) - 4;\n"> <"\tread(STDIN, $buf, $n);\n"> <"\tmy ($cmd, $other) = split /\\0/, $buf;\n"> <"\t# drop absolute-path on repo name\n"> <"\t$cmd =~ s{ /}{ };\n"> <"\tprint $cmd;\n"> <"\tEOF\n"> <"\n"> <"\twrite_script proxy <<-\\EOF\n"> <"\techo >&2 \"proxying for $*\"\n"> <"\tcmd=$(./proxy-get-cmd)\n"> <"\techo >&2 \"Running $cmd\"\n"> <"\texec $cmd\n"> <"\tEOF\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup local repo">)} { (SQ <"\n"> <"\tgit remote add fake git://example.com/remote &&\n"> <"\tgit config core.gitproxy ./proxy\n"> ) } ) (C {(test_expect_success)} {(SQ <"fetch through proxy works">)} { (SQ <"\n"> <"\tgit fetch fake &&\n"> <"\techo one >expect &&\n"> <"\tgit log -1 --format=%s FETCH_HEAD >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_done)}) ] )