forked from stacked-git/stgit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
t1307-repair-amend.sh
executable file
·73 lines (60 loc) · 1.9 KB
/
t1307-repair-amend.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
test_description='Test "stg repair" of amended commits'
. ./test-lib.sh
test_expect_success 'Initialize the StGit patch' '
echo "hello" >foo.txt &&
stg add foo.txt &&
stg new -m p0 &&
stg refresh
'
test_expect_success 'Amend patch commit with git' '
echo "amended" >>foo.txt &&
git commit -a --amend -m "p0 amended"
'
test_expect_success 'Repair amended patch' '
stg repair &&
test "$(echo $(stg series --noprefix --applied))" = "p0-amended" &&
test "$(echo $(stg series --noprefix --unapplied))" = "p0" &&
test "$(tail -n1 foo.txt)" = "amended"
'
test_expect_success 'Reset to original patch' '
stg delete p0-amended &&
stg push p0
'
test_expect_success 'Add more applied and unapplied patches' '
stg new -m p1 &&
echo "from p1" >>foo.txt &&
stg refresh &&
stg new -m p2 &&
echo "from p2" >>foo.txt &&
stg refresh &&
stg pop p2 &&
test "$(echo $(stg series --noprefix --applied))" = "p0 p1" &&
test "$(echo $(stg series --noprefix --unapplied))" = "p2"
'
test_expect_success 'Amend middle patch' '
echo "p1 amended" >>foo.txt &&
git commit -a --amend -m "p1 amended"
'
test_expect_success 'Repair amended middle patch' '
stg repair &&
test "$(echo $(stg series --noprefix --applied))" = "p0 p1-amended" &&
test "$(echo $(stg series --noprefix --unapplied))" = "p1 p2" &&
test "$(tail -n1 foo.txt)" = "p1 amended"
'
test_expect_success 'Reset to non-amended patches' '
stg delete p1-amended &&
stg pop -a
'
test_expect_success 'Add commit onto stack base' '
echo "new commit" >foo.txt &&
git add foo.txt &&
git commit -m "add foo"
'
test_expect_success 'Repair new commit on stack base' '
stg repair &&
test "$(echo $(stg series --noprefix --applied))" = "" &&
test "$(echo $(stg series --noprefix --unapplied))" = "p0 p1 p2" &&
test "$(tail -n1 foo.txt)" = "new commit"
'
test_done