@@ -43,7 +43,7 @@ class CliMainTest < CliTestCase
43
43
44
44
test "deploy" do
45
45
with_test_secrets ( "secrets" => "DB_PASSWORD=secret" ) do
46
- invoke_options = { "config_file" => "test/fixtures/deploy_simple.yml" , "version" => "999" , "skip_hooks" => false , "verbose" => true }
46
+ invoke_options = { "config_file" => "test/fixtures/deploy_simple.yml" , "version" => "999" , "skip_hooks" => false , "skip_uncommitted_changes_check" => false , " verbose" => true }
47
47
48
48
Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:registry:login" , [ ] , invoke_options . merge ( skip_local : false ) )
49
49
Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:build:deliver" , [ ] , invoke_options )
@@ -68,7 +68,7 @@ class CliMainTest < CliTestCase
68
68
end
69
69
70
70
test "deploy with skip_push" do
71
- invoke_options = { "config_file" => "test/fixtures/deploy_simple.yml" , "version" => "999" , "skip_hooks" => false }
71
+ invoke_options = { "config_file" => "test/fixtures/deploy_simple.yml" , "version" => "999" , "skip_hooks" => false , "skip_uncommitted_changes_check" => false }
72
72
73
73
Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:registry:login" , [ ] , invoke_options . merge ( skip_local : true ) )
74
74
Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:build:pull" , [ ] , invoke_options )
@@ -88,6 +88,45 @@ class CliMainTest < CliTestCase
88
88
end
89
89
end
90
90
91
+ test "deploy with uncommitted git changes" do
92
+ Kamal ::Git . stubs ( :uncommitted_changes ) . returns ( "M file\n " )
93
+
94
+ with_argv ( [ "deploy" , "-c" , "test/fixtures/deploy_simple.yml" ] ) do
95
+ output = capture ( :stdout ) do
96
+ begin
97
+ Kamal ::Cli ::Main . start
98
+ rescue Kamal ::Cli ::Build ::BuildError => e
99
+ @raised_error = e
100
+ end
101
+ end
102
+ assert_match /Uncommitted changes detected - commit your changes first. To ignore uncommitted changes and deploy from latest git commit, use --skip-uncommitted-changes-check. Uncommitted changes:\n M file/ , output
103
+ end
104
+ assert_equal Kamal ::Cli ::Build ::BuildError , @raised_error . class
105
+ assert_equal "Uncommitted changes detected" , @raised_error . message
106
+ end
107
+
108
+ test "deploy with uncommitted git changes and skip_uncommitted_changes_check" do
109
+ invoke_options = { "config_file" => "test/fixtures/deploy_simple.yml" , "version" => "999" , "skip_hooks" => false , "skip_uncommitted_changes_check" => true }
110
+
111
+ Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:registry:login" , [ ] , invoke_options . merge ( skip_local : false ) )
112
+ Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:build:deliver" , [ ] , invoke_options )
113
+ Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:proxy:boot" , [ ] , invoke_options )
114
+ Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:app:stale_containers" , [ ] , invoke_options . merge ( stop : true ) )
115
+ Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:app:boot" , [ ] , invoke_options )
116
+ Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:prune:all" , [ ] , invoke_options )
117
+
118
+ Kamal ::Git . stubs ( :uncommitted_changes ) . returns ( "M file\n " )
119
+
120
+ run_command ( "deploy" , "--skip-uncommitted-changes-check" ) . tap do |output |
121
+ assert_match /Acquiring the deploy lock/ , output
122
+ assert_match /Log into image registry/ , output
123
+ assert_match /Ensure kamal-proxy is running/ , output
124
+ assert_match /Detect stale containers/ , output
125
+ assert_match /Prune old containers and images/ , output
126
+ assert_match /Releasing the deploy lock/ , output
127
+ end
128
+ end
129
+
91
130
test "deploy when locked" do
92
131
Thread . report_on_exception = false
93
132
@@ -117,6 +156,8 @@ class CliMainTest < CliTestCase
117
156
. returns ( "" )
118
157
. at_least_once
119
158
159
+ stub_no_uncommitted_git_changes
160
+
120
161
assert_raises ( Kamal ::Cli ::LockError ) do
121
162
run_command ( "deploy" )
122
163
end
@@ -148,13 +189,15 @@ class CliMainTest < CliTestCase
148
189
. returns ( "" )
149
190
. at_least_once
150
191
192
+ stub_no_uncommitted_git_changes
193
+
151
194
assert_raises ( SSHKit ::Runner ::ExecuteError ) do
152
195
run_command ( "deploy" )
153
196
end
154
197
end
155
198
156
199
test "deploy errors during outside section leave remove lock" do
157
- invoke_options = { "config_file" => "test/fixtures/deploy_simple.yml" , "version" => "999" , "skip_hooks" => false , :skip_local => false }
200
+ invoke_options = { "config_file" => "test/fixtures/deploy_simple.yml" , "version" => "999" , "skip_hooks" => false , "skip_uncommitted_changes_check" => false , :skip_local => false }
158
201
159
202
Kamal ::Cli ::Main . any_instance . expects ( :invoke )
160
203
. with ( "kamal:cli:registry:login" , [ ] , invoke_options . merge ( skip_local : false ) )
@@ -168,7 +211,7 @@ class CliMainTest < CliTestCase
168
211
end
169
212
170
213
test "deploy with skipped hooks" do
171
- invoke_options = { "config_file" => "test/fixtures/deploy_simple.yml" , "version" => "999" , "skip_hooks" => true }
214
+ invoke_options = { "config_file" => "test/fixtures/deploy_simple.yml" , "version" => "999" , "skip_hooks" => true , "skip_uncommitted_changes_check" => false }
172
215
173
216
Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:registry:login" , [ ] , invoke_options . merge ( skip_local : false ) )
174
217
Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:build:deliver" , [ ] , invoke_options )
@@ -183,7 +226,7 @@ class CliMainTest < CliTestCase
183
226
end
184
227
185
228
test "deploy with missing secrets" do
186
- invoke_options = { "config_file" => "test/fixtures/deploy_with_secrets.yml" , "version" => "999" , "skip_hooks" => false }
229
+ invoke_options = { "config_file" => "test/fixtures/deploy_with_secrets.yml" , "version" => "999" , "skip_hooks" => false , "skip_uncommitted_changes_check" => false }
187
230
188
231
Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:registry:login" , [ ] , invoke_options . merge ( skip_local : false ) )
189
232
Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:build:deliver" , [ ] , invoke_options )
0 commit comments