#!/bin/sh global test_description := ''git p4 retrieve job info'' source ./lib-git-p4.sh test_expect_success 'start p4d' ' start_p4d ' test_expect_success 'add p4 jobs' ' ( p4_add_job TESTJOB-A && p4_add_job TESTJOB-B ) ' test_expect_success 'add p4 files' ' client_view "//depot/... //client/..." && ( cd "$cli" && >file1 && p4 add file1 && p4 submit -d "Add file 1" ) ' test_expect_success 'check log message of changelist with no jobs' ' client_view "//depot/... //client/..." && test_when_finished cleanup_git && ( cd "$git" && git init . && git p4 clone --use-client-spec --destination="$git" //depot@all && cat >expect <<-\EOF && Add file 1 [git-p4: depot-paths = "//depot/": change = 1] EOF git log --format=%B >actual && test_cmp expect actual ) ' test_expect_success 'add TESTJOB-A to change 1' ' ( cd "$cli" && p4 fix -c 1 TESTJOB-A ) ' test_expect_success 'check log message of changelist with one job' ' client_view "//depot/... //client/..." && test_when_finished cleanup_git && ( cd "$git" && git init . && git p4 clone --use-client-spec --destination="$git" //depot@all && cat >expect <<-\EOF && Add file 1 Jobs: TESTJOB-A [git-p4: depot-paths = "//depot/": change = 1] EOF git log --format=%B >actual && test_cmp expect actual ) ' test_expect_success 'add TESTJOB-B to change 1' ' ( cd "$cli" && p4 fix -c 1 TESTJOB-B ) ' test_expect_success 'check log message of changelist with more jobs' ' client_view "//depot/... //client/..." && test_when_finished cleanup_git && ( cd "$git" && git init . && git p4 clone --use-client-spec --destination="$git" //depot@all && cat >expect <<-\EOF && Add file 1 Jobs: TESTJOB-A TESTJOB-B [git-p4: depot-paths = "//depot/": change = 1] EOF git log --format=%B >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 <"git p4 retrieve job info">)} 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 <"add p4 jobs">)} { (SQ <"\n"> <"\t(\n"> <"\t\tp4_add_job TESTJOB-A &&\n"> <"\t\tp4_add_job TESTJOB-B\n"> <"\t)\n">) } ) (C {(test_expect_success)} {(SQ <"add p4 files">)} { (SQ <"\n"> <"\tclient_view \"//depot/... //client/...\" &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\t>file1 &&\n"> <"\t\tp4 add file1 &&\n"> <"\t\tp4 submit -d \"Add file 1\"\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"check log message of changelist with no jobs">)} { (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 p4 clone --use-client-spec --destination=\"$git\" //depot@all &&\n"> <"\t\tcat >expect <<-\\EOF &&\n"> <"\t\tAdd file 1\n"> <"\t\t[git-p4: depot-paths = \"//depot/\": change = 1]\n"> <"\n"> <"\t\tEOF\n"> <"\t\tgit log --format=%B >actual &&\n"> <"\t\ttest_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"add TESTJOB-A to change 1">)} {(SQ <"\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\tp4 fix -c 1 TESTJOB-A\n"> <"\t)\n">)} ) (C {(test_expect_success)} {(SQ <"check log message of changelist with one job">)} { (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 p4 clone --use-client-spec --destination=\"$git\" //depot@all &&\n"> <"\t\tcat >expect <<-\\EOF &&\n"> <"\t\tAdd file 1\n"> <"\t\tJobs: TESTJOB-A\n"> <"\t\t[git-p4: depot-paths = \"//depot/\": change = 1]\n"> <"\n"> <"\t\tEOF\n"> <"\t\tgit log --format=%B >actual &&\n"> <"\t\ttest_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"add TESTJOB-B to change 1">)} {(SQ <"\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\tp4 fix -c 1 TESTJOB-B\n"> <"\t)\n">)} ) (C {(test_expect_success)} {(SQ <"check log message of changelist with more jobs">)} { (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 p4 clone --use-client-spec --destination=\"$git\" //depot@all &&\n"> <"\t\tcat >expect <<-\\EOF &&\n"> <"\t\tAdd file 1\n"> <"\t\tJobs: TESTJOB-A TESTJOB-B\n"> <"\t\t[git-p4: depot-paths = \"//depot/\": change = 1]\n"> <"\n"> <"\t\tEOF\n"> <"\t\tgit log --format=%B >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)}) ] )