danger 4.0.4 → 4.0.5
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/lib/danger/ci_source/support/pull_request_finder.rb +9 -1
- data/lib/danger/comment_generators/github.md.erb +1 -1
- data/lib/danger/helpers/comments_helper.rb +1 -0
- data/lib/danger/helpers/find_max_num_violations.rb +31 -0
- data/lib/danger/request_sources/github.rb +2 -2
- data/lib/danger/version.rb +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 2b38a6e168e6dcf728c7b4b6f21508898d541403
         | 
| 4 | 
            +
              data.tar.gz: ff70b2d646014a8ad369e5ed58a8e8a23ff8fdd7
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c1e063484128d9082a71d2988b8204a5161b8311935979997c120d03b30c4cc4110617f9d2a908826538bb406e59046299136058b3bf90ab023724ceae2d89c9
         | 
| 7 | 
            +
              data.tar.gz: 4330a18b4774180d562017580484e3bc7fe9f6e97cf54f10611b86f0bc2f20938bfe4400ce4637c45564a4c5162b0b142cfef6a7374183e68ff3daa73222a870
         | 
| @@ -116,7 +116,15 @@ module Danger | |
| 116 116 |  | 
| 117 117 | 
             
                def client
         | 
| 118 118 | 
             
                  require "octokit"
         | 
| 119 | 
            -
                  Octokit::Client.new(access_token: ENV["DANGER_GITHUB_API_TOKEN"])
         | 
| 119 | 
            +
                  Octokit::Client.new(access_token: ENV["DANGER_GITHUB_API_TOKEN"], api_endpoint: api_url)
         | 
| 120 | 
            +
                end
         | 
| 121 | 
            +
             | 
| 122 | 
            +
                def api_url
         | 
| 123 | 
            +
                  ENV.fetch("DANGER_GITHUB_API_HOST") do
         | 
| 124 | 
            +
                    ENV.fetch("DANGER_GITHUB_API_BASE_URL") do
         | 
| 125 | 
            +
                      "https://api.github.com/".freeze
         | 
| 126 | 
            +
                    end
         | 
| 127 | 
            +
                  end
         | 
| 120 128 | 
             
                end
         | 
| 121 129 | 
             
              end
         | 
| 122 130 | 
             
            end
         | 
| @@ -14,7 +14,7 @@ | |
| 14 14 | 
             
                 </tr>
         | 
| 15 15 | 
             
              </thead>
         | 
| 16 16 | 
             
              <tbody>
         | 
| 17 | 
            -
                <%- max_num_violations =  | 
| 17 | 
            +
                <%- max_num_violations = FindMaxNumViolations.new(table[:content]).call -%>
         | 
| 18 18 | 
             
                <%- table[:content].take(max_num_violations).each do |violation| -%>
         | 
| 19 19 | 
             
                <tr>
         | 
| 20 20 | 
             
                  <td>:<%= table[:emoji] %>:</td>
         | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            # Find max_num_violations in lib/danger/comment_generators/github.md.erb.
         | 
| 2 | 
            +
            class FindMaxNumViolations
         | 
| 3 | 
            +
              # Save ~ 5000 for contents other than violations to avoid exceeded 65536 max comment length limit.
         | 
| 4 | 
            +
              LIMIT = 60_000
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def initialize(violations)
         | 
| 7 | 
            +
                @violations = violations
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              def call
         | 
| 11 | 
            +
                total = 0
         | 
| 12 | 
            +
                num_of_violations_allowed = 0
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                violations.each do |violation|
         | 
| 15 | 
            +
                  message_length = violation.message.length + 80 # 80 is ~ the size of html wraps violation message.
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  if total + message_length < LIMIT
         | 
| 18 | 
            +
                    total += message_length
         | 
| 19 | 
            +
                    num_of_violations_allowed += 1
         | 
| 20 | 
            +
                  else
         | 
| 21 | 
            +
                    break
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                num_of_violations_allowed
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              private
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              attr_reader :violations
         | 
| 31 | 
            +
            end
         | 
| @@ -353,8 +353,8 @@ module Danger | |
| 353 353 | 
             
                      end
         | 
| 354 354 |  | 
| 355 355 | 
             
                      # We are past the line position, just abort
         | 
| 356 | 
            -
                      break if message.line < range_start
         | 
| 357 | 
            -
                      next unless message.line >= range_start && message.line <= range_end
         | 
| 356 | 
            +
                      break if message.line.to_i < range_start
         | 
| 357 | 
            +
                      next unless message.line.to_i >= range_start && message.line.to_i <= range_end
         | 
| 358 358 |  | 
| 359 359 | 
             
                      file_line = range_start
         | 
| 360 360 | 
             
                    end
         | 
    
        data/lib/danger/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: danger
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 4.0. | 
| 4 | 
            +
              version: 4.0.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Orta Therox
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2017-01-13 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: claide
         | 
| @@ -422,6 +422,7 @@ files: | |
| 422 422 | 
             
            - lib/danger/helpers/comments_helper.rb
         | 
| 423 423 | 
             
            - lib/danger/helpers/comments_parsing_helper.rb
         | 
| 424 424 | 
             
            - lib/danger/helpers/emoji_mapper.rb
         | 
| 425 | 
            +
            - lib/danger/helpers/find_max_num_violations.rb
         | 
| 425 426 | 
             
            - lib/danger/plugin_support/gems_resolver.rb
         | 
| 426 427 | 
             
            - lib/danger/plugin_support/plugin.rb
         | 
| 427 428 | 
             
            - lib/danger/plugin_support/plugin_file_resolver.rb
         |