| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='Run "stg refresh"' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success 'Initialize StGit stack' ' |
| 8 | stg init && |
| 9 | echo expected.txt >> .git/info/exclude && |
| 10 | echo patches.txt >> .git/info/exclude && |
| 11 | stg new p0 -m "base" && |
| 12 | for i in 1 2 3; do |
| 13 | echo base >> foo$i.txt && |
| 14 | git add foo$i.txt |
| 15 | done |
| 16 | stg refresh && |
| 17 | for i in 1 2 3; do |
| 18 | stg new p$i -m "foo $i" && |
| 19 | echo "foo $i" >> foo$i.txt && |
| 20 | stg refresh |
| 21 | done |
| 22 | ' |
| 23 | |
| 24 | cat > expected.txt <<EOF |
| 25 | p0 |
| 26 | p3 |
| 27 | EOF |
| 28 | test_expect_success 'Refresh top patch' ' |
| 29 | echo bar 3 >> foo3.txt && |
| 30 | stg refresh && |
| 31 | stg status && |
| 32 | test -z "$(stg status)" && |
| 33 | stg patches foo3.txt > patches.txt && |
| 34 | diff -u expected.txt patches.txt |
| 35 | ' |
| 36 | |
| 37 | cat > expected.txt <<EOF |
| 38 | p0 |
| 39 | p2 |
| 40 | EOF |
| 41 | test_expect_success 'Refresh middle patch' ' |
| 42 | stg status && |
| 43 | echo bar 2 >> foo2.txt && |
| 44 | stg refresh -p p2 && |
| 45 | stg status && |
| 46 | test -z "$(stg status)" && |
| 47 | stg patches foo2.txt > patches.txt && |
| 48 | diff -u expected.txt patches.txt |
| 49 | ' |
| 50 | |
| 51 | cat > expected.txt <<EOF |
| 52 | p0 |
| 53 | p1 |
| 54 | EOF |
| 55 | test_expect_success 'Refresh bottom patch' ' |
| 56 | stg status && |
| 57 | echo bar 1 >> foo1.txt && |
| 58 | stg refresh -p p1 && |
| 59 | stg status && |
| 60 | test -z "$(stg status)" && |
| 61 | stg patches foo1.txt > patches.txt && |
| 62 | diff -u expected.txt patches.txt |
| 63 | ' |
| 64 | |
| 65 | test_done |