modulesync 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 139a0b0b011d17ff31b014560eb02ce6a57e62f2e45ffaa06c9acf778240b047
4
- data.tar.gz: f1696a42bcf9cf44719ea8f7c5f5580481672e9c3dd920463f77f2f72d54a82a
3
+ metadata.gz: 2442835e7b5da17cc633790e9e4a2a3fe38c0a1b4d3fbd75ee8f60b6948ddc75
4
+ data.tar.gz: 0f0c8f284f95824e469759582db8188b37c8c8d7247f463dc9877e973887fcac
5
5
  SHA512:
6
- metadata.gz: 22bf21a62e3c6e3c8df65bed7b1356af3dc656ba85ae885338b0f35b501c1217c5159918d2c21fcbe3c92c52d14ab2f561b876004eabec99ecaa81521c875c88
7
- data.tar.gz: 751fdcd7d6ee62611f90659e21eb94a103ac6473c98b6907342441675232e1c946dc69ed925dff5e1f708dd4e5f8dca68e039b38600d7c73c9f919dc837a9aee
6
+ metadata.gz: 521392847ed7f191f9ef9bb6a0c26d80fb7c557b882f092bec29834311af6c10a2e0bd5db2d1be162996fbfbcccfd5f9ac1063268b6480aa95c867802e9b48b3
7
+ data.tar.gz: b3ddc00ba28e2d5043cb0e24d3448c35ca84f3d42a4263de4efa8513f7c38d02ca2324289a2b15d2a5c84435a3329de76acccfae8da2da6f1df31d60553cdc77
data/.gitignore CHANGED
@@ -1,5 +1,10 @@
1
- tmp/
2
- modules/
3
1
  *.gem
4
- Gemfile.lock
5
2
  .bundle/
3
+ .ruby-version
4
+ .vscode/
5
+ Gemfile.lock
6
+ bin/bundle
7
+ bin/rspec
8
+ modules/
9
+ tmp/
10
+ vendor/
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2020-07-03 - 1.2.0
4
+
5
+ Add support for GitLab merge requests (MRs) [#175](https://github.com/voxpupuli/modulesync/pull/175)
6
+
3
7
  ## 2020-05-01 - 1.1.0
4
8
 
5
9
  This release provides metadata in the ERB template scope which makes it easy to read files from inside the module. A possible application is reading metadata.json and generating CI configs based on that.
data/README.md CHANGED
@@ -176,27 +176,29 @@ touching the modules, you can deactivate the hook.
176
176
  msync hook deactivate
177
177
  ```
178
178
 
179
- #### Submitting PRs to GitHub
179
+ #### Submitting PRs/MRs to GitHub or GitLab
180
180
 
181
- You can have modulesync submit Pull Requests on GitHub automatically with the
182
- `--pr` CLI option.
181
+ You can have modulesync submit Pull Requests on GitHub or Merge Requests on
182
+ GitLab automatically with the `--pr` CLI option.
183
183
 
184
184
  ```
185
185
  msync update --pr
186
186
  ```
187
187
 
188
- You must set `GITHUB_TOKEN` in your environment for this to work. Other options
189
- include:
188
+ You must set the `GITHUB_TOKEN` or `GITLAB_TOKEN` environment variable
189
+ for GitHub PRs or GitLab MRs to work. Additional options:
190
190
 
191
- * Set the PR title with `--pr-title` or in `modulesync.yml` with the `pr_title`
192
- attribute.
193
- * Assign labels to the PR with `--pr-labels` or in `modulesync.yml` with the
194
- `pr_labels` attribute. **NOTE:** `pr_labels` should be a list. When using
195
- the `--pr-labels` CLI option, you should use a comma separated list.
191
+ * Set the PR/MR title with `--pr-title` or in `modulesync.yml` with the
192
+ `pr_title` attribute.
193
+ * Assign labels to the PR/MR with `--pr-labels` or in `modulesync.yml` with
194
+ the `pr_labels` attribute. **NOTE:** `pr_labels` should be a list. When
195
+ using the `--pr-labels` CLI option, you should use a comma separated list.
196
196
 
197
- You can optionally set the `GITHUB_BASE_URL` environment variable to use GitHub
198
- Enterprise. This is passed to Octokit's [`api_endpoint`](https://github.com/octokit/octokit.rb#interacting-with-the-githubcom-apis-in-github-enterprise)
199
- configuration option.
197
+ For GitHub Enterprise and self-hosted GitLab instances you need to set the
198
+ `GITHUB_BASE_URL` or `GITLAB_BASE_URL` environment variable in addition.
199
+ More details for GitHub:
200
+
201
+ * Octokit [`api_endpoint`](https://github.com/octokit/octokit.rb#interacting-with-the-githubcom-apis-in-github-enterprise)
200
202
 
201
203
  ### Using Forks and Non-master branches
202
204
 
@@ -258,8 +260,8 @@ Available parameters for modulesync.yml
258
260
  * `remote_branch` : Remote branch to push to (Default: Same value as branch)
259
261
  * `message` : Commit message to apply to updated modules.
260
262
  * `pre_commit_script` : A script to be run before commiting (e.g. 'contrib/myfooscript.sh')
261
- * `pr_title` : The title to use when submitting PRs to GitHub.
262
- * `pr_labels` : A list of labels to assign PRs created on GitHub.
263
+ * `pr_title` : The title to use when submitting PRs/MRs to GitHub or GitLab.
264
+ * `pr_labels` : A list of labels to assign PRs/MRs created on GitHub or GitLab.
263
265
 
264
266
  ##### Example
265
267
 
@@ -1,5 +1,4 @@
1
1
  require 'fileutils'
2
- require 'octokit'
3
2
  require 'pathname'
4
3
  require 'modulesync/cli'
5
4
  require 'modulesync/constants'
@@ -10,12 +9,6 @@ require 'modulesync/settings'
10
9
  require 'modulesync/util'
11
10
  require 'monkey_patches'
12
11
 
13
- GITHUB_TOKEN = ENV.fetch('GITHUB_TOKEN', '')
14
-
15
- Octokit.configure do |c|
16
- c.api_endpoint = ENV.fetch('GITHUB_BASE_URL', 'https://api.github.com')
17
- end
18
-
19
12
  module ModuleSync # rubocop:disable Metrics/ModuleLength
20
13
  include Constants
21
14
 
@@ -136,48 +129,22 @@ module ModuleSync # rubocop:disable Metrics/ModuleLength
136
129
  if options[:noop]
137
130
  Git.update_noop(git_repo, options)
138
131
  elsif !options[:offline]
139
- # Git.update() returns a boolean: true if files were pushed, false if not.
140
132
  pushed = Git.update(git_repo, files_to_manage, options)
141
- return nil unless pushed && options[:pr]
142
-
143
- manage_pr(namespace, module_name, options)
144
- end
145
- end
146
-
147
- def self.manage_pr(namespace, module_name, options)
148
- if options[:pr] && GITHUB_TOKEN.empty?
149
- $stderr.puts 'Environment variable GITHUB_TOKEN must be set to use --pr!'
150
- raise unless options[:skip_broken]
151
- end
152
-
153
- # We only do GitHub PR work if the GITHUB_TOKEN variable is set in the environment.
154
- repo_path = File.join(namespace, module_name)
155
- github = Octokit::Client.new(:access_token => GITHUB_TOKEN)
156
-
157
- # Skip creating the PR if it exists already.
158
- head = "#{namespace}:#{options[:branch]}"
159
- pull_requests = github.pull_requests(repo_path, :state => 'open', :base => 'master', :head => head)
160
- if pull_requests.empty?
161
- pr = github.create_pull_request(repo_path, 'master', options[:branch], options[:pr_title], options[:message])
162
- $stdout.puts "Submitted PR '#{options[:pr_title]}' to #{repo_path} - merges #{options[:branch]} into master"
163
- else
164
- $stdout.puts "Skipped! #{pull_requests.length} PRs found for branch #{options[:branch]}"
133
+ pushed && options[:pr] && @pr.manage(namespace, module_name, options)
165
134
  end
166
-
167
- # PR labels can either be a list in the YAML file or they can pass in a comma
168
- # separated list via the command line argument.
169
- pr_labels = Util.parse_list(options[:pr_labels])
170
-
171
- # We only assign labels to the PR if we've discovered a list > 1. The labels MUST
172
- # already exist. We DO NOT create missing labels.
173
- return if pr_labels.empty?
174
- $stdout.puts "Attaching the following labels to PR #{pr['number']}: #{pr_labels.join(', ')}"
175
- github.add_labels_to_an_issue(repo_path, pr['number'], pr_labels)
176
135
  end
177
136
 
178
137
  def self.update(options)
179
138
  options = config_defaults.merge(options)
180
139
  defaults = Util.parse_config(File.join(options[:configs], CONF_FILE))
140
+ if options[:pr]
141
+ unless options[:branch]
142
+ $stderr.puts 'A branch must be specified with --branch to use --pr!'
143
+ raise
144
+ end
145
+
146
+ @pr = create_pr_manager if options[:pr]
147
+ end
181
148
 
182
149
  local_template_dir = File.join(options[:configs], MODULE_FILES_DIR)
183
150
  local_files = find_template_files(local_template_dir)
@@ -201,4 +168,20 @@ module ModuleSync # rubocop:disable Metrics/ModuleLength
201
168
  end
202
169
  exit 1 if errors && options[:fail_on_warnings]
203
170
  end
171
+
172
+ def self.create_pr_manager
173
+ github_token = ENV.fetch('GITHUB_TOKEN', '')
174
+ gitlab_token = ENV.fetch('GITLAB_TOKEN', '')
175
+
176
+ if !github_token.empty?
177
+ require 'modulesync/pr/github'
178
+ ModuleSync::PR::GitHub.new(github_token, ENV.fetch('GITHUB_BASE_URL', 'https://api.github.com'))
179
+ elsif !gitlab_token.empty?
180
+ require 'modulesync/pr/github'
181
+ ModuleSync::PR::GitLab.new(gitlab_token, ENV.fetch('GITLAB_BASE_URL', 'https://gitlab.com/api/v4'))
182
+ else
183
+ $stderr.puts 'Environment variables GITHUB_TOKEN or GITLAB_TOKEN must be set to use --pr!'
184
+ raise
185
+ end
186
+ end
204
187
  end
@@ -90,14 +90,14 @@ module ModuleSync
90
90
  :default => false
91
91
  option :pr,
92
92
  :type => :boolean,
93
- :desc => 'Submit GitHub PR',
93
+ :desc => 'Submit pull/merge request',
94
94
  :default => false
95
95
  option :pr_title,
96
- :desc => 'Title of GitHub PR',
96
+ :desc => 'Title of pull/merge request',
97
97
  :default => CLI.defaults[:pr_title] || 'Update to module template files'
98
98
  option :pr_labels,
99
99
  :type => :array,
100
- :desc => 'Labels to add to the GitHub PR',
100
+ :desc => 'Labels to add to the pull/merge request',
101
101
  :default => CLI.defaults[:pr_labels] || []
102
102
  option :offline,
103
103
  :type => :boolean,
@@ -0,0 +1,41 @@
1
+ require 'octokit'
2
+ require 'modulesync/util'
3
+
4
+ module ModuleSync
5
+ module PR
6
+ # GitHub creates and manages pull requests on github.com or GitHub
7
+ # Enterprise installations.
8
+ class GitHub
9
+ def initialize(token, endpoint)
10
+ Octokit.configure do |c|
11
+ c.api_endpoint = endpoint
12
+ end
13
+ @api = Octokit::Client.new(:access_token => token)
14
+ end
15
+
16
+ def manage(namespace, module_name, options)
17
+ repo_path = File.join(namespace, module_name)
18
+ head = "#{namespace}:#{options[:branch]}"
19
+
20
+ pull_requests = @api.pull_requests(repo_path, :state => 'open', :base => 'master', :head => head)
21
+ if pull_requests.empty?
22
+ pr = @api.create_pull_request(repo_path, 'master', options[:branch], options[:pr_title], options[:message])
23
+ $stdout.puts "Submitted PR '#{options[:pr_title]}' to #{repo_path} - merges #{options[:branch]} into master"
24
+ else
25
+ # Skip creating the PR if it exists already.
26
+ $stdout.puts "Skipped! #{pull_requests.length} PRs found for branch #{options[:branch]}"
27
+ end
28
+
29
+ # PR labels can either be a list in the YAML file or they can pass in a comma
30
+ # separated list via the command line argument.
31
+ pr_labels = ModuleSync::Util.parse_list(options[:pr_labels])
32
+
33
+ # We only assign labels to the PR if we've discovered a list > 1. The labels MUST
34
+ # already exist. We DO NOT create missing labels.
35
+ return if pr_labels.empty?
36
+ $stdout.puts "Attaching the following labels to PR #{pr['number']}: #{pr_labels.join(', ')}"
37
+ @api.add_labels_to_an_issue(repo_path, pr['number'], pr_labels)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,40 @@
1
+ require 'gitlab'
2
+ require 'modulesync/util'
3
+
4
+ module ModuleSync
5
+ module PR
6
+ # GitLab creates and manages merge requests on gitlab.com or private GitLab
7
+ # installations.
8
+ class GitLab
9
+ def initialize(token, endpoint)
10
+ @api = Gitlab::Client.new(
11
+ :endpoint => endpoint,
12
+ :private_token => token
13
+ )
14
+ end
15
+
16
+ def manage(namespace, module_name, options)
17
+ repo_path = File.join(namespace, module_name)
18
+
19
+ head = "#{namespace}:#{options[:branch]}"
20
+ merge_requests = @api.merge_requests(repo_path,
21
+ :state => 'opened',
22
+ :source_branch => head,
23
+ :target_branch => 'master')
24
+ if merge_requests.empty?
25
+ mr_labels = ModuleSync::Util.parse_list(options[:pr_labels])
26
+ mr = @api.create_merge_request(repo_path, options[:pr_title],
27
+ :source_branch => options[:branch],
28
+ :target_branch => 'master',
29
+ :labels => mr_labels)
30
+ $stdout.puts "Submitted MR '#{options[:pr_title]}' to #{repo_path} - merges #{options[:branch]} into master"
31
+ return if mr_labels.empty?
32
+ $stdout.puts "Attached the following labels to MR #{mr.iid}: #{mr_labels.join(', ')}"
33
+ else
34
+ # Skip creating the MR if it exists already.
35
+ $stdout.puts "Skipped! #{merge_requests.length} MRs found for branch #{options[:branch]}"
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'modulesync'
6
- spec.version = '1.1.0'
6
+ spec.version = '1.2.0'
7
7
  spec.authors = ['Vox Pupuli']
8
8
  spec.email = ['voxpupuli@groups.io']
9
9
  spec.summary = 'Puppet Module Synchronizer'
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'rubocop', '~> 0.50.0'
25
25
 
26
26
  spec.add_runtime_dependency 'git', '~>1.3'
27
+ spec.add_runtime_dependency 'gitlab', '~>4.0'
27
28
  spec.add_runtime_dependency 'octokit', '~>4.0'
28
29
  spec.add_runtime_dependency 'puppet-blacksmith', '~>3.0'
29
30
  spec.add_runtime_dependency 'thor'
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+ require 'modulesync/pr/github'
3
+
4
+ describe ModuleSync::PR::GitHub 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(Octokit::Client).to receive(:new).and_return(@client)
19
+ @it = ModuleSync::PR::GitHub.new('test', 'https://api.github.com')
20
+ end
21
+
22
+ it 'submits PR when --pr is set' do
23
+ allow(@client).to receive(:pull_requests).with(@git_repo, :state => 'open', :base => 'master', :head => "#{@namespace}:#{@options[:branch]}").and_return([])
24
+ expect(@client).to receive(:create_pull_request).with(@git_repo, 'master', @options[:branch], @options[:pr_title], @options[:message]).and_return({"html_url" => "http://example.com/pulls/22"})
25
+ expect { @it.manage(@namespace, @repo_name, @options) }.to output(/Submitted PR/).to_stdout
26
+ end
27
+
28
+ it 'skips submitting PR if one has already been issued' do
29
+ pr = {
30
+ "title" => "Test title",
31
+ "html_url" => "https://example.com/pulls/44",
32
+ "number" => "44"
33
+ }
34
+
35
+ expect(@client).to receive(:pull_requests).with(@git_repo, :state => 'open', :base => 'master', :head => "#{@namespace}:#{@options[:branch]}").and_return([pr])
36
+ expect { @it.manage(@namespace, @repo_name, @options) }.to output(/Skipped! 1 PRs found for branch test/).to_stdout
37
+ end
38
+
39
+ it 'adds labels to PR when --pr-labels is set' do
40
+ @options[:pr_labels] = "HELLO,WORLD"
41
+
42
+ allow(@client).to receive(:create_pull_request).and_return({"html_url" => "http://example.com/pulls/22", "number" => "44"})
43
+ allow(@client).to receive(:pull_requests).with(@git_repo, :state => 'open', :base => 'master', :head => "#{@namespace}:#{@options[:branch]}").and_return([])
44
+
45
+ expect(@client).to receive(:add_labels_to_an_issue).with(@git_repo, "44", ["HELLO", "WORLD"])
46
+ expect { @it.manage(@namespace, @repo_name, @options) }.to output(/Attaching the following labels to PR 44: HELLO, WORLD/).to_stdout
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,81 @@
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
@@ -12,58 +12,11 @@ describe ModuleSync do
12
12
  end
13
13
  end
14
14
 
15
- context '::manage_pr' do
16
- before(:each) do
17
- stub_const('GITHUB_TOKEN', 'test')
18
- @git_repo = 'test/modulesync'
19
- @namespace, @repo_name = @git_repo.split('/')
20
- @options = {
21
- :pr => true,
22
- :pr_title => 'Test PR is submitted',
23
- :branch => 'test',
24
- :message => 'Hello world',
25
- :pr_auto_merge => false,
26
- }
27
-
28
- @client = double()
29
- end
30
-
31
- it 'rasies an error when GITHUB_TOKEN not set for PRs' do
32
- stub_const('GITHUB_TOKEN', '')
33
- options = {:pr => true, :skip_broken => false}
34
-
35
- expect { ModuleSync.manage_pr(@namespace, @repo_name, options) }.to raise_error(RuntimeError).and output(/GITHUB_TOKEN/).to_stderr
36
- end
37
-
38
- it 'submits PR when --pr is set' do
39
- allow(Octokit::Client).to receive(:new).and_return(@client)
40
- allow(@client).to receive(:pull_requests).with(@git_repo, :state => 'open', :base => 'master', :head => "#{@namespace}:#{@options[:branch]}").and_return([])
41
- expect(@client).to receive(:create_pull_request).with(@git_repo, 'master', @options[:branch], @options[:pr_title], @options[:message]).and_return({"html_url" => "http://example.com/pulls/22"})
42
- expect { ModuleSync.manage_pr(@namespace, @repo_name, @options) }.to output(/Submitted PR/).to_stdout
43
- end
44
-
45
- it 'skips submitting PR if one has already been issued' do
46
- allow(Octokit::Client).to receive(:new).and_return(@client)
47
-
48
- pr = {
49
- "title" => "Test title",
50
- "html_url" => "https://example.com/pulls/44",
51
- "number" => "44"
52
- }
53
-
54
- expect(@client).to receive(:pull_requests).with(@git_repo, :state => 'open', :base => 'master', :head => "#{@namespace}:#{@options[:branch]}").and_return([pr])
55
- expect { ModuleSync.manage_pr(@namespace, @repo_name, @options) }.to output(/Skipped! 1 PRs found for branch test/).to_stdout
56
- end
57
-
58
- it 'adds labels to PR when --pr-labels is set' do
59
- @options[:pr_labels] = "HELLO,WORLD"
60
-
61
- allow(Octokit::Client).to receive(:new).and_return(@client)
62
- allow(@client).to receive(:create_pull_request).and_return({"html_url" => "http://example.com/pulls/22", "number" => "44"})
63
- allow(@client).to receive(:pull_requests).with(@git_repo, :state => 'open', :base => 'master', :head => "#{@namespace}:#{@options[:branch]}").and_return([])
64
-
65
- expect(@client).to receive(:add_labels_to_an_issue).with(@git_repo, "44", ["HELLO", "WORLD"])
66
- expect { ModuleSync.manage_pr(@namespace, @repo_name, @options) }.to output(/Attaching the following labels to PR 44: HELLO, WORLD/).to_stdout
15
+ context '::create_pr_manager' do
16
+ describe "Raise Error" do
17
+ it 'raises an error when neither GITHUB_TOKEN nor GITLAB_TOKEN are set for PRs' do
18
+ expect { ModuleSync.create_pr_manager() }.to raise_error(RuntimeError).and output(/GITHUB_TOKEN/).to_stderr
19
+ end
67
20
  end
68
21
  end
69
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modulesync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-04 00:00:00.000000000 Z
11
+ date: 2020-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: gitlab
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '4.0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '4.0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: octokit
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -166,12 +180,16 @@ files:
166
180
  - lib/modulesync/constants.rb
167
181
  - lib/modulesync/git.rb
168
182
  - lib/modulesync/hook.rb
183
+ - lib/modulesync/pr/github.rb
184
+ - lib/modulesync/pr/gitlab.rb
169
185
  - lib/modulesync/renderer.rb
170
186
  - lib/modulesync/settings.rb
171
187
  - lib/modulesync/util.rb
172
188
  - lib/monkey_patches.rb
173
189
  - modulesync.gemspec
174
190
  - spec/spec_helper.rb
191
+ - spec/unit/modulesync/pr/github_spec.rb
192
+ - spec/unit/modulesync/pr/gitlab_spec.rb
175
193
  - spec/unit/modulesync/settings_spec.rb
176
194
  - spec/unit/modulesync_spec.rb
177
195
  homepage: http://github.com/voxpupuli/modulesync
@@ -193,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
211
  - !ruby/object:Gem::Version
194
212
  version: '0'
195
213
  requirements: []
196
- rubygems_version: 3.1.2
214
+ rubygems_version: 3.1.4
197
215
  signing_key:
198
216
  specification_version: 4
199
217
  summary: Puppet Module Synchronizer
@@ -204,5 +222,7 @@ test_files:
204
222
  - features/support/env.rb
205
223
  - features/update.feature
206
224
  - spec/spec_helper.rb
225
+ - spec/unit/modulesync/pr/github_spec.rb
226
+ - spec/unit/modulesync/pr/gitlab_spec.rb
207
227
  - spec/unit/modulesync/settings_spec.rb
208
228
  - spec/unit/modulesync_spec.rb