(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"Test workflows involving pull request.">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <setup>)} { (SQ <"\n"> <"\n"> <"\tgit init --bare upstream.git &&\n"> <"\tgit init --bare downstream.git &&\n"> <"\tgit clone upstream.git upstream-private &&\n"> <"\tgit clone downstream.git local &&\n"> <"\n"> <"\ttrash_url=\"file://$TRASH_DIRECTORY\" &&\n"> <"\tdownstream_url=\"$trash_url/downstream.git/\" &&\n"> <"\tupstream_url=\"$trash_url/upstream.git/\" &&\n"> <"\n"> <"\t(\n"> <"\t\tcd upstream-private &&\n"> <"\t\tcat <<-\\EOT >mnemonic.txt &&\n"> <"\t\tThirtey days hath November,\n"> <"\t\tAprile, June, and September:\n"> <"\t\tEOT\n"> <"\t\tgit add mnemonic.txt &&\n"> <"\t\ttest_tick &&\n"> <"\t\tgit commit -m \"\\\"Thirty days\\\", a reminder of month lengths\" &&\n"> <"\t\tgit tag -m \"version 1\" -a initial &&\n"> <"\t\tgit push --tags origin master\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd local &&\n"> <"\t\tgit remote add upstream \"$trash_url/upstream.git\" &&\n"> <"\t\tgit fetch upstream &&\n"> <"\t\tgit pull upstream master &&\n"> <"\t\tcat <<-\\EOT >>mnemonic.txt &&\n"> <"\t\tOf twyecescore-eightt is but eine,\n"> <"\t\tAnd all the remnante be thrycescore-eine.\n"> <"\t\tO\u2019course Leap yare comes an\u2019pynes,\n"> <"\t\tEv\u2019rie foure yares, gote it ryghth.\n"> <"\t\tAn\u2019twyecescore-eight is but twyecescore-nyne.\n"> <"\t\tEOT\n"> <"\t\tgit add mnemonic.txt &&\n"> <"\t\ttest_tick &&\n"> <"\t\tgit commit -m \"More detail\" &&\n"> <"\t\tgit tag -m \"version 2\" -a full &&\n"> <"\t\tgit checkout -b simplify HEAD^ &&\n"> <"\t\tmv mnemonic.txt mnemonic.standard &&\n"> <"\t\tcat <<-\\EOT >mnemonic.clarified &&\n"> <"\t\tThirty days has September,\n"> <"\t\tAll the rest I can\u2019t remember.\n"> <"\t\tEOT\n"> <"\t\tgit add -N mnemonic.standard mnemonic.clarified &&\n"> <"\t\tgit commit -a -m \"Adapt to use modern, simpler English\n"> <"\n"> <"But keep the old version, too, in case some people prefer it.\" &&\n"> <"\t\tgit checkout master\n"> <"\t)\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup: two scripts for reading pull requests">)} { (SQ <"\n"> <"\n"> <"\tdownstream_url_for_sed=$(\n"> <"\t\tprintf \"%s\\n\" \"$downstream_url\" |\n"> <"\t\tsed -e "> ) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <"s/\\\\/\\\\\\\\/g">) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <" -e ">) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <"s/[[/.*^$]/\\\\&/g">) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <"\n"> <"\t) &&\n"> <"\n"> <"\tcat <<-\\EOT >read-request.sed &&\n"> <"\t#!/bin/sed -nf\n"> <"\t# Note that a request could ask for \"tag $tagname\"\n"> <"\t/ in the git repository at:$/!d\n"> <"\tn\n"> <"\t/^$/ n\n"> <"\ts/ tag \\([^ ]*\\)$/ tag--\\1/\n"> <"\ts/^[ \t]*\\(.*\\) \\([^ ]*\\)/please pull\\\n"> <"\t\\1\\\n"> <"\t\\2/p\n"> <"\tq\n"> <"\tEOT\n"> <"\n"> <"\tcat <<-EOT >fuzz.sed\n"> <"\t#!/bin/sed -nf\n"> <"\ts/$downstream_url_for_sed/URL/g\n"> <"\ts/$_x40/OBJECT_NAME/g\n"> <"\ts/A U Thor/AUTHOR/g\n"> <"\ts/[-0-9]\\{10\\} [:0-9]\\{8\\} [-+][0-9]\\{4\\}/DATE/g\n"> <"\ts/ [^ ].*/ SUBJECT/g\n"> <"\ts/ [^ ].* (DATE)/ SUBJECT (DATE)/g\n"> <"\ts|tags/full|BRANCH|g\n"> <"\ts/mnemonic.txt/FILENAME/g\n"> <"\ts/^version [0-9]/VERSION/\n"> <"\t/^ FILENAME | *[0-9]* [-+]*\\$/ b diffstat\n"> <"\t/^AUTHOR ([0-9]*):\\$/ b shortlog\n"> <"\tp\n"> <"\tb\n"> <"\t: diffstat\n"> <"\tn\n"> <"\t/ [0-9]* files* changed/ {\n"> <"\t\ta\\\\\n"> <"\tDIFFSTAT\n"> <"\t\tb\n"> <"\t}\n"> <"\tb diffstat\n"> <"\t: shortlog\n"> <"\t/^ [a-zA-Z]/ n\n"> <"\t/^[a-zA-Z]* ([0-9]*):\\$/ n\n"> <"\t/^\\$/ N\n"> <"\t/^\\n[a-zA-Z]* ([0-9]*):\\$/!{\n"> <"\t\ta\\\\\n"> <"\tSHORTLOG\n"> <"\t\tD\n"> <"\t}\n"> <"\tn\n"> <"\tb shortlog\n"> <"\tEOT\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"pull request when forgot to push">)} { (SQ <"\n"> <"\n"> <"\trm -fr downstream.git &&\n"> <"\tgit init --bare downstream.git &&\n"> <"\t(\n"> <"\t\tcd local &&\n"> <"\t\tgit checkout initial &&\n"> <"\t\tgit merge --ff-only master &&\n"> <"\t\ttest_must_fail git request-pull initial \"$downstream_url\" \\\n"> <"\t\t\t2>../err\n"> <"\t) &&\n"> <"\tgrep \"No match for commit .*\" err &&\n"> <"\tgrep \"Are you sure you pushed\" err\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"pull request after push">)} { (SQ <"\n"> <"\n"> <"\trm -fr downstream.git &&\n"> <"\tgit init --bare downstream.git &&\n"> <"\t(\n"> <"\t\tcd local &&\n"> <"\t\tgit checkout initial &&\n"> <"\t\tgit merge --ff-only master &&\n"> <"\t\tgit push origin master:for-upstream &&\n"> <"\t\tgit request-pull initial origin master:for-upstream >../request\n"> <"\t) &&\n"> <"\tsed -nf read-request.sed <request >digest &&\n"> <"\tcat digest &&\n"> <"\t{\n"> <"\t\tread task &&\n"> <"\t\tread repository &&\n"> <"\t\tread branch\n"> <"\t} <digest &&\n"> <"\t(\n"> <"\t\tcd upstream-private &&\n"> <"\t\tgit checkout initial &&\n"> <"\t\tgit pull --ff-only \"$repository\" \"$branch\"\n"> <"\t) &&\n"> <"\ttest \"$branch\" = for-upstream &&\n"> <"\ttest_cmp local/mnemonic.txt upstream-private/mnemonic.txt\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"request asks HEAD to be pulled">)} { (SQ <"\n"> <"\n"> <"\trm -fr downstream.git &&\n"> <"\tgit init --bare downstream.git &&\n"> <"\t(\n"> <"\t\tcd local &&\n"> <"\t\tgit checkout initial &&\n"> <"\t\tgit merge --ff-only master &&\n"> <"\t\tgit push --tags origin master simplify &&\n"> <"\t\tgit push origin master:for-upstream &&\n"> <"\t\tgit request-pull initial \"$downstream_url\" >../request\n"> <"\t) &&\n"> <"\tsed -nf read-request.sed <request >digest &&\n"> <"\tcat digest &&\n"> <"\t{\n"> <"\t\tread task &&\n"> <"\t\tread repository &&\n"> <"\t\tread branch\n"> <"\t} <digest &&\n"> <"\ttest -z \"$branch\"\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"pull request format">)} { (SQ <"\n"> <"\n"> <"\trm -fr downstream.git &&\n"> <"\tgit init --bare downstream.git &&\n"> <"\tcat <<-\\EOT >expect &&\n"> <"\tThe following changes since commit OBJECT_NAME:\n"> <"\n"> <"\t SUBJECT (DATE)\n"> <"\n"> <"\tare available in the git repository at:\n"> <"\n"> <"\t URL BRANCH\n"> <"\n"> <"\tfor you to fetch changes up to OBJECT_NAME:\n"> <"\n"> <"\t SUBJECT (DATE)\n"> <"\n"> <"\t----------------------------------------------------------------\n"> <"\tVERSION\n"> <"\n"> <"\t----------------------------------------------------------------\n"> <"\tSHORTLOG\n"> <"\n"> <"\tDIFFSTAT\n"> <"\tEOT\n"> <"\t(\n"> <"\t\tcd local &&\n"> <"\t\tgit checkout initial &&\n"> <"\t\tgit merge --ff-only master &&\n"> <"\t\tgit push origin tags/full &&\n"> <"\t\tgit request-pull initial \"$downstream_url\" tags/full >../request\n"> <"\t) &&\n"> <"\t<request sed -nf fuzz.sed >request.fuzzy &&\n"> <"\ttest_i18ncmp expect request.fuzzy &&\n"> <"\n"> <"\t(\n"> <"\t\tcd local &&\n"> <"\t\tgit request-pull initial \"$downstream_url\" tags/full:refs/tags/full\n"> <"\t) >request &&\n"> <"\tsed -nf fuzz.sed <request >request.fuzzy &&\n"> <"\ttest_i18ncmp expect request.fuzzy &&\n"> <"\n"> <"\t(\n"> <"\t\tcd local &&\n"> <"\t\tgit request-pull initial \"$downstream_url\" full\n"> <"\t) >request &&\n"> <"\tgrep \" tags/full\\$\" request\n"> ) } ) (C {(test_expect_success)} {(SQ <"request-pull ignores OPTIONS_KEEPDASHDASH poison">)} { (SQ <"\n"> <"\n"> <"\t(\n"> <"\t\tcd local &&\n"> <"\t\tOPTIONS_KEEPDASHDASH=Yes &&\n"> <"\t\texport OPTIONS_KEEPDASHDASH &&\n"> <"\t\tgit checkout initial &&\n"> <"\t\tgit merge --ff-only master &&\n"> <"\t\tgit push origin master:for-upstream &&\n"> <"\t\tgit request-pull -- initial \"$downstream_url\" master:for-upstream >../request\n"> <"\t)\n"> <"\n"> ) } ) (C {(test_done)}) ] )