danger-todoist 2.0.0 → 2.0.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
  SHA256:
3
- metadata.gz: 40d67599877e38f3a1c049466dc30319a51e2c6cf4af6510382b145049acfc4f
4
- data.tar.gz: 6c8e7ea8d40784801b56a9b96161f928088b9cc781febe75eb6205e91ca8ce99
3
+ metadata.gz: 4afb3ce622171a380007204479eedb0aefca4df4ef76b5ea8fb06d9892499db1
4
+ data.tar.gz: 32524a2b719ab4facc971623599f39213139a6dbd448ec1825b35097c67e640c
5
5
  SHA512:
6
- metadata.gz: b5827657a3f8eae8810f81975d49a1a43e3531c9ffd3cab0125f3f48ed0373c8d68be8909d2b2907ce5d392cb58b1b2a8e0b34de66d6c7809d5e6fd8e1e21e37
7
- data.tar.gz: 21888fa0872b48b3724db99131d678fb73adfefc8af69e51ba76482e5c60ded667c6aa439ef160ad4482e21e62daf32d41c8dd098e4b5f1577406540bfe07183
6
+ metadata.gz: 76900a481490c824961e518c5186035cf76508fed553145cfc999b20b6c9c9c061cbb35fea6859d67ff50c4b359b9f167ba4d494bf5c3769c1cec39bcc0d925f
7
+ data.tar.gz: aedc837ec910921a8cfd963539e340eeb8da2ee4b1bed364402c4077d9843118818655cf19b7a7dcc01d13e0a71b0929766f3172e726400808b0713a08a379cf
@@ -1,5 +1,9 @@
1
1
  ## master
2
2
 
3
+ ## 2.0.1
4
+
5
+ * fix bug where existing todos in a patch were identified - allewun
6
+
3
7
  ## 2.0.0
4
8
 
5
9
  * Drop rubies below 2.3.8 from support and require bundler 2 - hanneskaeufler
@@ -5,13 +5,26 @@ module Danger
5
5
  @regexp = todo_regexp(keywords)
6
6
  end
7
7
 
8
+ # rubocop:disable Metrics/MethodLength
8
9
  def call(diffs)
9
10
  diffs
10
- .map { |diff| MatchesInDiff.new(diff, diff.patch.scan(@regexp)) }
11
+ .map do |diff|
12
+ # Should only look for matches *within* the changed lines of a patch
13
+ # (lines that begin with "+"), not the entire patch.
14
+ # The current regexp doesn't enforce this correctly in some cases.
15
+ patch = MatchesInDiff::Patch.new(diff.patch)
16
+ matches = patch.changed_lines
17
+ .map(&:content)
18
+ .join
19
+ .scan(@regexp)
20
+
21
+ MatchesInDiff.new(diff, matches)
22
+ end
11
23
  .select(&:todo_matches?)
12
24
  .map(&:all_todos)
13
25
  .flatten
14
26
  end
27
+ # rubocop:enable Metrics/MethodLength
15
28
 
16
29
  private
17
30
 
@@ -1,3 +1,3 @@
1
1
  module Todoist
2
- VERSION = "2.0.0".freeze
2
+ VERSION = "2.0.1".freeze
3
3
  end
@@ -140,6 +140,12 @@ PATCH
140
140
  "I'd rather not have this here ... because it's probably "\
141
141
  "just a bit of code that we can reimplement or steal"])
142
142
  end
143
+
144
+ it "ignores pre-existing todos found in the context lines of a patch" do
145
+ diff = sample_diff_fixture("preexisting_todo.diff")
146
+ todos = subject.call([diff])
147
+ expect(todos).to be_empty
148
+ end
143
149
  end
144
150
  end
145
151
  # rubocop:enable Metrics/BlockLength
@@ -0,0 +1,16 @@
1
+ diff --git a/lib/todoist/diff_todo_finder.rb b/lib/todoist/diff_todo_finder.rb
2
+ index b58809b..1ecc4f0 100644
3
+ --- a/lib/todoist/diff_todo_finder.rb
4
+ +++ b/lib/todoist/diff_todo_finder.rb
5
+ @@ -54,9 +53,11 @@ def all_todos
6
+
7
+ def line_number(match)
8
+ _, todo_indicator = match
9
+ GitDiffParser::Patch.new(diff.patch).changed_lines.each do |line|
10
+ return line.number if line.content =~ /#{todo_indicator}/
11
+ end
12
+ + # introducing a change with a newline right above a pre-existing TODO
13
+ +
14
+ # TODO: thats not gonna fly
15
+ -1
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-todoist
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hannes Käufler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-09 00:00:00.000000000 Z
11
+ date: 2019-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api
@@ -207,6 +207,7 @@ files:
207
207
  - spec/diff_inline_todo_finder_spec.rb
208
208
  - spec/diff_todo_finder_spec.rb
209
209
  - spec/fixtures/multiline_todo_patch.diff
210
+ - spec/fixtures/preexisting_todo.diff
210
211
  - spec/fixtures/sample_patch.diff
211
212
  - spec/matches_in_diff_spec.rb
212
213
  - spec/spec_helper.rb
@@ -230,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
231
  - !ruby/object:Gem::Version
231
232
  version: '0'
232
233
  requirements: []
233
- rubygems_version: 3.0.1
234
+ rubygems_version: 3.0.6
234
235
  signing_key:
235
236
  specification_version: 4
236
237
  summary: Marking something with a todo is very common during implementing a new feature.
@@ -239,6 +240,7 @@ test_files:
239
240
  - spec/diff_inline_todo_finder_spec.rb
240
241
  - spec/diff_todo_finder_spec.rb
241
242
  - spec/fixtures/multiline_todo_patch.diff
243
+ - spec/fixtures/preexisting_todo.diff
242
244
  - spec/fixtures/sample_patch.diff
243
245
  - spec/matches_in_diff_spec.rb
244
246
  - spec/spec_helper.rb