danger-swiftformat 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1437a0e4028a1bb64f0627d4bc16e15bb8ab73e7
4
- data.tar.gz: dbad08332fa993cd805425cc88557dbde5524e67
3
+ metadata.gz: 3f81a4c7e44e5a23a8d7067dce1c851f898ed8a8
4
+ data.tar.gz: 345782e42ac5b52abd278476c527ba412e374763
5
5
  SHA512:
6
- metadata.gz: 8314e9c66a55238c9923d80bc249ef6c5c0a7f86cb60a6bb7c5ccf951df51ac584565f4e2015e7499a42bd0f757c6108d1e122cad7880e480e10e3a47e385eca
7
- data.tar.gz: 8c9a45515e26efa9cfb60f871b13c9e10a8755ad5979bb295309c1c05d0380401b79fbd52d8e294be2f01c0e049621b44e9f698aa49ff1977a882cccce0e106b
6
+ metadata.gz: 3c660ed15219c13a5d4d68f6196207e06a418cb2cc0277b60a39dc71ef73add88d1c0112a29a9662eef8c22d012c81f39f93ed2de971e884a1f187b8100afdca
7
+ data.tar.gz: bc68d5038eb2355a49c79aa3b1fc58a385cbbe3c6b66e3315cbcace224a048f8df3f20df70c69d778ddf10ae9b13887bba40ab850457620e3451af1cb47c2620
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-swiftformat (0.3.0)
4
+ danger-swiftformat (0.3.1)
5
5
  danger-plugin-api (~> 1.0)
6
6
 
7
7
  GEM
@@ -19,7 +19,7 @@ GEM
19
19
  colored2 (3.1.2)
20
20
  cork (0.3.0)
21
21
  colored2 (~> 3.1)
22
- danger (5.5.5)
22
+ danger (5.5.6)
23
23
  claide (~> 1.0)
24
24
  claide-plugins (>= 0.9.2)
25
25
  colored2 (~> 3.1)
@@ -1,3 +1,3 @@
1
1
  module Swiftformat
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "0.3.1".freeze
3
3
  end
@@ -1,3 +1,5 @@
1
+ require "logger"
2
+
1
3
  module Danger
2
4
  class SwiftFormat
3
5
  def initialize(path = nil)
@@ -45,7 +47,13 @@ module Danger
45
47
  RUNTIME_REGEX = /.*swiftformat completed.*(.+\..+)s/
46
48
 
47
49
  def run_time(output)
48
- RUNTIME_REGEX.match(output)[1]
50
+ if RUNTIME_REGEX.match(output)
51
+ RUNTIME_REGEX.match(output)[1]
52
+ else
53
+ logger = Logger.new(STDERR)
54
+ logger.error("Invalid run_time output: #{output}")
55
+ "-1"
56
+ end
49
57
  end
50
58
  end
51
59
  end
@@ -0,0 +1,9 @@
1
+ running swiftformat...
2
+ formatting /Users/garriguv/FirstClass.swift
3
+ -- no changes
4
+ formatting /Users/garriguv/FileWithErrors.swift
5
+ -- no changes
6
+ formatting /Users/garriguv/OtherFile.swift
7
+ -- no changes
8
+
9
+ swiftformat completed. 0/3 files would have been updated in 0.08m
@@ -113,5 +113,20 @@ RSpec.describe Danger::SwiftFormat do
113
113
 
114
114
  expect(@sut.check_format(%w(.), "--self insert --indent tab")).to eq(output)
115
115
  end
116
+
117
+ it "should not crash if the output is invalid" do
118
+ expect(@cmd).to receive(:run)
119
+ .with(%w(swiftformat . --self insert --indent tab --dryrun --verbose))
120
+ .and_return(fixture("swiftformat_output_bad.txt"))
121
+
122
+ output = {
123
+ errors: [],
124
+ stats: {
125
+ run_time: "-1"
126
+ }
127
+ }
128
+
129
+ expect(@sut.check_format(%w(.), "--self insert --indent tab")).to eq(output)
130
+ end
116
131
  end
117
132
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-swiftformat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Garrigues
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-12 00:00:00.000000000 Z
11
+ date: 2018-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api
@@ -174,6 +174,7 @@ files:
174
174
  - lib/swiftformat/plugin.rb
175
175
  - lib/swiftformat/swiftformat.rb
176
176
  - spec/fixtures/swiftformat_output.txt
177
+ - spec/fixtures/swiftformat_output_bad.txt
177
178
  - spec/fixtures/swiftformat_output_with_errors.txt
178
179
  - spec/spec_helper.rb
179
180
  - spec/swiftformat/plugin_spec.rb
@@ -204,6 +205,7 @@ specification_version: 4
204
205
  summary: A danger plugin for checking Swift formatting using SwiftFormat.
205
206
  test_files:
206
207
  - spec/fixtures/swiftformat_output.txt
208
+ - spec/fixtures/swiftformat_output_bad.txt
207
209
  - spec/fixtures/swiftformat_output_with_errors.txt
208
210
  - spec/spec_helper.rb
209
211
  - spec/swiftformat/plugin_spec.rb