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
@@ -1,81 +0,0 @@
1
- require 'spec_helper'
2
- require 'modulesync/pr/gitlab'
3
-
4
- describe ModuleSync::PR::GitLab do
5
- context '::manage' do
6
- before(:each) do
7
- @git_repo = 'test/modulesync'
8
- @namespace, @repo_name = @git_repo.split('/')
9
- @options = {
10
- :pr => true,
11
- :pr_title => 'Test PR is submitted',
12
- :branch => 'test',
13
- :message => 'Hello world',
14
- :pr_auto_merge => false,
15
- }
16
-
17
- @client = double()
18
- allow(Gitlab::Client).to receive(:new).and_return(@client)
19
- @it = ModuleSync::PR::GitLab.new('test', 'https://gitlab.com/api/v4')
20
- end
21
-
22
- it 'submits MR when --pr is set' do
23
- allow(@client).to receive(:merge_requests)
24
- .with(@git_repo,
25
- :state => 'opened',
26
- :source_branch => "#{@namespace}:#{@options[:branch]}",
27
- :target_branch => 'master',
28
- ).and_return([])
29
-
30
- expect(@client).to receive(:create_merge_request)
31
- .with(@git_repo,
32
- @options[:pr_title],
33
- :labels => [],
34
- :source_branch => @options[:branch],
35
- :target_branch => 'master',
36
- ).and_return({"html_url" => "http://example.com/pulls/22"})
37
-
38
- expect { @it.manage(@namespace, @repo_name, @options) }.to output(/Submitted MR/).to_stdout
39
- end
40
-
41
- it 'skips submitting MR if one has already been issued' do
42
- mr = {
43
- "title" => "Test title",
44
- "html_url" => "https://example.com/pulls/44",
45
- "iid" => "44"
46
- }
47
-
48
- expect(@client).to receive(:merge_requests)
49
- .with(@git_repo,
50
- :state => 'opened',
51
- :source_branch => "#{@namespace}:#{@options[:branch]}",
52
- :target_branch => 'master',
53
- ).and_return([mr])
54
-
55
- expect { @it.manage(@namespace, @repo_name, @options) }.to output(/Skipped! 1 MRs found for branch test/).to_stdout
56
- end
57
-
58
- it 'adds labels to MR when --pr-labels is set' do
59
- @options[:pr_labels] = "HELLO,WORLD"
60
- mr = double()
61
- allow(mr).to receive(:iid).and_return("42")
62
-
63
- expect(@client).to receive(:create_merge_request)
64
- .with(@git_repo,
65
- @options[:pr_title],
66
- :labels => ["HELLO", "WORLD"],
67
- :source_branch => @options[:branch],
68
- :target_branch => 'master',
69
- ).and_return(mr)
70
-
71
- allow(@client).to receive(:merge_requests)
72
- .with(@git_repo,
73
- :state => 'opened',
74
- :source_branch => "#{@namespace}:#{@options[:branch]}",
75
- :target_branch => 'master',
76
- ).and_return([])
77
-
78
- expect { @it.manage(@namespace, @repo_name, @options) }.to output(/Attached the following labels to MR 42: HELLO, WORLD/).to_stdout
79
- end
80
- end
81
- end