File: t1300-uncommit.sh

package info (click to toggle)
stgit 0.19-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,748 kB
  • sloc: python: 10,558; sh: 5,739; lisp: 2,678; makefile: 142; perl: 42
file content (141 lines) | stat: -rwxr-xr-x 2,997 bytes parent folder | download | duplicates (3)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/sh
#
# Copyright (c) 2006 Catalin Marinas
#

test_description='Test the uncommit command.

'

. ./test-lib.sh

test_expect_success \
	'Initialize the StGIT repository' \
	'stg init
'

test_expect_success \
	'Create the first patch' \
	'
	stg new foo -m "Foo Patch" &&
	echo foo > test &&
	stg add test &&
	stg refresh
	'

test_expect_success \
	'Create the second patch' \
	'
	stg new bar -m "Bar Patch" &&
	echo bar > test &&
	stg add test &&
	stg refresh
	'

test_expect_success \
	'Commit the patches' \
	'
	stg commit --all
	'

test_expect_success \
  'Invalid --to and --number arguments' \
  '
  command_error stg uncommit --to HEAD^ --number 1 2>&1 |
  grep -e "cannot give both --to and --number"
  '

test_expect_success \
  'Invalid --to with patch args' \
  '
  command_error stg uncommit --to HEAD^ p0 2>&1 |
  grep -e "cannot specify patch name with --to"
  '

test_expect_success \
  'Invalid --number' \
  '
  command_error stg uncommit --number -1 2>&1 |
  grep -e "invalid value passed to --number"
  '

test_expect_success \
  'Too many patch names with --number' \
  '
  command_error stg uncommit --number 2 p0 p1 2>&1 |
  grep -e "when using --number, specify at most one patch name"
  '

test_expect_success \
	'Uncommit the patches using names' \
	'
	stg uncommit bar foo &&
	[ "$(stg id foo)" = "$(stg id bar^)" ] &&
	stg commit --all
	'

test_expect_success \
	'Uncommit the patches using prefix' \
	'
	stg uncommit --number=2 foobar &&
	[ "$(stg id foobar1)" = "$(stg id foobar2^)" ] &&
	stg commit --all
	'

test_expect_success \
	'Uncommit the patches using auto names' \
	'
	stg uncommit --number=2 &&
	[ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] &&
	stg commit --all
	'

test_expect_success \
	'Uncommit the patches one by one' \
	'
	stg uncommit &&
	stg uncommit &&
	[ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] &&
	stg commit --all
	'

test_expect_success \
    'Uncommit the patches with --to' '
    stg uncommit --to HEAD^ &&
    [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] &&
    stg commit --all
'

test_expect_success \
  'Use --exclusive' \
  '
  stg uncommit --to HEAD^ --exclusive &&
  [ "$(echo $(stg series --applied --noprefix))" = "bar-patch" ] &&
  stg commit --all
  '

test_expect_success 'Attempt to reuse patch name' '
  stg uncommit &&
  [ "$(echo $(stg series --applied --noprefix))" = "bar-patch" ] &&
  command_error stg uncommit bar-patch 2>&1 |
  grep -e "Patch name \"bar-patch\" already taken" &&
  stg commit --all
'

test_expect_success 'Uncommit a commit with not precisely one parent' '
    command_error stg uncommit -n 5  &&
    [ "$(echo $(stg series))" = "" ]
'

# stg uncommit should work even when top != head, and should not touch
# the head.
test_expect_success 'Uncommit when top != head' '
    stg new -m foo &&
    git reset --hard HEAD^ &&
    h=$(git rev-parse HEAD)
    stg uncommit bar &&
    test "$(git rev-parse HEAD)" = "$h" &&
    test "$(echo $(stg series))" = "+ bar > foo"
'

test_done