danger-jira_sync 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/jira_sync/gem_version.rb +1 -1
- data/lib/jira_sync/plugin.rb +3 -1
- data/spec/jira_sync_spec.rb +33 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b11f9ef73bd5db3c5d26b38c5fa285ad6d958bc28d8ea0c1143f3c5d4d1b650e
|
4
|
+
data.tar.gz: aabfa9cd7a266af8cdf860d0ec44c55db61a1300e09909600ca3556b4bf01d45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e00eb94c4cdee985fcd70cdc0d12680e268ebbad0e8e9849e7fe2a1c47c055d393df8de41664892abc2622817ce4c00816c69d43e12fdc5e803fec939fa5e6a9
|
7
|
+
data.tar.gz: 397899d6534b6020747fa15715a22b9b82aaa4538058bb532498d3250f9e555626cae94367f1f033fbfa8dfe36f6a21ee560be47173e475bb2c5050f4c8df7dd
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -62,6 +62,6 @@ Labels the Pull Request with Jira Project Keys and Component Names
|
|
62
62
|
|
63
63
|
# **:warning: Do not commit fixtures with your credentials in them :warning:**
|
64
64
|
|
65
|
-
Before committing, check to see if you have created or changed any fixtures in `/spec/fixtures/vcr_cassettes`. If you have, it is
|
65
|
+
Before committing, check to see if you have created or changed any fixtures in `/spec/fixtures/vcr_cassettes`. If you have, it is possible that the changed file contains your credentials. Manually remove your credentials from these fixture files
|
66
66
|
|
67
67
|
When a new HTTP request is made that [VCR](https://github.com/vcr/vcr) hasn't seen before, it will record the response from the server and play it back in subsequent HTTP requests to the same URL with the same headers. This means that if a new request is made in the tests, it will actually make a request to the server in order to record the response. For this reason, development should be done within testing environments in GitHub and Jira Cloud
|
data/lib/jira_sync/plugin.rb
CHANGED
@@ -138,7 +138,9 @@ module Danger
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def add_labels_to_issue(labels)
|
141
|
-
github.api.
|
141
|
+
existing_labels = github.api.labels_for_issue(repo, issue_number).map { |label| label[:name] }
|
142
|
+
new_labels = labels - existing_labels
|
143
|
+
github.api.add_labels_to_an_issue(repo, issue_number, new_labels) unless new_labels.empty?
|
142
144
|
rescue Octokit::Error => e
|
143
145
|
warn "#{e.response_status} Error while adding labels [#{labels}] to GitHub issue: #{e.message}"
|
144
146
|
end
|
data/spec/jira_sync_spec.rb
CHANGED
@@ -146,6 +146,7 @@ RSpec.describe Danger::DangerJiraSync do
|
|
146
146
|
def stub_github_api_labelling(labels: [])
|
147
147
|
allow(github_api_mock).to receive(:labels).and_return(github_labels_response(labels))
|
148
148
|
allow(github_api_mock).to receive(:add_label).and_return(nil)
|
149
|
+
allow(github_api_mock).to receive(:labels_for_issue).and_return([])
|
149
150
|
allow(github_api_mock).to receive(:add_labels_to_an_issue).and_return(nil)
|
150
151
|
|
151
152
|
allow(plugin.github).to receive(:api).and_return(github_api_mock)
|
@@ -312,6 +313,27 @@ RSpec.describe Danger::DangerJiraSync do
|
|
312
313
|
expect(dangerfile.status_report[:warnings].count).to eq(1)
|
313
314
|
end
|
314
315
|
|
316
|
+
it "creates a warning when it cannot fetch labels for the related pr" do
|
317
|
+
stub_github_api_labelling
|
318
|
+
|
319
|
+
error = Octokit::Error.from_response({
|
320
|
+
method: "GET",
|
321
|
+
url: "https://www.example.com/",
|
322
|
+
status: 503,
|
323
|
+
documentation_url: "https://developer.github.com/v3/issues/labels/#create-a-label",
|
324
|
+
message: "Forbidden"
|
325
|
+
})
|
326
|
+
|
327
|
+
expect(github_api_mock).to receive(:labels_for_issue).and_raise(error)
|
328
|
+
expect(dangerfile.status_report[:warnings].count).to eq(0), "preconditions"
|
329
|
+
|
330
|
+
VCR.use_cassette(:default_success, record: :new_episodes) do
|
331
|
+
plugin.autolabel_pull_request(issue_prefixes)
|
332
|
+
end
|
333
|
+
|
334
|
+
expect(dangerfile.status_report[:warnings].count).to eq(1)
|
335
|
+
end
|
336
|
+
|
315
337
|
it "creates a warning when it cannot fetch existing github labels" do
|
316
338
|
stub_github_api_labelling
|
317
339
|
|
@@ -359,6 +381,17 @@ RSpec.describe Danger::DangerJiraSync do
|
|
359
381
|
end
|
360
382
|
end
|
361
383
|
|
384
|
+
it "does not add existing labels to the github pr" do
|
385
|
+
expect(github_api_mock).to receive(:labels_for_issue).once.and_return github_labels_response(%w(DEV))
|
386
|
+
expect(github_api_mock).to receive(:add_labels_to_an_issue).with(anything, anything, %w(ComponentA ComponentC ABC ComponentB)).once
|
387
|
+
|
388
|
+
stub_github_api_labelling
|
389
|
+
|
390
|
+
VCR.use_cassette(:default_success, record: :new_episodes) do
|
391
|
+
plugin.autolabel_pull_request(issue_prefixes)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
362
395
|
it "adds missing github labels" do
|
363
396
|
labels = pr_title_project_keys + pr_title_related_component_names
|
364
397
|
labels.each do |label|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-jira_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Menesini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|