Pete Wyckoff | c145225 | 2011-12-09 18:48:15 -0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Pete Wyckoff | 6ab1d76 | 2012-04-08 20:18:02 -0400 | [diff] [blame] | 3 | test_description='git p4 submit' |
Pete Wyckoff | c145225 | 2011-12-09 18:48:15 -0500 | [diff] [blame] | 4 | |
| 5 | . ./lib-git-p4.sh |
| 6 | |
| 7 | test_expect_success 'start p4d' ' |
| 8 | start_p4d |
| 9 | ' |
| 10 | |
| 11 | test_expect_success 'init depot' ' |
| 12 | ( |
| 13 | cd "$cli" && |
| 14 | echo file1 >file1 && |
| 15 | p4 add file1 && |
| 16 | p4 submit -d "change 1" |
| 17 | ) |
| 18 | ' |
| 19 | |
Pete Wyckoff | 0577849 | 2014-01-21 18:16:42 -0500 | [diff] [blame] | 20 | test_expect_success 'is_cli_file_writeable function' ' |
Pete Wyckoff | e9df0f9 | 2013-01-26 22:11:17 -0500 | [diff] [blame] | 21 | ( |
| 22 | cd "$cli" && |
| 23 | echo a >a && |
| 24 | is_cli_file_writeable a && |
| 25 | ! is_cli_file_writeable file1 && |
| 26 | rm a |
| 27 | ) |
| 28 | ' |
| 29 | |
Pete Wyckoff | c145225 | 2011-12-09 18:48:15 -0500 | [diff] [blame] | 30 | test_expect_success 'submit with no client dir' ' |
| 31 | test_when_finished cleanup_git && |
Pete Wyckoff | 6ab1d76 | 2012-04-08 20:18:02 -0400 | [diff] [blame] | 32 | git p4 clone --dest="$git" //depot && |
Pete Wyckoff | c145225 | 2011-12-09 18:48:15 -0500 | [diff] [blame] | 33 | ( |
| 34 | cd "$git" && |
| 35 | echo file2 >file2 && |
| 36 | git add file2 && |
| 37 | git commit -m "git commit 2" && |
| 38 | rm -rf "$cli" && |
| 39 | git config git-p4.skipSubmitEdit true && |
Pete Wyckoff | 6ab1d76 | 2012-04-08 20:18:02 -0400 | [diff] [blame] | 40 | git p4 submit |
Pete Wyckoff | 8d7ec36 | 2012-04-29 20:57:14 -0400 | [diff] [blame] | 41 | ) && |
| 42 | ( |
| 43 | cd "$cli" && |
| 44 | test_path_is_file file1 && |
| 45 | test_path_is_file file2 |
Pete Wyckoff | c145225 | 2011-12-09 18:48:15 -0500 | [diff] [blame] | 46 | ) |
| 47 | ' |
| 48 | |
Pete Wyckoff | 28755db | 2011-12-24 21:07:40 -0500 | [diff] [blame] | 49 | # make two commits, but tell it to apply only from HEAD^ |
| 50 | test_expect_success 'submit --origin' ' |
| 51 | test_when_finished cleanup_git && |
Pete Wyckoff | 6ab1d76 | 2012-04-08 20:18:02 -0400 | [diff] [blame] | 52 | git p4 clone --dest="$git" //depot && |
Pete Wyckoff | 28755db | 2011-12-24 21:07:40 -0500 | [diff] [blame] | 53 | ( |
| 54 | cd "$git" && |
| 55 | test_commit "file3" && |
| 56 | test_commit "file4" && |
| 57 | git config git-p4.skipSubmitEdit true && |
Pete Wyckoff | 6ab1d76 | 2012-04-08 20:18:02 -0400 | [diff] [blame] | 58 | git p4 submit --origin=HEAD^ |
Pete Wyckoff | 28755db | 2011-12-24 21:07:40 -0500 | [diff] [blame] | 59 | ) && |
| 60 | ( |
| 61 | cd "$cli" && |
Pete Wyckoff | 28755db | 2011-12-24 21:07:40 -0500 | [diff] [blame] | 62 | test_path_is_missing "file3.t" && |
| 63 | test_path_is_file "file4.t" |
| 64 | ) |
| 65 | ' |
| 66 | |
Pete Wyckoff | ef739f0 | 2012-09-09 16:16:11 -0400 | [diff] [blame] | 67 | test_expect_success 'submit --dry-run' ' |
| 68 | test_when_finished cleanup_git && |
| 69 | git p4 clone --dest="$git" //depot && |
| 70 | ( |
| 71 | cd "$git" && |
| 72 | test_commit "dry-run1" && |
| 73 | test_commit "dry-run2" && |
| 74 | git p4 submit --dry-run >out && |
| 75 | test_i18ngrep "Would apply" out |
| 76 | ) && |
| 77 | ( |
| 78 | cd "$cli" && |
| 79 | test_path_is_missing "dry-run1.t" && |
| 80 | test_path_is_missing "dry-run2.t" |
| 81 | ) |
| 82 | ' |
| 83 | |
| 84 | test_expect_success 'submit --dry-run --export-labels' ' |
| 85 | test_when_finished cleanup_git && |
| 86 | git p4 clone --dest="$git" //depot && |
| 87 | ( |
| 88 | cd "$git" && |
| 89 | echo dry-run1 >dry-run1 && |
| 90 | git add dry-run1 && |
| 91 | git commit -m "dry-run1" dry-run1 && |
| 92 | git config git-p4.skipSubmitEdit true && |
| 93 | git p4 submit && |
| 94 | echo dry-run2 >dry-run2 && |
| 95 | git add dry-run2 && |
| 96 | git commit -m "dry-run2" dry-run2 && |
| 97 | git tag -m "dry-run-tag1" dry-run-tag1 HEAD^ && |
| 98 | git p4 submit --dry-run --export-labels >out && |
| 99 | test_i18ngrep "Would create p4 label" out |
| 100 | ) && |
| 101 | ( |
| 102 | cd "$cli" && |
| 103 | test_path_is_file "dry-run1" && |
| 104 | test_path_is_missing "dry-run2" |
| 105 | ) |
| 106 | ' |
| 107 | |
Pete Wyckoff | 28755db | 2011-12-24 21:07:40 -0500 | [diff] [blame] | 108 | test_expect_success 'submit with allowSubmit' ' |
| 109 | test_when_finished cleanup_git && |
Pete Wyckoff | 6ab1d76 | 2012-04-08 20:18:02 -0400 | [diff] [blame] | 110 | git p4 clone --dest="$git" //depot && |
Pete Wyckoff | 28755db | 2011-12-24 21:07:40 -0500 | [diff] [blame] | 111 | ( |
| 112 | cd "$git" && |
| 113 | test_commit "file5" && |
| 114 | git config git-p4.skipSubmitEdit true && |
| 115 | git config git-p4.allowSubmit "nobranch" && |
Pete Wyckoff | 6ab1d76 | 2012-04-08 20:18:02 -0400 | [diff] [blame] | 116 | test_must_fail git p4 submit && |
Pete Wyckoff | 28755db | 2011-12-24 21:07:40 -0500 | [diff] [blame] | 117 | git config git-p4.allowSubmit "nobranch,master" && |
Pete Wyckoff | 6ab1d76 | 2012-04-08 20:18:02 -0400 | [diff] [blame] | 118 | git p4 submit |
Pete Wyckoff | 28755db | 2011-12-24 21:07:40 -0500 | [diff] [blame] | 119 | ) |
| 120 | ' |
| 121 | |
| 122 | test_expect_success 'submit with master branch name from argv' ' |
| 123 | test_when_finished cleanup_git && |
Pete Wyckoff | 6ab1d76 | 2012-04-08 20:18:02 -0400 | [diff] [blame] | 124 | git p4 clone --dest="$git" //depot && |
Pete Wyckoff | 28755db | 2011-12-24 21:07:40 -0500 | [diff] [blame] | 125 | ( |
| 126 | cd "$git" && |
| 127 | test_commit "file6" && |
| 128 | git config git-p4.skipSubmitEdit true && |
Pete Wyckoff | 6ab1d76 | 2012-04-08 20:18:02 -0400 | [diff] [blame] | 129 | test_must_fail git p4 submit nobranch && |
Pete Wyckoff | 28755db | 2011-12-24 21:07:40 -0500 | [diff] [blame] | 130 | git branch otherbranch && |
| 131 | git reset --hard HEAD^ && |
| 132 | test_commit "file7" && |
Pete Wyckoff | 6ab1d76 | 2012-04-08 20:18:02 -0400 | [diff] [blame] | 133 | git p4 submit otherbranch |
Pete Wyckoff | 28755db | 2011-12-24 21:07:40 -0500 | [diff] [blame] | 134 | ) && |
| 135 | ( |
| 136 | cd "$cli" && |
Pete Wyckoff | 28755db | 2011-12-24 21:07:40 -0500 | [diff] [blame] | 137 | test_path_is_file "file6.t" && |
| 138 | test_path_is_missing "file7.t" |
| 139 | ) |
| 140 | ' |
| 141 | |
Luke Diamand | eff4511 | 2017-04-15 11:36:09 +0100 | [diff] [blame] | 142 | test_expect_success 'allow submit from branch with same revision but different name' ' |
Luke Diamand | 3d553cc | 2017-04-15 11:36:07 +0100 | [diff] [blame] | 143 | test_when_finished cleanup_git && |
| 144 | git p4 clone --dest="$git" //depot && |
| 145 | ( |
| 146 | cd "$git" && |
| 147 | test_commit "file8" && |
| 148 | git checkout -b branch1 && |
| 149 | git checkout -b branch2 && |
| 150 | git config git-p4.skipSubmitEdit true && |
| 151 | git config git-p4.allowSubmit "branch1" && |
| 152 | test_must_fail git p4 submit && |
| 153 | git checkout branch1 && |
| 154 | git p4 submit |
| 155 | ) |
| 156 | ' |
| 157 | |
Romain Merland | f55b87c | 2018-06-01 09:46:14 +0200 | [diff] [blame] | 158 | # make two commits, but tell it to apply only one |
| 159 | |
| 160 | test_expect_success 'submit --commit one' ' |
| 161 | test_when_finished cleanup_git && |
| 162 | git p4 clone --dest="$git" //depot && |
| 163 | ( |
| 164 | cd "$git" && |
| 165 | test_commit "file9" && |
| 166 | test_commit "file10" && |
| 167 | git config git-p4.skipSubmitEdit true && |
| 168 | git p4 submit --commit HEAD |
| 169 | ) && |
| 170 | ( |
| 171 | cd "$cli" && |
| 172 | test_path_is_missing "file9.t" && |
| 173 | test_path_is_file "file10.t" |
| 174 | ) |
| 175 | ' |
| 176 | |
| 177 | # make three commits, but tell it to apply only range |
| 178 | |
| 179 | test_expect_success 'submit --commit range' ' |
| 180 | test_when_finished cleanup_git && |
| 181 | git p4 clone --dest="$git" //depot && |
| 182 | ( |
| 183 | cd "$git" && |
| 184 | test_commit "file11" && |
| 185 | test_commit "file12" && |
| 186 | test_commit "file13" && |
| 187 | git config git-p4.skipSubmitEdit true && |
| 188 | git p4 submit --commit HEAD~2..HEAD |
| 189 | ) && |
| 190 | ( |
| 191 | cd "$cli" && |
| 192 | test_path_is_missing "file11.t" && |
| 193 | test_path_is_file "file12.t" && |
| 194 | test_path_is_file "file13.t" |
| 195 | ) |
| 196 | ' |
| 197 | |
Pete Wyckoff | 0f224e5 | 2012-04-29 20:57:15 -0400 | [diff] [blame] | 198 | # |
| 199 | # Basic submit tests, the five handled cases |
| 200 | # |
| 201 | |
| 202 | test_expect_success 'submit modify' ' |
| 203 | test_when_finished cleanup_git && |
| 204 | git p4 clone --dest="$git" //depot && |
| 205 | ( |
| 206 | cd "$git" && |
| 207 | git config git-p4.skipSubmitEdit true && |
| 208 | echo line >>file1 && |
| 209 | git add file1 && |
| 210 | git commit -m file1 && |
| 211 | git p4 submit |
| 212 | ) && |
| 213 | ( |
| 214 | cd "$cli" && |
| 215 | test_path_is_file file1 && |
| 216 | test_line_count = 2 file1 |
| 217 | ) |
| 218 | ' |
| 219 | |
| 220 | test_expect_success 'submit add' ' |
| 221 | test_when_finished cleanup_git && |
| 222 | git p4 clone --dest="$git" //depot && |
| 223 | ( |
| 224 | cd "$git" && |
| 225 | git config git-p4.skipSubmitEdit true && |
| 226 | echo file13 >file13 && |
| 227 | git add file13 && |
| 228 | git commit -m file13 && |
| 229 | git p4 submit |
| 230 | ) && |
| 231 | ( |
| 232 | cd "$cli" && |
| 233 | test_path_is_file file13 |
| 234 | ) |
| 235 | ' |
| 236 | |
| 237 | test_expect_success 'submit delete' ' |
| 238 | test_when_finished cleanup_git && |
| 239 | git p4 clone --dest="$git" //depot && |
| 240 | ( |
| 241 | cd "$git" && |
| 242 | git config git-p4.skipSubmitEdit true && |
| 243 | git rm file4.t && |
| 244 | git commit -m "delete file4.t" && |
| 245 | git p4 submit |
| 246 | ) && |
| 247 | ( |
| 248 | cd "$cli" && |
| 249 | test_path_is_missing file4.t |
| 250 | ) |
| 251 | ' |
| 252 | |
| 253 | test_expect_success 'submit copy' ' |
| 254 | test_when_finished cleanup_git && |
| 255 | git p4 clone --dest="$git" //depot && |
| 256 | ( |
| 257 | cd "$git" && |
| 258 | git config git-p4.skipSubmitEdit true && |
| 259 | git config git-p4.detectCopies true && |
| 260 | git config git-p4.detectCopiesHarder true && |
| 261 | cp file5.t file5.ta && |
| 262 | git add file5.ta && |
| 263 | git commit -m "copy to file5.ta" && |
| 264 | git p4 submit |
| 265 | ) && |
| 266 | ( |
| 267 | cd "$cli" && |
Pete Wyckoff | b6ad6dc | 2012-04-29 20:57:16 -0400 | [diff] [blame] | 268 | test_path_is_file file5.ta && |
Pete Wyckoff | e9df0f9 | 2013-01-26 22:11:17 -0500 | [diff] [blame] | 269 | ! is_cli_file_writeable file5.ta |
Pete Wyckoff | 0f224e5 | 2012-04-29 20:57:15 -0400 | [diff] [blame] | 270 | ) |
| 271 | ' |
| 272 | |
| 273 | test_expect_success 'submit rename' ' |
| 274 | test_when_finished cleanup_git && |
| 275 | git p4 clone --dest="$git" //depot && |
| 276 | ( |
| 277 | cd "$git" && |
| 278 | git config git-p4.skipSubmitEdit true && |
| 279 | git config git-p4.detectRenames true && |
| 280 | git mv file6.t file6.ta && |
| 281 | git commit -m "rename file6.t to file6.ta" && |
| 282 | git p4 submit |
| 283 | ) && |
| 284 | ( |
| 285 | cd "$cli" && |
| 286 | test_path_is_missing file6.t && |
Pete Wyckoff | b6ad6dc | 2012-04-29 20:57:16 -0400 | [diff] [blame] | 287 | test_path_is_file file6.ta && |
Pete Wyckoff | e9df0f9 | 2013-01-26 22:11:17 -0500 | [diff] [blame] | 288 | ! is_cli_file_writeable file6.ta |
Pete Wyckoff | 0f224e5 | 2012-04-29 20:57:15 -0400 | [diff] [blame] | 289 | ) |
| 290 | ' |
| 291 | |
Pete Wyckoff | f19cb0a | 2012-07-04 09:34:20 -0400 | [diff] [blame] | 292 | # |
| 293 | # Converting git commit message to p4 change description, including |
| 294 | # parsing out the optional Jobs: line. |
| 295 | # |
| 296 | test_expect_success 'simple one-line description' ' |
| 297 | test_when_finished cleanup_git && |
| 298 | git p4 clone --dest="$git" //depot && |
| 299 | ( |
| 300 | cd "$git" && |
| 301 | echo desc2 >desc2 && |
| 302 | git add desc2 && |
| 303 | cat >msg <<-EOF && |
| 304 | One-line description line for desc2. |
| 305 | EOF |
| 306 | git commit -F - <msg && |
| 307 | git config git-p4.skipSubmitEdit true && |
| 308 | git p4 submit && |
| 309 | change=$(p4 -G changes -m 1 //depot/... | \ |
| 310 | marshal_dump change) && |
| 311 | # marshal_dump always adds a newline |
| 312 | p4 -G describe $change | marshal_dump desc | sed \$d >pmsg && |
| 313 | test_cmp msg pmsg |
| 314 | ) |
| 315 | ' |
| 316 | |
| 317 | test_expect_success 'description with odd formatting' ' |
| 318 | test_when_finished cleanup_git && |
| 319 | git p4 clone --dest="$git" //depot && |
| 320 | ( |
| 321 | cd "$git" && |
| 322 | echo desc3 >desc3 && |
| 323 | git add desc3 && |
| 324 | ( |
| 325 | printf "subject line\n\n\tExtra tab\nline.\n\n" && |
| 326 | printf "Description:\n\tBogus description marker\n\n" && |
| 327 | # git commit eats trailing newlines; only use one |
| 328 | printf "Files:\n\tBogus descs marker\n" |
| 329 | ) >msg && |
| 330 | git commit -F - <msg && |
| 331 | git config git-p4.skipSubmitEdit true && |
| 332 | git p4 submit && |
| 333 | change=$(p4 -G changes -m 1 //depot/... | \ |
| 334 | marshal_dump change) && |
| 335 | # marshal_dump always adds a newline |
| 336 | p4 -G describe $change | marshal_dump desc | sed \$d >pmsg && |
| 337 | test_cmp msg pmsg |
| 338 | ) |
| 339 | ' |
| 340 | |
| 341 | make_job() { |
| 342 | name="$1" && |
| 343 | tab="$(printf \\t)" && |
| 344 | p4 job -o | \ |
| 345 | sed -e "/^Job:/s/.*/Job: $name/" \ |
| 346 | -e "/^Description/{ n; s/.*/$tab job text/; }" | \ |
| 347 | p4 job -i |
| 348 | } |
| 349 | |
| 350 | test_expect_success 'description with Jobs section at end' ' |
| 351 | test_when_finished cleanup_git && |
| 352 | git p4 clone --dest="$git" //depot && |
| 353 | ( |
| 354 | cd "$git" && |
| 355 | echo desc4 >desc4 && |
| 356 | git add desc4 && |
| 357 | echo 6060842 >jobname && |
| 358 | ( |
| 359 | printf "subject line\n\n\tExtra tab\nline.\n\n" && |
| 360 | printf "Files:\n\tBogus files marker\n" && |
| 361 | printf "Junk: 3164175\n" && |
| 362 | printf "Jobs: $(cat jobname)\n" |
| 363 | ) >msg && |
| 364 | git commit -F - <msg && |
| 365 | git config git-p4.skipSubmitEdit true && |
| 366 | # build a job |
| 367 | make_job $(cat jobname) && |
| 368 | git p4 submit && |
| 369 | change=$(p4 -G changes -m 1 //depot/... | \ |
| 370 | marshal_dump change) && |
| 371 | # marshal_dump always adds a newline |
| 372 | p4 -G describe $change | marshal_dump desc | sed \$d >pmsg && |
| 373 | # make sure Jobs line and all following is gone |
| 374 | sed "/^Jobs:/,\$d" msg >jmsg && |
| 375 | test_cmp jmsg pmsg && |
| 376 | # make sure p4 knows about job |
| 377 | p4 -G describe $change | marshal_dump job0 >job0 && |
| 378 | test_cmp jobname job0 |
| 379 | ) |
| 380 | ' |
| 381 | |
| 382 | test_expect_success 'description with Jobs and values on separate lines' ' |
| 383 | test_when_finished cleanup_git && |
| 384 | git p4 clone --dest="$git" //depot && |
| 385 | ( |
| 386 | cd "$git" && |
| 387 | echo desc5 >desc5 && |
| 388 | git add desc5 && |
| 389 | echo PROJ-6060842 >jobname1 && |
| 390 | echo PROJ-6060847 >jobname2 && |
| 391 | ( |
| 392 | printf "subject line\n\n\tExtra tab\nline.\n\n" && |
| 393 | printf "Files:\n\tBogus files marker\n" && |
| 394 | printf "Junk: 3164175\n" && |
| 395 | printf "Jobs:\n" && |
| 396 | printf "\t$(cat jobname1)\n" && |
| 397 | printf "\t$(cat jobname2)\n" |
| 398 | ) >msg && |
| 399 | git commit -F - <msg && |
| 400 | git config git-p4.skipSubmitEdit true && |
| 401 | # build two jobs |
| 402 | make_job $(cat jobname1) && |
| 403 | make_job $(cat jobname2) && |
| 404 | git p4 submit && |
| 405 | change=$(p4 -G changes -m 1 //depot/... | \ |
| 406 | marshal_dump change) && |
| 407 | # marshal_dump always adds a newline |
| 408 | p4 -G describe $change | marshal_dump desc | sed \$d >pmsg && |
| 409 | # make sure Jobs line and all following is gone |
| 410 | sed "/^Jobs:/,\$d" msg >jmsg && |
| 411 | test_cmp jmsg pmsg && |
| 412 | # make sure p4 knows about the two jobs |
| 413 | p4 -G describe $change >change && |
| 414 | ( |
| 415 | marshal_dump job0 <change && |
| 416 | marshal_dump job1 <change |
| 417 | ) | sort >jobs && |
| 418 | cat jobname1 jobname2 | sort >expected && |
| 419 | test_cmp expected jobs |
| 420 | ) |
| 421 | ' |
| 422 | |
| 423 | test_expect_success 'description with Jobs section and bogus following text' ' |
| 424 | test_when_finished cleanup_git && |
| 425 | git p4 clone --dest="$git" //depot && |
| 426 | ( |
| 427 | cd "$git" && |
| 428 | echo desc6 >desc6 && |
| 429 | git add desc6 && |
| 430 | echo 6060843 >jobname && |
| 431 | ( |
| 432 | printf "subject line\n\n\tExtra tab\nline.\n\n" && |
| 433 | printf "Files:\n\tBogus files marker\n" && |
| 434 | printf "Junk: 3164175\n" && |
| 435 | printf "Jobs: $(cat jobname)\n" && |
| 436 | printf "MoreJunk: 3711\n" |
| 437 | ) >msg && |
| 438 | git commit -F - <msg && |
| 439 | git config git-p4.skipSubmitEdit true && |
| 440 | # build a job |
| 441 | make_job $(cat jobname) && |
| 442 | test_must_fail git p4 submit 2>err && |
| 443 | test_i18ngrep "Unknown field name" err |
Pete Wyckoff | 728b7ad | 2012-09-09 16:16:12 -0400 | [diff] [blame] | 444 | ) && |
| 445 | ( |
| 446 | cd "$cli" && |
| 447 | p4 revert desc6 && |
GIRARD Etienne | b7638fe | 2015-11-24 07:43:59 +0000 | [diff] [blame] | 448 | rm -f desc6 |
Pete Wyckoff | 728b7ad | 2012-09-09 16:16:12 -0400 | [diff] [blame] | 449 | ) |
| 450 | ' |
| 451 | |
| 452 | test_expect_success 'submit --prepare-p4-only' ' |
| 453 | test_when_finished cleanup_git && |
| 454 | git p4 clone --dest="$git" //depot && |
| 455 | ( |
| 456 | cd "$git" && |
| 457 | echo prep-only-add >prep-only-add && |
| 458 | git add prep-only-add && |
| 459 | git commit -m "prep only add" && |
| 460 | git p4 submit --prepare-p4-only >out && |
| 461 | test_i18ngrep "prepared for submission" out && |
Maxime Coste | b4073bb | 2014-05-24 18:40:35 +0100 | [diff] [blame] | 462 | test_i18ngrep "must be deleted" out && |
Johannes Sixt | 41ca19b | 2014-08-13 21:30:11 +0200 | [diff] [blame] | 463 | test_i18ngrep ! "everything below this line is just the diff" out |
Pete Wyckoff | 728b7ad | 2012-09-09 16:16:12 -0400 | [diff] [blame] | 464 | ) && |
| 465 | ( |
| 466 | cd "$cli" && |
| 467 | test_path_is_file prep-only-add && |
| 468 | p4 fstat -T action prep-only-add | grep -w add |
Pete Wyckoff | f19cb0a | 2012-07-04 09:34:20 -0400 | [diff] [blame] | 469 | ) |
| 470 | ' |
| 471 | |
Vinicius Kursancew | b34fa57 | 2016-11-28 09:33:18 +0000 | [diff] [blame] | 472 | test_expect_success 'submit --shelve' ' |
| 473 | test_when_finished cleanup_git && |
| 474 | git p4 clone --dest="$git" //depot && |
| 475 | ( |
| 476 | cd "$cli" && |
| 477 | p4 revert ... && |
| 478 | cd "$git" && |
| 479 | git config git-p4.skipSubmitEdit true && |
| 480 | test_commit "shelveme1" && |
| 481 | git p4 submit --origin=HEAD^ && |
| 482 | |
| 483 | echo 654321 >shelveme2.t && |
| 484 | echo 123456 >>shelveme1.t && |
| 485 | git add shelveme* && |
| 486 | git commit -m"shelvetest" && |
| 487 | git p4 submit --shelve --origin=HEAD^ && |
| 488 | |
| 489 | test_path_is_file shelveme1.t && |
| 490 | test_path_is_file shelveme2.t |
| 491 | ) && |
| 492 | ( |
| 493 | cd "$cli" && |
| 494 | change=$(p4 -G changes -s shelved -m 1 //depot/... | \ |
| 495 | marshal_dump change) && |
| 496 | p4 describe -S $change | grep shelveme2 && |
| 497 | p4 describe -S $change | grep 123456 && |
| 498 | test_path_is_file shelveme1.t && |
| 499 | test_path_is_missing shelveme2.t |
| 500 | ) |
| 501 | ' |
| 502 | |
Luke Diamand | 7a10bb3 | 2019-01-18 09:36:55 +0000 | [diff] [blame] | 503 | last_shelve () { |
| 504 | p4 -G changes -s shelved -m 1 //depot/... | marshal_dump change |
| 505 | } |
| 506 | |
Luke Diamand | 8cf422d | 2017-12-21 11:06:14 +0000 | [diff] [blame] | 507 | make_shelved_cl() { |
| 508 | test_commit "$1" >/dev/null && |
| 509 | git p4 submit --origin HEAD^ --shelve >/dev/null && |
| 510 | p4 -G changes -s shelved -m 1 | marshal_dump change |
| 511 | } |
| 512 | |
| 513 | # Update existing shelved changelists |
Luke Diamand | 46c609e | 2016-12-02 22:43:19 +0000 | [diff] [blame] | 514 | |
| 515 | test_expect_success 'submit --update-shelve' ' |
| 516 | test_when_finished cleanup_git && |
| 517 | git p4 clone --dest="$git" //depot && |
| 518 | ( |
| 519 | cd "$cli" && |
| 520 | p4 revert ... && |
| 521 | cd "$git" && |
| 522 | git config git-p4.skipSubmitEdit true && |
Luke Diamand | 8cf422d | 2017-12-21 11:06:14 +0000 | [diff] [blame] | 523 | shelved_cl0=$(make_shelved_cl "shelved-change-0") && |
| 524 | echo shelved_cl0=$shelved_cl0 && |
| 525 | shelved_cl1=$(make_shelved_cl "shelved-change-1") && |
Luke Diamand | 46c609e | 2016-12-02 22:43:19 +0000 | [diff] [blame] | 526 | |
Luke Diamand | 8cf422d | 2017-12-21 11:06:14 +0000 | [diff] [blame] | 527 | echo "updating shelved change lists $shelved_cl0 and $shelved_cl1" && |
Luke Diamand | 46c609e | 2016-12-02 22:43:19 +0000 | [diff] [blame] | 528 | |
| 529 | echo "updated-line" >>shelf.t && |
| 530 | echo added-file.t >added-file.t && |
| 531 | git add shelf.t added-file.t && |
Luke Diamand | 8cf422d | 2017-12-21 11:06:14 +0000 | [diff] [blame] | 532 | git rm -f shelved-change-1.t && |
Luke Diamand | 46c609e | 2016-12-02 22:43:19 +0000 | [diff] [blame] | 533 | git commit --amend -C HEAD && |
| 534 | git show --stat HEAD && |
Luke Diamand | 8cf422d | 2017-12-21 11:06:14 +0000 | [diff] [blame] | 535 | git p4 submit -v --origin HEAD~2 --update-shelve $shelved_cl0 --update-shelve $shelved_cl1 && |
Luke Diamand | 46c609e | 2016-12-02 22:43:19 +0000 | [diff] [blame] | 536 | echo "done git p4 submit" |
| 537 | ) && |
| 538 | ( |
| 539 | cd "$cli" && |
Luke Diamand | 7a10bb3 | 2019-01-18 09:36:55 +0000 | [diff] [blame] | 540 | change=$(last_shelve) && |
Luke Diamand | 46c609e | 2016-12-02 22:43:19 +0000 | [diff] [blame] | 541 | p4 unshelve -c $change -s $change && |
| 542 | grep -q updated-line shelf.t && |
| 543 | p4 describe -S $change | grep added-file.t && |
Luke Diamand | 7a10bb3 | 2019-01-18 09:36:55 +0000 | [diff] [blame] | 544 | test_path_is_missing shelved-change-1.t && |
| 545 | p4 revert ... |
| 546 | ) |
| 547 | ' |
| 548 | |
Luke Diamand | 7a10946 | 2019-01-18 09:36:56 +0000 | [diff] [blame] | 549 | test_expect_success 'update a shelve involving moved and copied files' ' |
Luke Diamand | 7a10bb3 | 2019-01-18 09:36:55 +0000 | [diff] [blame] | 550 | test_when_finished cleanup_git && |
| 551 | ( |
| 552 | cd "$cli" && |
| 553 | : >file_to_move && |
| 554 | p4 add file_to_move && |
| 555 | p4 submit -d "change1" && |
| 556 | p4 edit file_to_move && |
| 557 | echo change >>file_to_move && |
| 558 | p4 submit -d "change2" && |
| 559 | p4 opened |
| 560 | ) && |
| 561 | git p4 clone --dest="$git" //depot && |
| 562 | ( |
| 563 | cd "$git" && |
| 564 | git config git-p4.detectCopies true && |
| 565 | git config git-p4.detectRenames true && |
| 566 | git config git-p4.skipSubmitEdit true && |
| 567 | mkdir moved && |
| 568 | cp file_to_move copy_of_file && |
| 569 | git add copy_of_file && |
| 570 | git mv file_to_move moved/ && |
| 571 | git commit -m "rename a file" && |
| 572 | git p4 submit -M --shelve --origin HEAD^ && |
| 573 | : >new_file && |
| 574 | git add new_file && |
| 575 | git commit --amend && |
| 576 | git show --stat HEAD && |
| 577 | change=$(last_shelve) && |
| 578 | git p4 submit -M --update-shelve $change --commit HEAD |
| 579 | ) && |
| 580 | ( |
| 581 | cd "$cli" && |
| 582 | change=$(last_shelve) && |
| 583 | echo change=$change && |
| 584 | p4 unshelve -s $change && |
| 585 | p4 submit -d "Testing update-shelve" && |
| 586 | test_path_is_file copy_of_file && |
| 587 | test_path_is_file moved/file_to_move && |
| 588 | test_path_is_missing file_to_move && |
| 589 | test_path_is_file new_file && |
| 590 | echo "unshelved and submitted change $change" && |
| 591 | p4 changes moved/file_to_move | grep "Testing update-shelve" && |
| 592 | p4 changes copy_of_file | grep "Testing update-shelve" |
Luke Diamand | 46c609e | 2016-12-02 22:43:19 +0000 | [diff] [blame] | 593 | ) |
| 594 | ' |
| 595 | |
Pete Wyckoff | c145225 | 2011-12-09 18:48:15 -0500 | [diff] [blame] | 596 | test_done |