modulesync 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +18 -3
  3. data/.github/workflows/release.yml +2 -4
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +14 -8
  6. data/.rubocop_todo.yml +25 -17
  7. data/.simplecov +46 -0
  8. data/CHANGELOG.md +32 -0
  9. data/Gemfile +1 -1
  10. data/bin/msync +17 -1
  11. data/features/cli.feature +12 -6
  12. data/features/execute.feature +51 -0
  13. data/features/hook.feature +5 -8
  14. data/features/push.feature +46 -0
  15. data/features/reset.feature +57 -0
  16. data/features/step_definitions/git_steps.rb +29 -1
  17. data/features/support/env.rb +9 -0
  18. data/features/update/bump_version.feature +8 -12
  19. data/features/update/dot_sync.feature +52 -0
  20. data/features/update/pull_request.feature +180 -0
  21. data/features/update.feature +74 -103
  22. data/lib/modulesync/cli/thor.rb +12 -0
  23. data/lib/modulesync/cli.rb +122 -28
  24. data/lib/modulesync/git_service/base.rb +63 -0
  25. data/lib/modulesync/git_service/factory.rb +28 -0
  26. data/lib/modulesync/{pr → git_service}/github.rb +23 -21
  27. data/lib/modulesync/git_service/gitlab.rb +62 -0
  28. data/lib/modulesync/git_service.rb +96 -0
  29. data/lib/modulesync/hook.rb +11 -13
  30. data/lib/modulesync/renderer.rb +3 -6
  31. data/lib/modulesync/repository.rb +71 -25
  32. data/lib/modulesync/settings.rb +0 -1
  33. data/lib/modulesync/source_code.rb +28 -2
  34. data/lib/modulesync/util.rb +4 -4
  35. data/lib/modulesync.rb +104 -66
  36. data/modulesync.gemspec +7 -4
  37. data/spec/helpers/faker/puppet_module_remote_repo.rb +16 -1
  38. data/spec/spec_helper.rb +1 -23
  39. data/spec/unit/modulesync/git_service/factory_spec.rb +16 -0
  40. data/spec/unit/modulesync/git_service/github_spec.rb +81 -0
  41. data/spec/unit/modulesync/git_service/gitlab_spec.rb +90 -0
  42. data/spec/unit/modulesync/git_service_spec.rb +201 -0
  43. data/spec/unit/modulesync/source_code_spec.rb +22 -0
  44. data/spec/unit/modulesync_spec.rb +0 -12
  45. metadata +74 -12
  46. data/lib/modulesync/pr/gitlab.rb +0 -54
  47. data/spec/unit/modulesync/pr/github_spec.rb +0 -49
  48. data/spec/unit/modulesync/pr/gitlab_spec.rb +0 -81
@@ -0,0 +1,52 @@
1
+ Feature: Update using a `.sync.yml` file
2
+ ModuleSync needs to apply templates according to `.sync.yml` content
3
+
4
+ Scenario: Updating a module with a .sync.yml file
5
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
6
+ And a file named "config_defaults.yml" with:
7
+ """
8
+ ---
9
+ :global:
10
+ variable: 'global'
11
+ template_with_specific_config:
12
+ variable: 'specific'
13
+ """
14
+ And a file named "moduleroot/template_with_specific_config.erb" with:
15
+ """
16
+ ---
17
+ <%= @configs['variable'] %>
18
+ """
19
+ And a file named "moduleroot/template_with_only_global_config.erb" with:
20
+ """
21
+ ---
22
+ <%= @configs['variable'] %>
23
+ """
24
+ And the puppet module "puppet-test" from "fakenamespace" has a branch named "target"
25
+ And the puppet module "puppet-test" from "fakenamespace" has, in branch "target", a file named ".sync.yml" with:
26
+ """
27
+ ---
28
+ :global:
29
+ variable: 'overwritten by globally defined value in .sync.yml'
30
+ template_with_specific_config:
31
+ variable: 'overwritten by file-specific defined value in .sync.yml'
32
+ """
33
+ When I successfully run `msync update --message 'Apply ModuleSync templates to target source code' --branch 'target'`
34
+ Then the file named "modules/fakenamespace/puppet-test/template_with_specific_config" should contain:
35
+ """
36
+ overwritten by file-specific defined value in .sync.yml
37
+ """
38
+ And the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba"
39
+ When the puppet module "puppet-test" from "fakenamespace" has, in branch "target", a file named ".sync.yml" with:
40
+ """
41
+ ---
42
+ :global:
43
+ variable: 'overwritten by globally defined value in .sync.yml'
44
+ template_with_specific_config:
45
+ variable: 'overwritten by newly file-specific defined value in .sync.yml'
46
+ """
47
+ And I successfully run `msync update --message 'Apply ModuleSync templates to target source code' --branch 'target'`
48
+ Then the file named "modules/fakenamespace/puppet-test/template_with_specific_config" should contain:
49
+ """
50
+ overwritten by newly file-specific defined value in .sync.yml
51
+ """
52
+ And the puppet module "puppet-test" from "fakenamespace" should have 2 commits made by "Aruba"
@@ -0,0 +1,180 @@
1
+ Feature: Create a pull-request/merge-request after update
2
+
3
+ Scenario: Run update in no-op mode and ask for GitHub PR
4
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
5
+ And a file named "managed_modules.yml" with:
6
+ """
7
+ ---
8
+ puppet-test:
9
+ github: {}
10
+ """
11
+ And I set the environment variables to:
12
+ | variable | value |
13
+ | GITHUB_TOKEN | foobar |
14
+ | GITHUB_BASE_URL | https://github.example.com |
15
+ And a file named "config_defaults.yml" with:
16
+ """
17
+ ---
18
+ test:
19
+ name: aruba
20
+ """
21
+ And a file named "moduleroot/test.erb" with:
22
+ """
23
+ <%= @configs['name'] %>
24
+ """
25
+ When I successfully run `msync update --noop --branch managed_update --pr`
26
+ Then the output should contain "Would submit PR "
27
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
28
+
29
+ Scenario: Run update in no-op mode and ask for GitLab MR
30
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
31
+ And a file named "managed_modules.yml" with:
32
+ """
33
+ ---
34
+ puppet-test:
35
+ gitlab: {
36
+ base_url: 'https://gitlab.example.com'
37
+ }
38
+ """
39
+ And I set the environment variables to:
40
+ | variable | value |
41
+ | GITLAB_TOKEN | foobar |
42
+ And a file named "config_defaults.yml" with:
43
+ """
44
+ ---
45
+ test:
46
+ name: aruba
47
+ """
48
+ And a file named "moduleroot/test.erb" with:
49
+ """
50
+ <%= @configs['name'] %>
51
+ """
52
+ When I successfully run `msync update --noop --branch managed_update --pr`
53
+ Then the output should contain "Would submit MR "
54
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
55
+
56
+ Scenario: Run update without changes in no-op mode and ask for GitLab MR
57
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
58
+ And a directory named "moduleroot"
59
+ And a file named "managed_modules.yml" with:
60
+ """
61
+ ---
62
+ puppet-test:
63
+ gitlab: {
64
+ base_url: 'https://gitlab.example.com'
65
+ }
66
+ """
67
+ And I set the environment variables to:
68
+ | variable | value |
69
+ | GITLAB_TOKEN | foobar |
70
+ When I successfully run `msync update --noop --branch managed_update --pr`
71
+ Then the output should not contain "Would submit MR "
72
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
73
+
74
+ Scenario: Ask for PR without credentials
75
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
76
+ And a file named "managed_modules.yml" with:
77
+ """
78
+ ---
79
+ puppet-test:
80
+ gitlab: {
81
+ base_url: https://gitlab.example.com
82
+ }
83
+ """
84
+ And a file named "config_defaults.yml" with:
85
+ """
86
+ ---
87
+ test:
88
+ name: aruba
89
+ """
90
+ And a file named "moduleroot/test.erb" with:
91
+ """
92
+ <%= @configs['name'] %>
93
+ """
94
+ When I run `msync update --noop --pr`
95
+ Then the stderr should contain "A token is required to use services from gitlab"
96
+ And the exit status should be 1
97
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
98
+
99
+ Scenario: Ask for PR/MR with modules from GitHub and from GitLab
100
+ Given a basic setup with a puppet module "puppet-github" from "fakenamespace"
101
+ And a basic setup with a puppet module "puppet-gitlab" from "fakenamespace"
102
+ And a file named "managed_modules.yml" with:
103
+ """
104
+ ---
105
+ puppet-github:
106
+ github:
107
+ base_url: https://github.example.com
108
+ token: 'secret'
109
+ puppet-gitlab:
110
+ gitlab:
111
+ base_url: https://gitlab.example.com
112
+ token: 'secret'
113
+ """
114
+ And a file named "config_defaults.yml" with:
115
+ """
116
+ ---
117
+ test:
118
+ name: aruba
119
+ """
120
+ And a file named "moduleroot/test.erb" with:
121
+ """
122
+ <%= @configs['name'] %>
123
+ """
124
+ When I successfully run `msync update --noop --branch managed_update --pr`
125
+ Then the output should contain "Would submit PR "
126
+ And the output should contain "Would submit MR "
127
+ And the puppet module "puppet-github" from "fakenamespace" should have no commits made by "Aruba"
128
+ And the puppet module "puppet-gitlab" from "fakenamespace" should have no commits made by "Aruba"
129
+
130
+ Scenario: Ask for PR with same source and target branch
131
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
132
+ And a file named "managed_modules.yml" with:
133
+ """
134
+ ---
135
+ puppet-test:
136
+ gitlab:
137
+ token: 'secret'
138
+ base_url: 'https://gitlab.example.com'
139
+ """
140
+ And a file named "config_defaults.yml" with:
141
+ """
142
+ ---
143
+ test:
144
+ name: aruba
145
+ """
146
+ And a file named "moduleroot/test.erb" with:
147
+ """
148
+ <%= @configs['name'] %>
149
+ """
150
+ When I run `msync update --noop --branch managed_update --pr --pr-target-branch managed_update`
151
+ Then the stderr should contain "Unable to open a pull request with the same source and target branch: 'managed_update'"
152
+ And the exit status should be 1
153
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
154
+
155
+ Scenario: Ask for PR with the default branch as source and target
156
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
157
+ And the puppet module "puppet-test" from "fakenamespace" has the default branch named "custom_default_branch"
158
+ And a file named "managed_modules.yml" with:
159
+ """
160
+ ---
161
+ puppet-test:
162
+ github:
163
+ token: 'secret'
164
+ base_url: 'https://gitlab.example.com'
165
+ """
166
+ And a file named "config_defaults.yml" with:
167
+ """
168
+ ---
169
+ test:
170
+ name: aruba
171
+ """
172
+ And a file named "moduleroot/test.erb" with:
173
+ """
174
+ <%= @configs['name'] %>
175
+ """
176
+ And a directory named "moduleroot"
177
+ When I run `msync update --noop --pr`
178
+ Then the stderr should contain "Unable to open a pull request with the same source and target branch: 'custom_default_branch'"
179
+ And the exit status should be 1
180
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
@@ -14,9 +14,8 @@ Feature: update
14
14
  """
15
15
  <%= @configs['name'] %>
16
16
  """
17
- When I run `msync update --noop`
18
- Then the exit status should be 0
19
- And the output should match:
17
+ When I successfully run `msync update --noop`
18
+ Then the output should match:
20
19
  """
21
20
  Files added:
22
21
  test
@@ -37,9 +36,8 @@ Feature: update
37
36
  """
38
37
  <%= @configs['name'] %>
39
38
  """
40
- When I run `msync update -s -m "Add test"`
41
- Then the exit status should be 0
42
- And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
39
+ When I successfully run `msync update -s -m "Add test"`
40
+ Then the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
43
41
 
44
42
  Scenario: Adding a new file to repo without write access
45
43
  Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
@@ -72,9 +70,8 @@ Feature: update
72
70
  """
73
71
  <%= @configs['name'] %>
74
72
  """
75
- When I run `msync update --noop`
76
- Then the exit status should be 0
77
- And the output should match:
73
+ When I successfully run `msync update --noop`
74
+ Then the output should match:
78
75
  """
79
76
  Warning: using './moduleroot/test' as template without '.erb' suffix
80
77
  """
@@ -99,9 +96,8 @@ Feature: update
99
96
  """
100
97
  <%= @configs['name'] %>
101
98
  """
102
- When I run `msync update --noop`
103
- Then the exit status should be 0
104
- And the output should match:
99
+ When I successfully run `msync update --noop`
100
+ Then the output should match:
105
101
  """
106
102
  Files added:
107
103
  test
@@ -125,9 +121,8 @@ Feature: update
125
121
  """
126
122
  <%= @configs['name'] %>
127
123
  """
128
- When I run `msync update --noop`
129
- Then the exit status should be 0
130
- And the output should match:
124
+ When I successfully run `msync update --noop`
125
+ Then the output should match:
131
126
  """
132
127
  Files added:
133
128
  test
@@ -151,9 +146,8 @@ Feature: update
151
146
  """
152
147
  <%= @configs['name'] %>
153
148
  """
154
- When I run `msync update --noop`
155
- Then the exit status should be 0
156
- And the output should match:
149
+ When I successfully run `msync update --noop`
150
+ Then the output should match:
157
151
  """
158
152
  Files added:
159
153
  test
@@ -195,9 +189,8 @@ Feature: update
195
189
  <%= c['name'] %>
196
190
  <% end %>
197
191
  """
198
- When I run `msync update --noop -s`
199
- Then the exit status should be 0
200
- And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
192
+ When I successfully run `msync update --noop -s`
193
+ Then the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
201
194
 
202
195
  Scenario: Using skip_broken and fail_on_warnings options with invalid files
203
196
  Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
@@ -235,9 +228,8 @@ Feature: update
235
228
  """
236
229
  source '<%= @configs['gem_source'] %>'
237
230
  """
238
- When I run `msync update --noop`
239
- Then the exit status should be 0
240
- And the output should match:
231
+ When I successfully run `msync update --noop`
232
+ Then the output should match:
241
233
  """
242
234
  Files changed:
243
235
  +diff --git a/Gemfile b/Gemfile
@@ -265,9 +257,8 @@ Feature: update
265
257
  """
266
258
  source '<%= @configs['gem_source'] %>'
267
259
  """
268
- When I run `msync update -m "Update Gemfile" -r test`
269
- Then the exit status should be 0
270
- And the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
260
+ When I successfully run `msync update -m "Update Gemfile" -r test`
261
+ Then the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
271
262
  And the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba" in branch "test"
272
263
  And the puppet module "puppet-test" from "fakenamespace" should have a branch "test" with a file named "Gemfile" which contains:
273
264
  """
@@ -292,7 +283,7 @@ Feature: update
292
283
  """
293
284
  source '<%= @configs['gem_source'] %>'
294
285
  """
295
- When I run `msync update --noop`
286
+ When I successfully run `msync update --noop`
296
287
  Then the output should not match:
297
288
  """
298
289
  Files changed:
@@ -302,7 +293,6 @@ Feature: update
302
293
  """
303
294
  Not managing 'Gemfile' in 'puppet-test'
304
295
  """
305
- And the exit status should be 0
306
296
  And the file named "modules/fakenamespace/puppet-test/Gemfile" should contain:
307
297
  """
308
298
  source 'https://rubygems.org'
@@ -326,14 +316,13 @@ Feature: update
326
316
  """
327
317
  source 'https://rubygems.org'
328
318
  """
329
- When I run `msync update --noop`
319
+ When I successfully run `msync update --noop`
330
320
  Then the output should match:
331
321
  """
332
322
  Files changed:
333
323
  diff --git a/Gemfile b/Gemfile
334
324
  deleted file mode 100644
335
325
  """
336
- And the exit status should be 0
337
326
  And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
338
327
 
339
328
  Scenario: Setting a non-existent file to deleted
@@ -345,12 +334,12 @@ Feature: update
345
334
  delete: true
346
335
  """
347
336
  And a directory named "moduleroot"
348
- When I run `msync update -m 'deletes a file that doesnt exist!' -f puppet-test`
349
- And the exit status should be 0
350
- And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
337
+ When I successfully run `msync update -m 'deletes a file that doesnt exist!' -f puppet-test`
338
+ Then the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
351
339
 
352
340
  Scenario: Setting a directory to unmanaged
353
341
  Given a basic setup with a puppet module "puppet-apache" from "puppetlabs"
342
+ And I successfully run `msync clone`
354
343
  And a file named "config_defaults.yml" with:
355
344
  """
356
345
  ---
@@ -367,17 +356,15 @@ Feature: update
367
356
  """
368
357
  This is a fake spec_helper!
369
358
  """
370
- When I run `msync update --offline`
359
+ When I successfully run `msync update --offline`
371
360
  Then the output should contain:
372
361
  """
373
362
  Not managing 'spec/spec_helper.rb' in 'puppet-apache'
374
363
  """
375
- And the exit status should be 0
376
364
  And the file named "modules/puppetlabs/puppet-apache/spec/spec_helper.rb" should contain:
377
365
  """
378
366
  This is a fake spec_helper!
379
367
  """
380
- And the exit status should be 0
381
368
  And the puppet module "puppet-apache" from "puppetlabs" should have no commits made by "Aruba"
382
369
 
383
370
  Scenario: Adding a new file in a new subdirectory
@@ -395,9 +382,8 @@ Feature: update
395
382
  require '<%= required %>'
396
383
  <% end %>
397
384
  """
398
- When I run `msync update --noop`
399
- Then the exit status should be 0
400
- And the output should match:
385
+ When I successfully run `msync update --noop`
386
+ Then the output should match:
401
387
  """
402
388
  Files added:
403
389
  spec/spec_helper.rb
@@ -410,6 +396,7 @@ Feature: update
410
396
 
411
397
  Scenario: Updating offline
412
398
  Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
399
+ And I successfully run `msync clone`
413
400
  And a file named "config_defaults.yml" with:
414
401
  """
415
402
  ---
@@ -423,17 +410,15 @@ Feature: update
423
410
  require '<%= required %>'
424
411
  <% end %>
425
412
  """
426
- When I run `msync update --offline`
427
- Then the exit status should be 0
428
- And the output should not match /Files (changed|added|deleted):/
413
+ When I successfully run `msync update --offline`
414
+ Then the output should not match /Files (changed|added|deleted):/
429
415
  And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
430
416
 
431
417
  Scenario: Pulling a module that already exists in the modules directory
432
418
  Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
433
419
  And a directory named "moduleroot"
434
- When I run `msync update --message "First update run"`
435
- Then the exit status should be 0
436
- And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
420
+ When I successfully run `msync update --message "First update run"`
421
+ Then the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
437
422
  Given a file named "config_defaults.yml" with:
438
423
  """
439
424
  ---
@@ -447,9 +432,8 @@ Feature: update
447
432
  require '<%= required %>'
448
433
  <% end %>
449
434
  """
450
- When I run `msync update --noop`
451
- Then the exit status should be 0
452
- And the output should match:
435
+ When I successfully run `msync update --noop`
436
+ Then the output should match:
453
437
  """
454
438
  Files added:
455
439
  spec/spec_helper.rb
@@ -459,9 +443,8 @@ Feature: update
459
443
  Scenario: When running update without changes
460
444
  Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
461
445
  And a directory named "moduleroot"
462
- When I run `msync update --message "Running without changes"`
463
- Then the exit status should be 0
464
- And the stdout should contain "There were no changes in 'modules/fakenamespace/puppet-test'. Not committing."
446
+ When I successfully run `msync update --verbose --message "Running without changes"`
447
+ Then the stdout should contain "There were no changes in 'modules/fakenamespace/puppet-test'. Not committing."
465
448
  And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
466
449
 
467
450
  Scenario: When specifying configurations in managed_modules.yml
@@ -483,9 +466,8 @@ Feature: update
483
466
  """
484
467
  <%= @configs['name'] %>
485
468
  """
486
- When I run `msync update --noop`
487
- Then the exit status should be 0
488
- And the output should match:
469
+ When I successfully run `msync update --noop`
470
+ Then the output should match:
489
471
  """
490
472
  Files added:
491
473
  test
@@ -521,9 +503,8 @@ Feature: update
521
503
  """
522
504
  <%= @configs['name'] %>
523
505
  """
524
- When I run `msync update --noop -f puppet-test`
525
- Then the exit status should be 0
526
- And the output should match:
506
+ When I successfully run `msync update --noop -f puppet-test`
507
+ Then the output should match:
527
508
  """
528
509
  Files added:
529
510
  test
@@ -560,9 +541,8 @@ Feature: update
560
541
  """
561
542
  <%= @configs['name'] %>
562
543
  """
563
- When I run `msync update --noop -x puppet-blacksmith`
564
- Then the exit status should be 0
565
- And the output should match:
544
+ When I successfully run `msync update --noop -x puppet-blacksmith`
545
+ Then the output should match:
566
546
  """
567
547
  Files added:
568
548
  test
@@ -604,9 +584,8 @@ Feature: update
604
584
  spec/spec_helper.rb:
605
585
  unmanaged: true
606
586
  """
607
- When I run `msync update --noop`
608
- Then the exit status should be 0
609
- And the output should match:
587
+ When I successfully run `msync update --noop`
588
+ Then the output should match:
610
589
  """
611
590
  Not managing 'spec/spec_helper.rb' in 'puppet-test'
612
591
  """
@@ -645,9 +624,8 @@ Feature: update
645
624
  """
646
625
  <%= @configs['name'] %>
647
626
  """
648
- When I run `msync update --noop`
649
- Then the exit status should be 0
650
- And the output should match:
627
+ When I successfully run `msync update --noop`
628
+ Then the output should match:
651
629
  """
652
630
  Files added:
653
631
  test
@@ -674,9 +652,8 @@ Feature: update
674
652
  """
675
653
  Hello world!
676
654
  """
677
- When I run `msync update --noop`
678
- Then the exit status should be 0
679
- And the output should match:
655
+ When I successfully run `msync update --noop`
656
+ Then the output should match:
680
657
  """
681
658
  Files changed:
682
659
  +diff --git a/README.md b/README.md
@@ -701,40 +678,16 @@ Feature: update
701
678
  """
702
679
  source '<%= @configs['gem_source'] %>'
703
680
  """
704
- When I run `msync update -m "Update Gemfile" -r test`
705
- Then the exit status should be 0
706
- And the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
681
+ When I successfully run `msync update -m "Update Gemfile" -r test`
682
+ Then the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
707
683
  And the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba" in branch "test"
708
684
  Given I remove the directory "modules"
709
- When I run `msync update -m "Update Gemfile" -r test`
710
- Then the exit status should be 0
685
+ When I successfully run `msync update -m "Update Gemfile" -r test`
711
686
  Then the output should not contain "error"
712
687
  Then the output should not contain "rejected"
713
688
  And the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
714
689
  And the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba" in branch "test"
715
690
 
716
- Scenario: Creating a GitHub PR with an update
717
- Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
718
- And a directory named "moduleroot"
719
- And I set the environment variables to:
720
- | variable | value |
721
- | GITHUB_TOKEN | foobar |
722
- When I run `msync update --noop --branch managed_update --pr`
723
- Then the output should contain "Would submit PR "
724
- And the exit status should be 0
725
- And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
726
-
727
- Scenario: Creating a GitLab MR with an update
728
- Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
729
- And a directory named "moduleroot"
730
- And I set the environment variables to:
731
- | variable | value |
732
- | GITLAB_TOKEN | foobar |
733
- When I run `msync update --noop --branch managed_update --pr`
734
- Then the output should contain "Would submit MR "
735
- And the exit status should be 0
736
- And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
737
-
738
691
  Scenario: Repository with a default branch other than master
739
692
  Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
740
693
  And the puppet module "puppet-test" from "fakenamespace" has the default branch named "develop"
@@ -749,9 +702,8 @@ Feature: update
749
702
  """
750
703
  source '<%= @configs['gem_source'] %>'
751
704
  """
752
- When I run `msync update -m "Update Gemfile"`
753
- Then the exit status should be 0
754
- And the output should contain "Using repository's default branch: develop"
705
+ When I successfully run `msync update --verbose -m "Update Gemfile"`
706
+ Then the output should contain "Using repository's default branch: develop"
755
707
  And the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
756
708
  And the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba" in branch "develop"
757
709
 
@@ -768,12 +720,31 @@ Feature: update
768
720
  target: <%= @metadata[:target_file] %>
769
721
  workdir: <%= @metadata[:workdir] %>
770
722
  """
771
- When I run `msync update --noop`
772
- Then the exit status should be 0
773
- And the file named "modules/fakenamespace/puppet-test/test" should contain:
723
+ When I successfully run `msync update --noop`
724
+ Then the file named "modules/fakenamespace/puppet-test/test" should contain:
774
725
  """
775
726
  module: puppet-test
776
727
  target: modules/fakenamespace/puppet-test/test
777
728
  workdir: modules/fakenamespace/puppet-test
778
729
  """
779
730
  And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
731
+
732
+ # This reproduces the issue: https://github.com/voxpupuli/modulesync/issues/81
733
+ Scenario: Resync repositories after upstream branch deletion
734
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
735
+ And a file named "config_defaults.yml" with:
736
+ """
737
+ ---
738
+ test:
739
+ name: aruba
740
+ """
741
+ And a directory named "moduleroot"
742
+ And a file named "moduleroot/test.erb" with:
743
+ """
744
+ <%= @configs['name'] %>
745
+ """
746
+ When I successfully run `msync update -m "No changes!" --branch delete-me`
747
+ Then the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba" in branch "delete-me"
748
+ When the branch "delete-me" of the puppet module "puppet-test" from "fakenamespace" is deleted
749
+ And I successfully run `msync update -m "No changes!" --branch delete-me`
750
+ Then the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
@@ -8,7 +8,19 @@ module ModuleSync
8
8
  # This class extends ::Thor class to
9
9
  # - exit with status code sets to `1` on Thor failure (e.g. missing required option)
10
10
  # - exit with status code sets to `1` when user calls `msync` (or a subcommand) without required arguments
11
+ # - show subcommands help using `msync subcommand --help`
11
12
  class Thor < ::Thor
13
+ def self.start(*args)
14
+ if (Thor::HELP_MAPPINGS & ARGV).any? && subcommands.none? { |command| command.start_with?(ARGV[0]) }
15
+ Thor::HELP_MAPPINGS.each do |cmd|
16
+ if (match = ARGV.delete(cmd))
17
+ ARGV.unshift match
18
+ end
19
+ end
20
+ end
21
+ super
22
+ end
23
+
12
24
  desc '_invalid_command_call', 'Invalid command', hide: true
13
25
  def _invalid_command_call
14
26
  self.class.new.help