#!/bin/sh global test_description := ''Clone repositories and map users'' source ./lib-git-p4.sh test_expect_success 'start p4d' ' start_p4d ' test_expect_success 'Create a repo with different users' ' client_view "//depot/... //client/..." && ( cd "$cli" && >author.txt && p4 add author.txt && p4 submit -d "Add file author\\n" && P4USER=mmax && >max.txt && p4 add max.txt && p4 submit -d "Add file max" && P4USER=eri && >moritz.txt && p4 add moritz.txt && p4 submit -d "Add file moritz" && P4USER=no && >nobody.txt && p4 add nobody.txt && p4 submit -d "Add file nobody" ) ' test_expect_success 'Clone repo root path with all history' ' client_view "//depot/... //client/..." && test_when_finished cleanup_git && ( cd "$git" && git init . && git config --add git-p4.mapUser "mmax = Max Musterman " && git config --add git-p4.mapUser " eri=Erika Musterman " && git p4 clone --use-client-spec --destination="$git" //depot@all && cat >expect <<-\EOF && no Erika Musterman Max Musterman Dr. author EOF git log --format="%an <%ae>" >actual && test_cmp expect actual ) ' test_expect_success 'kill p4d' ' kill_p4d ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"Clone repositories and map users">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./lib-git-p4.sh)}) (C {(test_expect_success)} {(SQ <"start p4d">)} {(SQ <"\n"> <"\tstart_p4d\n">)}) (C {(test_expect_success)} {(SQ <"Create a repo with different users">)} { (SQ <"\n"> <"\tclient_view \"//depot/... //client/...\" &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\n"> <"\t\t>author.txt &&\n"> <"\t\tp4 add author.txt &&\n"> <"\t\tp4 submit -d \"Add file author\\\\n\" &&\n"> <"\n"> <"\t\tP4USER=mmax &&\n"> <"\t\t>max.txt &&\n"> <"\t\tp4 add max.txt &&\n"> <"\t\tp4 submit -d \"Add file max\" &&\n"> <"\n"> <"\t\tP4USER=eri &&\n"> <"\t\t>moritz.txt &&\n"> <"\t\tp4 add moritz.txt &&\n"> <"\t\tp4 submit -d \"Add file moritz\" &&\n"> <"\n"> <"\t\tP4USER=no &&\n"> <"\t\t>nobody.txt &&\n"> <"\t\tp4 add nobody.txt &&\n"> <"\t\tp4 submit -d \"Add file nobody\"\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"Clone repo root path with all history">)} { (SQ <"\n"> <"\tclient_view \"//depot/... //client/...\" &&\n"> <"\ttest_when_finished cleanup_git &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> <"\t\tgit init . &&\n"> < "\t\tgit config --add git-p4.mapUser \"mmax = Max Musterman \" &&\n" > <"\t\tgit config --add git-p4.mapUser \" eri=Erika Musterman \" &&\n"> <"\t\tgit p4 clone --use-client-spec --destination=\"$git\" //depot@all &&\n"> <"\t\tcat >expect <<-\\EOF &&\n"> <"\t\t\tno \n"> <"\t\t\tErika Musterman \n"> <"\t\t\tMax Musterman \n"> <"\t\t\tDr. author \n"> <"\t\tEOF\n"> <"\t\tgit log --format=\"%an <%ae>\" >actual &&\n"> <"\t\ttest_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"kill p4d">)} {(SQ <"\n"> <"\tkill_p4d\n">)}) (C {(test_done)}) ] )