(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'test_description='> name:test_description) op: assign_op.Equal rhs: {(SQ <'git p4 label tests'>)} spids: [4] ) ] redirects: [] ) (C {<.>} {<'./lib-git-p4.sh'>}) (C {<test_expect_success>} {(SQ <'start p4d'>)} {(SQ <'\n'> <'\tstart_p4d\n'>)}) (C {<test_expect_success>} {(SQ <'basic p4 labels'>)} { (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\tmkdir -p main &&\n'> <'\n'> <'\t\techo f1 >main/f1 &&\n'> <'\t\tp4 add main/f1 &&\n'> <'\t\tp4 submit -d "main/f1" &&\n'> <'\n'> <'\t\techo f2 >main/f2 &&\n'> <'\t\tp4 add main/f2 &&\n'> <'\t\tp4 submit -d "main/f2" &&\n'> <'\n'> <'\t\techo f3 >main/file_with_\\$metachar &&\n'> <'\t\tp4 add main/file_with_\\$metachar &&\n'> <'\t\tp4 submit -d "file with metachar" &&\n'> <'\n'> <'\t\tp4 tag -l TAG_F1_ONLY main/f1 &&\n'> <'\t\tp4 tag -l TAG_WITH\\$_SHELL_CHAR main/... &&\n'> <'\t\tp4 tag -l this_tag_will_be\\ skipped main/... &&\n'> <'\n'> <'\t\techo f4 >main/f4 &&\n'> <'\t\tp4 add main/f4 &&\n'> <'\t\tp4 submit -d "main/f4" &&\n'> <'\n'> <'\t\tp4 label -i <<-EOF &&\n'> <'\t\tLabel: TAG_LONG_LABEL\n'> <'\t\tDescription:\n'> <'\t\t A Label first line\n'> <'\t\t A Label second line\n'> <'\t\tView:\t//depot/...\n'> <'\t\tEOF\n'> <'\n'> <'\t\tp4 tag -l TAG_LONG_LABEL ... &&\n'> <'\n'> <'\t\tp4 labels ... &&\n'> <'\n'> <'\t\tgit p4 clone --dest="$git" //depot@all &&\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit config git-p4.labelImportRegexp ".*TAG.*" &&\n'> <'\t\tgit p4 sync --import-labels --verbose &&\n'> <'\n'> <'\t\tgit tag &&\n'> <'\t\tgit tag >taglist &&\n'> <'\t\ttest_line_count = 3 taglist &&\n'> <'\n'> <'\t\tcd main &&\n'> <'\t\tgit checkout TAG_F1_ONLY &&\n'> <'\t\t! test -f f2 &&\n'> <'\t\tgit checkout TAG_WITH\\$_SHELL_CHAR &&\n'> <'\t\ttest -f f1 && test -f f2 && test -f file_with_\\$metachar &&\n'> <'\n'> <'\t\tgit show TAG_LONG_LABEL | grep -q "A Label second line"\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'two labels on the same changelist'>)} { (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\tmkdir -p main &&\n'> <'\n'> <'\t\tp4 edit main/f1 main/f2 &&\n'> <'\t\techo "hello world" >main/f1 &&\n'> <'\t\techo "not in the tag" >main/f2 &&\n'> <'\t\tp4 submit -d "main/f[12]: testing two labels" &&\n'> <'\n'> <'\t\tp4 tag -l TAG_F1_1 main/... &&\n'> <'\t\tp4 tag -l TAG_F1_2 main/... &&\n'> <'\n'> <'\t\tp4 labels ... &&\n'> <'\n'> <'\t\tgit p4 clone --dest="$git" //depot@all &&\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit p4 sync --import-labels &&\n'> <'\n'> <'\t\tgit tag | grep TAG_F1 &&\n'> <'\t\tgit tag | grep -q TAG_F1_1 &&\n'> <'\t\tgit tag | grep -q TAG_F1_2 &&\n'> <'\n'> <'\t\tcd main &&\n'> <'\n'> <'\t\tgit checkout TAG_F1_1 &&\n'> <'\t\tls &&\n'> <'\t\ttest -f f1 &&\n'> <'\n'> <'\t\tgit checkout TAG_F1_2 &&\n'> <'\t\tls &&\n'> <'\t\ttest -f f1\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'export git tags to p4'>)} { (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --dest="$git" //depot@all &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit tag -m "A tag created in git:xyzzy" GIT_TAG_1 &&\n'> <'\t\techo "hello world" >main/f10 &&\n'> <'\t\tgit add main/f10 &&\n'> <'\t\tgit commit -m "Adding file for export test" &&\n'> <'\t\tgit config git-p4.skipSubmitEdit true &&\n'> <'\t\tgit p4 submit &&\n'> <'\t\tgit tag -m "Another git tag" GIT_TAG_2 &&\n'> <'\t\tgit tag LIGHTWEIGHT_TAG &&\n'> <'\t\tgit p4 rebase --import-labels --verbose &&\n'> <'\t\tgit p4 submit --export-labels --verbose\n'> <'\t) &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\tp4 sync ... &&\n'> <'\t\tp4 labels ... | grep GIT_TAG_1 &&\n'> <'\t\tp4 labels ... | grep GIT_TAG_2 &&\n'> <'\t\tp4 labels ... | grep LIGHTWEIGHT_TAG &&\n'> <'\t\tp4 label -o GIT_TAG_1 | grep "tag created in git:xyzzy" &&\n'> <'\t\tp4 sync ...@GIT_TAG_1 &&\n'> <'\t\t! test -f main/f10\n'> <'\t\tp4 sync ...@GIT_TAG_2 &&\n'> <'\t\ttest -f main/f10\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'export git tags to p4 with deletion'>)} { (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --dest="$git" //depot@all &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit p4 sync --import-labels &&\n'> <'\t\techo "deleted file" >main/deleted_file &&\n'> <'\t\tgit add main/deleted_file &&\n'> <'\t\tgit commit -m "create deleted file" &&\n'> <'\t\tgit rm main/deleted_file &&\n'> <'\t\techo "new file" >main/f11 &&\n'> <'\t\tgit add main/f11 &&\n'> <'\t\tgit commit -m "delete the deleted file" &&\n'> <'\t\tgit config git-p4.skipSubmitEdit true &&\n'> <'\t\tgit p4 submit &&\n'> <'\t\tgit p4 rebase --import-labels --verbose &&\n'> <'\t\tgit tag -m "tag on deleted file" GIT_TAG_ON_DELETED HEAD~1 &&\n'> <'\t\tgit tag -m "tag after deletion" GIT_TAG_AFTER_DELETION HEAD &&\n'> <'\t\tgit p4 submit --export-labels --verbose\n'> <'\t) &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\tp4 sync ... &&\n'> <'\t\tp4 sync ...@GIT_TAG_ON_DELETED &&\n'> <'\t\ttest -f main/deleted_file &&\n'> <'\t\tp4 sync ...@GIT_TAG_AFTER_DELETION &&\n'> <'\t\t! test -f main/deleted_file &&\n'> <'\t\techo "checking label contents" &&\n'> <'\t\tp4 label -o GIT_TAG_ON_DELETED | grep "tag on deleted file"\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'tag that cannot be exported'>)} { (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --dest="$git" //depot@all &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit checkout -b a_branch &&\n'> <'\t\techo "hello" >main/f12 &&\n'> <'\t\tgit add main/f12 &&\n'> <'\t\tgit commit -m "adding f12" &&\n'> <'\t\tgit tag -m "tag on a_branch" GIT_TAG_ON_A_BRANCH &&\n'> <'\t\tgit checkout master &&\n'> <'\t\tgit p4 submit --export-labels\n'> <'\t) &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\tp4 sync ... &&\n'> <'\t\t!(p4 labels | grep GIT_TAG_ON_A_BRANCH)\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'use git config to enable import/export of tags'>)} { (SQ <'\n'> <'\tgit p4 clone --verbose --dest="$git" //depot@all &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit config git-p4.exportLabels true &&\n'> <'\t\tgit config git-p4.importLabels true &&\n'> <'\t\tgit tag CFG_A_GIT_TAG &&\n'> <'\t\tgit p4 rebase --verbose &&\n'> <'\t\tgit p4 submit --verbose &&\n'> <'\t\tgit tag &&\n'> <'\t\tgit tag | grep TAG_F1_1\n'> <'\t) &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\tp4 labels &&\n'> <'\t\tp4 labels | grep CFG_A_GIT_TAG\n'> <'\t)\n'> ) } ) (command.ShFunction name: p4_head_revision body: (BraceGroup left: <Id.Lit_LBrace '{'> children: [ (command.Pipeline children: [ (C {<p4>} {<changes>} {<-m>} {<1>} {(DQ ($ Id.VSub_At '@'))}) (C {<awk>} {(SQ <'{print $2}'>)}) ] negated: F stderr_indices: [] ) ] redirects: [] right: <Id.Lit_RBrace '}'> ) ) (C {<test_expect_success>} {(SQ <'importing labels with missing revisions'>)} { (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> <'\t\trm -fr "$cli" "$git" &&\n'> <'\t\tmkdir "$cli" &&\n'> <'\t\tP4CLIENT=missing-revision &&\n'> <'\t\tclient_view "//depot/missing-revision/... //missing-revision/..." &&\n'> <'\t\tcd "$cli" &&\n'> <'\t\t>f1 && p4 add f1 && p4 submit -d "start" &&\n'> <'\n'> <'\t\tp4 tag -l TAG_S0 ... &&\n'> <'\n'> <'\t\t>f2 && p4 add f2 && p4 submit -d "second" &&\n'> <'\n'> <'\t\tstartrev=$(p4_head_revision //depot/missing-revision/...) &&\n'> <'\n'> <'\t\t>f3 && p4 add f3 && p4 submit -d "third" &&\n'> <'\n'> <'\t\tp4 edit f2 && date >f2 && p4 submit -d "change" f2 &&\n'> <'\n'> <'\t\tendrev=$(p4_head_revision //depot/missing-revision/...) &&\n'> <'\n'> <'\t\tp4 tag -l TAG_S1 ... &&\n'> <'\n'> <'\t\t# we should skip TAG_S0 since it is before our startpoint,\n'> <'\t\t# but pick up TAG_S1.\n'> <'\n'> <'\t\tgit p4 clone --dest="$git" --import-labels -v \\\n'> <'\t\t\t//depot/missing-revision/...@$startrev,$endrev &&\n'> <'\t\t(\n'> <'\t\t\tcd "$git" &&\n'> <'\t\t\tgit rev-parse TAG_S1 &&\n'> <'\t\t\t! git rev-parse TAG_S0\n'> <'\t\t)\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'kill p4d'>)} {(SQ <'\n'> <'\tkill_p4d\n'>)}) (C {<test_done>}) ] )