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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +18 -3
- data/.github/workflows/release.yml +2 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +14 -8
- data/.rubocop_todo.yml +25 -17
- data/.simplecov +46 -0
- data/CHANGELOG.md +32 -0
- data/Gemfile +1 -1
- data/bin/msync +17 -1
- data/features/cli.feature +12 -6
- data/features/execute.feature +51 -0
- data/features/hook.feature +5 -8
- data/features/push.feature +46 -0
- data/features/reset.feature +57 -0
- data/features/step_definitions/git_steps.rb +29 -1
- data/features/support/env.rb +9 -0
- data/features/update/bump_version.feature +8 -12
- data/features/update/dot_sync.feature +52 -0
- data/features/update/pull_request.feature +180 -0
- data/features/update.feature +74 -103
- data/lib/modulesync/cli/thor.rb +12 -0
- data/lib/modulesync/cli.rb +122 -28
- data/lib/modulesync/git_service/base.rb +63 -0
- data/lib/modulesync/git_service/factory.rb +28 -0
- data/lib/modulesync/{pr → git_service}/github.rb +23 -21
- data/lib/modulesync/git_service/gitlab.rb +62 -0
- data/lib/modulesync/git_service.rb +96 -0
- data/lib/modulesync/hook.rb +11 -13
- data/lib/modulesync/renderer.rb +3 -6
- data/lib/modulesync/repository.rb +71 -25
- data/lib/modulesync/settings.rb +0 -1
- data/lib/modulesync/source_code.rb +28 -2
- data/lib/modulesync/util.rb +4 -4
- data/lib/modulesync.rb +104 -66
- data/modulesync.gemspec +7 -4
- data/spec/helpers/faker/puppet_module_remote_repo.rb +16 -1
- data/spec/spec_helper.rb +1 -23
- data/spec/unit/modulesync/git_service/factory_spec.rb +16 -0
- data/spec/unit/modulesync/git_service/github_spec.rb +81 -0
- data/spec/unit/modulesync/git_service/gitlab_spec.rb +90 -0
- data/spec/unit/modulesync/git_service_spec.rb +201 -0
- data/spec/unit/modulesync/source_code_spec.rb +22 -0
- data/spec/unit/modulesync_spec.rb +0 -12
- metadata +74 -12
- data/lib/modulesync/pr/gitlab.rb +0 -54
- data/spec/unit/modulesync/pr/github_spec.rb +0 -49
- 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
|