|
| 1 | +#!/bin/sh |
| 2 | +# |
| 3 | +test_description="Test 'stg email format'" |
| 4 | + |
| 5 | +. ./test-lib.sh |
| 6 | + |
| 7 | +test_expect_success 'Setup StGit stack' ' |
| 8 | + test_commit_bulk --message="p%s" 7 && |
| 9 | + stg init && |
| 10 | + stg uncommit -n 7 && |
| 11 | + stg goto p4 |
| 12 | +' |
| 13 | + |
| 14 | +test_expect_success 'Format all applied patches' ' |
| 15 | + stg email format -o out --all && |
| 16 | + test_path_exists out/0001-p1.patch && |
| 17 | + test_path_exists out/0002-p2.patch && |
| 18 | + test_path_exists out/0003-p3.patch && |
| 19 | + test_path_exists out/0004-p4.patch && |
| 20 | + rm out/0001-p1.patch && |
| 21 | + rm out/0002-p2.patch && |
| 22 | + rm out/0003-p3.patch && |
| 23 | + rm out/0004-p4.patch && |
| 24 | + test_dir_is_empty out && |
| 25 | + rmdir out |
| 26 | +' |
| 27 | + |
| 28 | +test_expect_success 'Format custom patch range' ' |
| 29 | + stg email format -o out p3..p5 && |
| 30 | + test_path_exists out/0001-p3.patch && |
| 31 | + test_path_exists out/0002-p4.patch && |
| 32 | + test_path_exists out/0003-p5.patch && |
| 33 | + rm out/0001-p3.patch && |
| 34 | + rm out/0002-p4.patch && |
| 35 | + rm out/0003-p5.patch && |
| 36 | + test_dir_is_empty out && |
| 37 | + rmdir out |
| 38 | +' |
| 39 | + |
| 40 | +test_expect_success 'Format single patch' ' |
| 41 | + stg email format -o out p7 && |
| 42 | + test_path_exists out/0001-p7.patch && |
| 43 | + rm out/0001-p7.patch && |
| 44 | + test_dir_is_empty out && |
| 45 | + rmdir out |
| 46 | +' |
| 47 | + |
| 48 | +test_expect_success 'Setup another branch' ' |
| 49 | + stg branch --create other && |
| 50 | + test_commit_bulk --filename=other%s.txt --message="other%s" 5 && |
| 51 | + stg uncommit -n 5 && |
| 52 | + stg goto other3 && |
| 53 | + stg branch master |
| 54 | +' |
| 55 | + |
| 56 | +test_expect_success 'Format patches from other branch' ' |
| 57 | + stg email format -o out --branch other --all && |
| 58 | + test_path_exists out/0001-other1.patch && |
| 59 | + test_path_exists out/0002-other2.patch && |
| 60 | + test_path_exists out/0003-other3.patch && |
| 61 | + rm out/0001-other1.patch && |
| 62 | + rm out/0002-other2.patch && |
| 63 | + rm out/0003-other3.patch && |
| 64 | + test_dir_is_empty out && |
| 65 | + rmdir out |
| 66 | +' |
| 67 | + |
| 68 | +test_expect_success 'With cover letter' ' |
| 69 | + stg email format -o out --all --cover-letter && |
| 70 | + test_path_exists out/0000-cover-letter.patch && |
| 71 | + test_path_exists out/0001-p1.patch && |
| 72 | + test_path_exists out/0002-p2.patch && |
| 73 | + test_path_exists out/0003-p3.patch && |
| 74 | + test_path_exists out/0004-p4.patch && |
| 75 | + rm out/0000-cover-letter.patch && |
| 76 | + rm out/0001-p1.patch && |
| 77 | + rm out/0002-p2.patch && |
| 78 | + rm out/0003-p3.patch && |
| 79 | + rm out/0004-p4.patch && |
| 80 | + test_dir_is_empty out && |
| 81 | + rmdir out |
| 82 | +' |
| 83 | + |
| 84 | +test_done |
0 commit comments