danger 8.1.0 → 8.3.1
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/README.md +1 -1
- data/lib/danger/ci_source/appcenter.rb +1 -1
- data/lib/danger/ci_source/appveyor.rb +3 -0
- data/lib/danger/ci_source/azure_pipelines.rb +2 -2
- data/lib/danger/ci_source/bitbucket_pipelines.rb +1 -0
- data/lib/danger/ci_source/buildkite.rb +1 -1
- data/lib/danger/ci_source/circle.rb +1 -1
- data/lib/danger/ci_source/codemagic.rb +58 -0
- data/lib/danger/ci_source/concourse.rb +61 -0
- data/lib/danger/ci_source/drone.rb +2 -2
- data/lib/danger/ci_source/github_actions.rb +3 -2
- data/lib/danger/ci_source/gitlab_ci.rb +10 -1
- data/lib/danger/ci_source/jenkins.rb +1 -1
- data/lib/danger/ci_source/screwdriver.rb +2 -1
- data/lib/danger/ci_source/support/commits.rb +14 -12
- data/lib/danger/ci_source/teamcity.rb +2 -0
- data/lib/danger/commands/dangerfile/init.rb +1 -1
- data/lib/danger/commands/dry_run.rb +1 -1
- data/lib/danger/commands/init.rb +1 -1
- data/lib/danger/commands/local.rb +1 -1
- data/lib/danger/commands/local_helpers/pry_setup.rb +4 -4
- data/lib/danger/commands/pr.rb +1 -1
- data/lib/danger/commands/staging.rb +1 -1
- data/lib/danger/comment_generators/gitlab_inline.md.erb +2 -7
- data/lib/danger/danger_core/dangerfile.rb +10 -6
- data/lib/danger/danger_core/environment_manager.rb +2 -0
- data/lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb +1 -1
- data/lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb +21 -1
- data/lib/danger/danger_core/plugins/dangerfile_github_plugin.rb +8 -0
- data/lib/danger/danger_core/plugins/dangerfile_gitlab_plugin.rb +8 -0
- data/lib/danger/plugin_support/plugin.rb +6 -2
- data/lib/danger/request_sources/bitbucket_cloud_api.rb +6 -4
- data/lib/danger/request_sources/gitlab.rb +10 -10
- data/lib/danger/version.rb +1 -1
- metadata +12 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 78727e10312d96889e8e0fe3dcf38c1ec9137932972eb2538f9d39e0c114ef1c
         | 
| 4 | 
            +
              data.tar.gz: 57bbfff9bf004e91e3e900b87a80d34c3aebb749cc473e3a9496be8fd61652b2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 7be9c56ed729037d9b2c557e9a349e4ba091226c2ff4caa2b37c8432bdf2c515f7343ce9cf744797d79681b8cbdf50e03584d91551da03aa82509884f151c461
         | 
| 7 | 
            +
              data.tar.gz: dcfd5b78ad9d722a040737f7b0c64718d55297821ebf1d0bb3e78bddb46939d9331bc772b2cd398b00cadf33daff49e69001d1618fb2ece3e167185282e3a379
         | 
    
        data/README.md
    CHANGED
    
    
| @@ -3,6 +3,7 @@ module Danger | |
| 3 3 | 
             
              # ### CI Setup
         | 
| 4 4 | 
             
              #
         | 
| 5 5 | 
             
              # Install dependencies and add a danger step to your `appveyor.yml`.
         | 
| 6 | 
            +
              #
         | 
| 6 7 | 
             
              # ```yaml
         | 
| 7 8 | 
             
              # install:
         | 
| 8 9 | 
             
              # - cmd: >-
         | 
| @@ -19,6 +20,7 @@ module Danger | |
| 19 20 | 
             
              # For public repositories, add your plain token to environment variables in `appveyor.yml`.
         | 
| 20 21 | 
             
              # Encrypted environment variables will not be decrypted on PR builds.
         | 
| 21 22 | 
             
              # see here: https://www.appveyor.com/docs/build-configuration/#secure-variables
         | 
| 23 | 
            +
              #
         | 
| 22 24 | 
             
              # ```yaml
         | 
| 23 25 | 
             
              # environment:
         | 
| 24 26 | 
             
              #   DANGER_GITHUB_API_TOKEN: <YOUR_TOKEN_HERE>
         | 
| @@ -26,6 +28,7 @@ module Danger | |
| 26 28 | 
             
              #
         | 
| 27 29 | 
             
              # For private repositories, enter your token in `Settings>Environment>Environment variables>Add variable` and turn on `variable encryption`.
         | 
| 28 30 | 
             
              # You will see encrypted variable text in `Settings>Export YAML` so just copy to your `appveyor.yml`.
         | 
| 31 | 
            +
              #
         | 
| 29 32 | 
             
              # ```yaml
         | 
| 30 33 | 
             
              # environment:
         | 
| 31 34 | 
             
              #   DANGER_GITHUB_API_TOKEN:
         | 
| @@ -7,7 +7,7 @@ module Danger | |
| 7 7 | 
             
              #
         | 
| 8 8 | 
             
              # Add a script step:
         | 
| 9 9 | 
             
              #
         | 
| 10 | 
            -
              # ``` | 
| 10 | 
            +
              # ```shell
         | 
| 11 11 | 
             
              #   #!/usr/bin/env bash
         | 
| 12 12 | 
             
              #   bundle install
         | 
| 13 13 | 
             
              #   bundle exec danger
         | 
| @@ -19,7 +19,7 @@ module Danger | |
| 19 19 | 
             
              #
         | 
| 20 20 | 
             
              class AzurePipelines < CI
         | 
| 21 21 | 
             
                def self.validates_as_ci?(env)
         | 
| 22 | 
            -
                  env.key? | 
| 22 | 
            +
                  env.key?("AGENT_ID") && env["BUILD_REPOSITORY_PROVIDER"] != "TfsGit"
         | 
| 23 23 | 
             
                end
         | 
| 24 24 |  | 
| 25 25 | 
             
                def self.validates_as_pr?(env)
         | 
| @@ -9,7 +9,7 @@ module Danger | |
| 9 9 | 
             
              # With BuildKite you run the server yourself, so you will want to run  it as a part of your build process.
         | 
| 10 10 | 
             
              # It is common to have build steps, so we would recommend adding this to your scrip:
         | 
| 11 11 | 
             
              #
         | 
| 12 | 
            -
              #  ``` | 
| 12 | 
            +
              #  ```shell
         | 
| 13 13 | 
             
              #   echo "--- Running Danger"
         | 
| 14 14 | 
             
              #   bundle exec danger
         | 
| 15 15 | 
             
              #  ```
         | 
| @@ -0,0 +1,58 @@ | |
| 1 | 
            +
            # https://docs.codemagic.io/building/environment-variables/
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Danger
         | 
| 4 | 
            +
              # ### CI Setup
         | 
| 5 | 
            +
              #
         | 
| 6 | 
            +
              # Add a script step to your workflow:
         | 
| 7 | 
            +
              #
         | 
| 8 | 
            +
              # ```
         | 
| 9 | 
            +
              # - name: Running Danger
         | 
| 10 | 
            +
              #   script: |
         | 
| 11 | 
            +
              #     bundle install
         | 
| 12 | 
            +
              #     bundle exec danger
         | 
| 13 | 
            +
              # ```
         | 
| 14 | 
            +
              #
         | 
| 15 | 
            +
              # ### Token Setup
         | 
| 16 | 
            +
              #
         | 
| 17 | 
            +
              # Add the following environment variables to your workflow's environment configuration.
         | 
| 18 | 
            +
              # https://docs.codemagic.io/getting-started/yaml/
         | 
| 19 | 
            +
              #
         | 
| 20 | 
            +
              # #### GitHub
         | 
| 21 | 
            +
              # Add the `DANGER_GITHUB_API_TOKEN` to your build user's ENV.
         | 
| 22 | 
            +
              #
         | 
| 23 | 
            +
              # #### GitLab
         | 
| 24 | 
            +
              # Add the `DANGER_GITLAB_API_TOKEN` to your build user's ENV.
         | 
| 25 | 
            +
              #
         | 
| 26 | 
            +
              # #### Bitbucket Cloud
         | 
| 27 | 
            +
              # Add the `DANGER_BITBUCKETSERVER_USERNAME`, `DANGER_BITBUCKETSERVER_PASSWORD`
         | 
| 28 | 
            +
              # to your build user's ENV.
         | 
| 29 | 
            +
              #
         | 
| 30 | 
            +
              # #### Bitbucket server
         | 
| 31 | 
            +
              # Add the `DANGER_BITBUCKETSERVER_USERNAME`, `DANGER_BITBUCKETSERVER_PASSWORD`
         | 
| 32 | 
            +
              # and `DANGER_BITBUCKETSERVER_HOST` to your build user's ENV.
         | 
| 33 | 
            +
              #
         | 
| 34 | 
            +
              class Codemagic < CI
         | 
| 35 | 
            +
                def self.validates_as_ci?(env)
         | 
| 36 | 
            +
                  env.key? "FCI_PROJECT_ID"
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                def self.validates_as_pr?(env)
         | 
| 40 | 
            +
                  return !env["FCI_PULL_REQUEST_NUMBER"].to_s.empty?
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                def supported_request_sources
         | 
| 44 | 
            +
                  @supported_request_sources ||= [
         | 
| 45 | 
            +
                    Danger::RequestSources::GitHub,
         | 
| 46 | 
            +
                    Danger::RequestSources::GitLab,
         | 
| 47 | 
            +
                    Danger::RequestSources::BitbucketServer,
         | 
| 48 | 
            +
                    Danger::RequestSources::BitbucketCloud
         | 
| 49 | 
            +
                  ]
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                def initialize(env)
         | 
| 53 | 
            +
                  self.pull_request_id = env["FCI_PULL_REQUEST_NUMBER"]
         | 
| 54 | 
            +
                  self.repo_slug = env["FCI_REPO_SLUG"]
         | 
| 55 | 
            +
                  self.repo_url = GitRepo.new.origins # Codemagic doesn't provide a repo url env variable for n
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
            end
         | 
| @@ -0,0 +1,61 @@ | |
| 1 | 
            +
            require "git"
         | 
| 2 | 
            +
            require "danger/request_sources/local_only"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Danger
         | 
| 5 | 
            +
            # Concourse CI Integration
         | 
| 6 | 
            +
            #
         | 
| 7 | 
            +
            # https://concourse-ci.org/
         | 
| 8 | 
            +
            #
         | 
| 9 | 
            +
              # ### CI Setup
         | 
| 10 | 
            +
              #
         | 
| 11 | 
            +
              # With Concourse, you run the docker images yourself, so you will want to add `yarn danger ci` within one of your build jobs.
         | 
| 12 | 
            +
              #
         | 
| 13 | 
            +
              #   ```shell
         | 
| 14 | 
            +
              #    build:
         | 
| 15 | 
            +
              #      image: golang
         | 
| 16 | 
            +
              #        commands:
         | 
| 17 | 
            +
              #          - ...
         | 
| 18 | 
            +
              #          - yarn danger ci
         | 
| 19 | 
            +
              #   ```
         | 
| 20 | 
            +
              #
         | 
| 21 | 
            +
              # ### Environment Variable Setup
         | 
| 22 | 
            +
              #
         | 
| 23 | 
            +
              # As this is self-hosted, you will need to add the `CONCOURSE` environment variable `export CONCOURSE=true` to your build environment,
         | 
| 24 | 
            +
              # as well as setting environment variables for `PULL_REQUEST_ID` and `REPO_SLUG`. Assuming you are using the github pull request resource
         | 
| 25 | 
            +
              # https://github.com/jtarchie/github-pullrequest-resource the id of the PR can be accessed from `git config --get pullrequest.id`.
         | 
| 26 | 
            +
              #
         | 
| 27 | 
            +
              # ### Token Setup
         | 
| 28 | 
            +
              #
         | 
| 29 | 
            +
              # Once again as this is self-hosted, you will need to add `DANGER_GITHUB_API_TOKEN` environment variable to the build environment.
         | 
| 30 | 
            +
              # The suggested method of storing the token is within the vault - https://concourse-ci.org/creds.html
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              class Concourse < CI
         | 
| 33 | 
            +
                def self.validates_as_ci?(env)
         | 
| 34 | 
            +
                  env.key? "CONCOURSE"
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                def self.validates_as_pr?(env)
         | 
| 38 | 
            +
                  exists = ["PULL_REQUEST_ID", "REPO_SLUG"].all? { |x| env[x] && !env[x].empty? }
         | 
| 39 | 
            +
                  exists && env["PULL_REQUEST_ID"].to_i > 0
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                def supported_request_sources
         | 
| 43 | 
            +
                  @supported_request_sources ||= [
         | 
| 44 | 
            +
                    Danger::RequestSources::GitHub,
         | 
| 45 | 
            +
                    Danger::RequestSources::GitLab,
         | 
| 46 | 
            +
                    Danger::RequestSources::BitbucketServer,
         | 
| 47 | 
            +
                    Danger::RequestSources::BitbucketCloud
         | 
| 48 | 
            +
                  ]
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                def initialize(env)
         | 
| 52 | 
            +
                  self.repo_slug = env["REPO_SLUG"]
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                  if env["PULL_REQUEST_ID"].to_i > 0
         | 
| 55 | 
            +
                    self.pull_request_id = env["PULL_REQUEST_ID"]
         | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
                  self.repo_url = GitRepo.new.origins
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
            end
         | 
| @@ -8,7 +8,7 @@ module Danger | |
| 8 8 | 
             
              # With Drone you run the docker images yourself, so you will want to add `bundle exec danger` at the end of
         | 
| 9 9 | 
             
              # your `.drone.yml`.
         | 
| 10 10 | 
             
              #
         | 
| 11 | 
            -
              #  ``` | 
| 11 | 
            +
              #  ```shell
         | 
| 12 12 | 
             
              #   build:
         | 
| 13 13 | 
             
              #     image: golang
         | 
| 14 14 | 
             
              #     commands:
         | 
| @@ -24,7 +24,7 @@ module Danger | |
| 24 24 | 
             
              # Drone secrets: http://readme.drone.io/usage/secret-guide/
         | 
| 25 25 | 
             
              # NOTE: This is a new syntax in DroneCI 0.6+
         | 
| 26 26 | 
             
              #
         | 
| 27 | 
            -
              # ```
         | 
| 27 | 
            +
              # ```yml
         | 
| 28 28 | 
             
              #   build:
         | 
| 29 29 | 
             
              #     image: golang
         | 
| 30 30 | 
             
              #     secrets:
         | 
| @@ -6,7 +6,7 @@ module Danger | |
| 6 6 | 
             
              # You can use `danger/danger` Action in your `.github/workflows/xxx.yml`.
         | 
| 7 7 | 
             
              # And so, you can use GITHUB_TOKEN secret as `DANGER_GITHUB_API_TOKEN` environment variable.
         | 
| 8 8 | 
             
              #
         | 
| 9 | 
            -
              #  ```
         | 
| 9 | 
            +
              #  ```yml
         | 
| 10 10 | 
             
              #  ...
         | 
| 11 11 | 
             
              #    steps:
         | 
| 12 12 | 
             
              #      - uses: actions/checkout@v1
         | 
| @@ -21,7 +21,8 @@ module Danger | |
| 21 21 | 
             
                end
         | 
| 22 22 |  | 
| 23 23 | 
             
                def self.validates_as_pr?(env)
         | 
| 24 | 
            -
                  env["GITHUB_EVENT_NAME"] | 
| 24 | 
            +
                  value = env["GITHUB_EVENT_NAME"]
         | 
| 25 | 
            +
                  value == "pull_request" || value == "pull_request_target"
         | 
| 25 26 | 
             
                end
         | 
| 26 27 |  | 
| 27 28 | 
             
                def supported_request_sources
         | 
| @@ -7,6 +7,7 @@ module Danger | |
| 7 7 | 
             
              # ### CI Setup
         | 
| 8 8 | 
             
              #
         | 
| 9 9 | 
             
              # Install dependencies and add a danger step to your .gitlab-ci.yml:
         | 
| 10 | 
            +
              #
         | 
| 10 11 | 
             
              # ```yml
         | 
| 11 12 | 
             
              # before_script:
         | 
| 12 13 | 
             
              #  - bundle install
         | 
| @@ -14,6 +15,7 @@ module Danger | |
| 14 15 | 
             
              #   script:
         | 
| 15 16 | 
             
              #    - bundle exec danger
         | 
| 16 17 | 
             
              # ```
         | 
| 18 | 
            +
              #
         | 
| 17 19 | 
             
              # ### Token Setup
         | 
| 18 20 | 
             
              #
         | 
| 19 21 | 
             
              # Add the `DANGER_GITLAB_API_TOKEN` to your pipeline env variables if you
         | 
| @@ -44,10 +46,17 @@ module Danger | |
| 44 46 | 
             
                  base_commit = env["CI_COMMIT_SHA"]
         | 
| 45 47 | 
             
                  client = RequestSources::GitLab.new(nil, env).client
         | 
| 46 48 |  | 
| 47 | 
            -
                   | 
| 49 | 
            +
                  client_version = Gem::Version.new(client.version.version)
         | 
| 50 | 
            +
                  if (client_version >= Gem::Version.new("10.7"))
         | 
| 48 51 | 
             
                    #Use the 'list merge requests associated with a commit' API, for speeed
         | 
| 49 52 | 
             
                    # (GET /projects/:id/repository/commits/:sha/merge_requests) available for GitLab >= 10.7
         | 
| 50 53 | 
             
                    merge_request = client.commit_merge_requests(project_path, base_commit, state: :opened).first
         | 
| 54 | 
            +
                    if (client_version >= Gem::Version.new("13.8"))
         | 
| 55 | 
            +
                      # Gitlab 13.8.0 started returning merge requests for merge commits and squashed commits
         | 
| 56 | 
            +
                      # By checking for merge_request.state, we can ensure danger only comments on MRs which are open
         | 
| 57 | 
            +
                      return 0 if merge_request.nil?
         | 
| 58 | 
            +
                      return 0 unless merge_request.state == "opened"
         | 
| 59 | 
            +
                    end
         | 
| 51 60 | 
             
                  else
         | 
| 52 61 | 
             
                    merge_requests = client.merge_requests(project_path, state: :opened)
         | 
| 53 62 | 
             
                    merge_request = merge_requests.auto_paginate.find do |mr|
         | 
| @@ -133,7 +133,7 @@ module Danger | |
| 133 133 | 
             
                      matches = change_url.match(%r{(.+)\/pull\/[0-9]+})
         | 
| 134 134 | 
             
                      matches[1] unless matches.nil?
         | 
| 135 135 | 
             
                    when %r{\/merge_requests\/} # GitLab
         | 
| 136 | 
            -
                      matches = change_url.match(%r{( | 
| 136 | 
            +
                      matches = change_url.match(%r{(.+?)(\/-)?\/merge_requests\/[0-9]+})
         | 
| 137 137 | 
             
                      matches[1] unless matches.nil?
         | 
| 138 138 | 
             
                    when %r{\/pull-requests\/} # Bitbucket
         | 
| 139 139 | 
             
                      matches = change_url.match(%r{(.+)\/pull-requests\/[0-9]+})
         | 
| @@ -1,17 +1,19 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
               | 
| 3 | 
            -
                 | 
| 4 | 
            -
             | 
| 1 | 
            +
            module Danger
         | 
| 2 | 
            +
              class Commits
         | 
| 3 | 
            +
                def initialize(base_head)
         | 
| 4 | 
            +
                  @base_head = base_head.strip.split(" ".freeze)
         | 
| 5 | 
            +
                end
         | 
| 5 6 |  | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 7 | 
            +
                def base
         | 
| 8 | 
            +
                  base_head.first
         | 
| 9 | 
            +
                end
         | 
| 9 10 |  | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 11 | 
            +
                def head
         | 
| 12 | 
            +
                  base_head.last
         | 
| 13 | 
            +
                end
         | 
| 13 14 |  | 
| 14 | 
            -
             | 
| 15 | 
            +
                private
         | 
| 15 16 |  | 
| 16 | 
            -
             | 
| 17 | 
            +
                attr_reader :base_head
         | 
| 18 | 
            +
              end
         | 
| 17 19 | 
             
            end
         | 
| @@ -27,6 +27,7 @@ module Danger | |
| 27 27 | 
             
              # branch="%teamcity.build.branch%"
         | 
| 28 28 | 
             
              # export GITHUB_PULL_REQUEST_ID=(${branch//\// })
         | 
| 29 29 | 
             
              # ```
         | 
| 30 | 
            +
              #
         | 
| 30 31 | 
             
              # Or if you are using the pull request feature you can set an environment parameter called `GITHUB_PULL_REQUEST_ID`
         | 
| 31 32 | 
             
              # to the value of: `%teamcity.pullRequest.number`
         | 
| 32 33 | 
             
              #
         | 
| @@ -59,6 +60,7 @@ module Danger | |
| 59 60 | 
             
              #
         | 
| 60 61 | 
             
              # You will also need to set the `BITBUCKET_BRANCH_NAME` environment variable.
         | 
| 61 62 | 
             
              # TeamCity provides `%teamcity.build.branch%`, which you can use at the top of your Simple Command Runner:
         | 
| 63 | 
            +
              #
         | 
| 62 64 | 
             
              # ```sh
         | 
| 63 65 | 
             
              # export BITBUCKET_BRANCH_NAME="%teamcity.build.branch%"
         | 
| 64 66 | 
             
              # ```
         | 
| @@ -4,7 +4,7 @@ require "danger/danger_core/dangerfile_generator" | |
| 4 4 |  | 
| 5 5 | 
             
            module Danger
         | 
| 6 6 | 
             
              class DangerfileCommand < Runner
         | 
| 7 | 
            -
                self.summary = "Easily create  | 
| 7 | 
            +
                self.summary = "Easily create your Dangerfiles."
         | 
| 8 8 | 
             
                self.command = "dangerfile"
         | 
| 9 9 |  | 
| 10 10 | 
             
                self.abstract_command = true
         | 
    
        data/lib/danger/commands/init.rb
    CHANGED
    
    | @@ -277,7 +277,7 @@ module Danger | |
| 277 277 | 
             
                  ui.say "- You can look at the following Dangerfiles to get some more ideas:"
         | 
| 278 278 | 
             
                  ui.pause 0.6
         | 
| 279 279 | 
             
                  ui.link "https://github.com/danger/danger/blob/master/Dangerfile"
         | 
| 280 | 
            -
                  ui.link "https://github.com/artsy/eigen/blob/master/ | 
| 280 | 
            +
                  ui.link "https://github.com/artsy/eigen/blob/master/dangerfile.ts"
         | 
| 281 281 | 
             
                  ui.pause 1
         | 
| 282 282 | 
             
                end
         | 
| 283 283 |  | 
| @@ -4,9 +4,9 @@ module Danger | |
| 4 4 | 
             
                  @cork = cork
         | 
| 5 5 | 
             
                end
         | 
| 6 6 |  | 
| 7 | 
            -
                def setup_pry(dangerfile_path)
         | 
| 7 | 
            +
                def setup_pry(dangerfile_path, command)
         | 
| 8 8 | 
             
                  return dangerfile_path if dangerfile_path.empty?
         | 
| 9 | 
            -
                  validate_pry_available
         | 
| 9 | 
            +
                  validate_pry_available(command)
         | 
| 10 10 | 
             
                  FileUtils.cp dangerfile_path, DANGERFILE_COPY
         | 
| 11 11 | 
             
                  File.open(DANGERFILE_COPY, "a") do |f|
         | 
| 12 12 | 
             
                    f.write("\nbinding.pry; File.delete(\"#{DANGERFILE_COPY}\")")
         | 
| @@ -20,10 +20,10 @@ module Danger | |
| 20 20 |  | 
| 21 21 | 
             
                DANGERFILE_COPY = "_Dangerfile.tmp".freeze
         | 
| 22 22 |  | 
| 23 | 
            -
                def validate_pry_available
         | 
| 23 | 
            +
                def validate_pry_available(command)
         | 
| 24 24 | 
             
                  Kernel.require "pry"
         | 
| 25 25 | 
             
                rescue LoadError
         | 
| 26 | 
            -
                  cork.warn "Pry was not found, and is required for 'danger  | 
| 26 | 
            +
                  cork.warn "Pry was not found, and is required for 'danger #{command} --pry'."
         | 
| 27 27 | 
             
                  cork.print_warnings
         | 
| 28 28 | 
             
                  abort
         | 
| 29 29 | 
             
                end
         | 
    
        data/lib/danger/commands/pr.rb
    CHANGED
    
    | @@ -37,7 +37,7 @@ module Danger | |
| 37 37 | 
             
                  @dangerfile_path = dangerfile if File.exist?(dangerfile)
         | 
| 38 38 |  | 
| 39 39 | 
             
                  if argv.flag?("pry", false)
         | 
| 40 | 
            -
                    @dangerfile_path = PrySetup.new(cork).setup_pry(@dangerfile_path)
         | 
| 40 | 
            +
                    @dangerfile_path = PrySetup.new(cork).setup_pry(@dangerfile_path, PR.command)
         | 
| 41 41 | 
             
                  end
         | 
| 42 42 | 
             
                end
         | 
| 43 43 |  | 
| @@ -17,10 +17,5 @@ | |
| 17 17 | 
             
            <%= current %>
         | 
| 18 18 | 
             
            <%# the previous line has to be aligned far to the left, otherwise markdown can break easily %>
         | 
| 19 19 | 
             
            <%- end -%>
         | 
| 20 | 
            -
            <%#  | 
| 21 | 
            -
             | 
| 22 | 
            -
            <%- if @markdowns.count > 0 -%>
         | 
| 23 | 
            -
            <p align="right" data-meta="generated_by_<%= @danger_id %>">
         | 
| 24 | 
            -
              Generated by :no_entry_sign: <a href="http://danger.systems/">Danger</a>
         | 
| 25 | 
            -
            </p>
         | 
| 26 | 
            -
            <%- end -%>
         | 
| 20 | 
            +
            <%# Add the generated_by_ as a html coment to identify comments from danger. %>
         | 
| 21 | 
            +
            <!-- "generated_by_<%= @danger_id %>" -->
         | 
| @@ -49,22 +49,26 @@ module Danger | |
| 49 49 | 
             
                # However, as we're using using them in the DSL, they won't
         | 
| 50 50 | 
             
                # get method_missing called correctly without overriding them.
         | 
| 51 51 |  | 
| 52 | 
            -
                def warn(*args, &blk)
         | 
| 53 | 
            -
                  method_missing(:warn, *args, &blk)
         | 
| 52 | 
            +
                def warn(*args, **kargs, &blk)
         | 
| 53 | 
            +
                  method_missing(:warn, *args, **kargs, &blk)
         | 
| 54 54 | 
             
                end
         | 
| 55 55 |  | 
| 56 | 
            -
                def fail(*args, &blk)
         | 
| 57 | 
            -
                  method_missing(:fail, *args, &blk)
         | 
| 56 | 
            +
                def fail(*args, **kargs, &blk)
         | 
| 57 | 
            +
                  method_missing(:fail, *args, **kargs, &blk)
         | 
| 58 58 | 
             
                end
         | 
| 59 59 |  | 
| 60 60 | 
             
                # When an undefined method is called, we check to see if it's something
         | 
| 61 61 | 
             
                # that the core DSLs have, then starts looking at plugins support.
         | 
| 62 62 |  | 
| 63 63 | 
             
                # rubocop:disable Style/MethodMissing
         | 
| 64 | 
            -
                def method_missing(method_sym, *arguments, &_block)
         | 
| 64 | 
            +
                def method_missing(method_sym, *arguments, **keyword_arguments, &_block)
         | 
| 65 65 | 
             
                  @core_plugins.each do |plugin|
         | 
| 66 66 | 
             
                    if plugin.public_methods(false).include?(method_sym)
         | 
| 67 | 
            -
                       | 
| 67 | 
            +
                      if keyword_arguments.empty?
         | 
| 68 | 
            +
                        return plugin.send(method_sym, *arguments)
         | 
| 69 | 
            +
                      else
         | 
| 70 | 
            +
                        return plugin.send(method_sym, *arguments, **keyword_arguments)
         | 
| 71 | 
            +
                      end
         | 
| 68 72 | 
             
                    end
         | 
| 69 73 | 
             
                  end
         | 
| 70 74 | 
             
                  super
         | 
| @@ -33,6 +33,11 @@ module Danger | |
| 33 33 | 
             
              #
         | 
| 34 34 | 
             
              #          danger.import_dangerfile(github: "ruby-grape/danger", branch: "custom", path: "path/to/Dangerfile")
         | 
| 35 35 | 
             
              #
         | 
| 36 | 
            +
              # @example Import a plugin available over HTTP
         | 
| 37 | 
            +
              #
         | 
| 38 | 
            +
              #          custom_url = "https://custom.bitbucket.com/project-name/Dangerfile?raw"
         | 
| 39 | 
            +
              #          danger.import_dangerfile(url: custom_url)
         | 
| 40 | 
            +
              #
         | 
| 36 41 | 
             
              # @see  danger/danger
         | 
| 37 42 | 
             
              # @tags core, plugins
         | 
| 38 43 |  | 
| @@ -84,8 +89,10 @@ module Danger | |
| 84 89 | 
             
                      import_dangerfile_from_path(opts[:path])
         | 
| 85 90 | 
             
                    elsif opts.key?(:gem)
         | 
| 86 91 | 
             
                      import_dangerfile_from_gem(opts[:gem])
         | 
| 92 | 
            +
                    elsif opts.key?(:url)
         | 
| 93 | 
            +
                      import_dangerfile_from_url(opts[:url])
         | 
| 87 94 | 
             
                    else
         | 
| 88 | 
            -
                      raise "`import` requires a Hash with either :github, :gitlab, :gem, or : | 
| 95 | 
            +
                      raise "`import` requires a Hash with either :github, :gitlab, :gem, :path or :url"
         | 
| 89 96 | 
             
                    end
         | 
| 90 97 | 
             
                  else
         | 
| 91 98 | 
             
                    raise "`import` requires a Hash"
         | 
| @@ -180,6 +187,19 @@ module Danger | |
| 180 187 | 
             
                  @dangerfile.parse(Pathname.new(local_path))
         | 
| 181 188 | 
             
                end
         | 
| 182 189 |  | 
| 190 | 
            +
                # @!group Danger
         | 
| 191 | 
            +
                # Download and execute a remote Dangerfile.
         | 
| 192 | 
            +
                #
         | 
| 193 | 
            +
                # @param    [String] url
         | 
| 194 | 
            +
                #           A https url where the Dangerfile is.
         | 
| 195 | 
            +
                # @return   [void]
         | 
| 196 | 
            +
                #
         | 
| 197 | 
            +
                def import_dangerfile_from_url(url)
         | 
| 198 | 
            +
                  raise "`import_dangerfile_from_url` requires a string" unless url.kind_of?(String)
         | 
| 199 | 
            +
                  local_path = download(url)
         | 
| 200 | 
            +
                  @dangerfile.parse(Pathname.new(local_path))
         | 
| 201 | 
            +
                end
         | 
| 202 | 
            +
             | 
| 183 203 | 
             
                # @!group Plugins
         | 
| 184 204 | 
             
                # Download a local or remote plugin or Dangerfile.
         | 
| 185 205 | 
             
                # This method will not import the file for you, use plugin.import instead
         | 
| @@ -143,6 +143,14 @@ module Danger | |
| 143 143 | 
             
                  @github.issue_json["labels"].map { |l| l[:name] }
         | 
| 144 144 | 
             
                end
         | 
| 145 145 |  | 
| 146 | 
            +
                # @!group PR Metadata
         | 
| 147 | 
            +
                # Whether the PR is a Draft.
         | 
| 148 | 
            +
                # @return [Boolean]
         | 
| 149 | 
            +
                #
         | 
| 150 | 
            +
                def pr_draft?
         | 
| 151 | 
            +
                  pr_json["mergeable_state"] == "draft"
         | 
| 152 | 
            +
                end
         | 
| 153 | 
            +
             | 
| 146 154 | 
             
                # @!group PR Commit Metadata
         | 
| 147 155 | 
             
                # The branch to which the PR is going to be merged into.
         | 
| 148 156 | 
             
                # @return [String]
         | 
| @@ -131,6 +131,14 @@ module Danger | |
| 131 131 | 
             
                  @gitlab.mr_diff
         | 
| 132 132 | 
             
                end
         | 
| 133 133 |  | 
| 134 | 
            +
                # @!group MR Changes
         | 
| 135 | 
            +
                # The array of changes
         | 
| 136 | 
            +
                # @return [Array<Gitlab::ObjectifiedHash>]
         | 
| 137 | 
            +
                #
         | 
| 138 | 
            +
                def mr_changes
         | 
| 139 | 
            +
                  @gitlab.mr_changes.changes
         | 
| 140 | 
            +
                end
         | 
| 141 | 
            +
             | 
| 134 142 | 
             
                # @!group MR Commit Metadata
         | 
| 135 143 | 
             
                # The branch to which the MR is going to be merged into
         | 
| 136 144 | 
             
                # @deprecated Please use {#branch_for_base} instead
         | 
| @@ -19,8 +19,12 @@ module Danger | |
| 19 19 | 
             
                # We need to redirect the self calls to the Dangerfile
         | 
| 20 20 |  | 
| 21 21 | 
             
                # rubocop:disable Style/MethodMissing
         | 
| 22 | 
            -
                def method_missing(method_sym, *arguments, &block)
         | 
| 23 | 
            -
                   | 
| 22 | 
            +
                def method_missing(method_sym, *arguments, **keyword_arguments, &block)
         | 
| 23 | 
            +
                  if keyword_arguments.empty?
         | 
| 24 | 
            +
                    @dangerfile.send(method_sym, *arguments, &block)
         | 
| 25 | 
            +
                  else
         | 
| 26 | 
            +
                    @dangerfile.send(method_sym, *arguments, **keyword_arguments, &block)
         | 
| 27 | 
            +
                  end
         | 
| 24 28 | 
             
                end
         | 
| 25 29 |  | 
| 26 30 | 
             
                def self.all_plugins
         | 
| @@ -57,7 +57,8 @@ module Danger | |
| 57 57 | 
             
                  def fetch_comments
         | 
| 58 58 | 
             
                    values = []
         | 
| 59 59 | 
             
                    # TODO: use a url parts encoder to encode the query
         | 
| 60 | 
            -
                     | 
| 60 | 
            +
                    corrected_uuid = @my_uuid[1...-1] if !@my_uuid.nil? # Endpoint doesnt support curly brackets for this, so remove them for this
         | 
| 61 | 
            +
                    uri = "#{pr_api_endpoint}/comments?pagelen=100&q=deleted+%7E+false+AND+user.uuid+%7E+%22#{corrected_uuid}%22"
         | 
| 61 62 |  | 
| 62 63 | 
             
                    while uri
         | 
| 63 64 | 
             
                      json = fetch_json(URI(uri))
         | 
| @@ -94,12 +95,13 @@ module Danger | |
| 94 95 | 
             
                    "#{base_url(2)}/#{pull_request_id}"
         | 
| 95 96 | 
             
                  end
         | 
| 96 97 |  | 
| 97 | 
            -
                  def  | 
| 98 | 
            -
                     | 
| 98 | 
            +
                  def prs_api_url(branch_name)
         | 
| 99 | 
            +
                    encoded_branch_name = URI.encode_www_form_component(branch_name)
         | 
| 100 | 
            +
                    "#{base_url(2)}?q=source.branch.name=\"#{encoded_branch_name}\""
         | 
| 99 101 | 
             
                  end
         | 
| 100 102 |  | 
| 101 103 | 
             
                  def fetch_pr_from_branch(branch_name)
         | 
| 102 | 
            -
                    uri = URI( | 
| 104 | 
            +
                    uri = URI(prs_api_url(branch_name))
         | 
| 103 105 | 
             
                    fetch_json(uri)[:values][0][:id]
         | 
| 104 106 | 
             
                  end
         | 
| 105 107 |  | 
| @@ -85,7 +85,7 @@ module Danger | |
| 85 85 | 
             
                      if supports_inline_comments
         | 
| 86 86 | 
             
                        @raw_comments = mr_discussions
         | 
| 87 87 | 
             
                          .auto_paginate
         | 
| 88 | 
            -
                          .flat_map { |discussion| discussion.notes.map { |note| note.merge({"discussion_id" => discussion.id}) } }
         | 
| 88 | 
            +
                          .flat_map { |discussion| discussion.notes.map { |note| note.to_h.merge({"discussion_id" => discussion.id}) } }
         | 
| 89 89 | 
             
                        @raw_comments
         | 
| 90 90 | 
             
                          .map { |comment| Comment.from_gitlab(comment) }
         | 
| 91 91 | 
             
                      else
         | 
| @@ -206,10 +206,10 @@ module Danger | |
| 206 206 | 
             
                      markdowns: markdowns
         | 
| 207 207 | 
             
                    )
         | 
| 208 208 |  | 
| 209 | 
            -
                    rest_inline_violations = submit_inline_comments!({
         | 
| 209 | 
            +
                    rest_inline_violations = submit_inline_comments!(**{
         | 
| 210 210 | 
             
                      danger_id: danger_id,
         | 
| 211 211 | 
             
                      previous_violations: previous_violations
         | 
| 212 | 
            -
                    }.merge( | 
| 212 | 
            +
                    }.merge(inline_violations))
         | 
| 213 213 |  | 
| 214 214 | 
             
                    main_violations = merge_violations(
         | 
| 215 215 | 
             
                      regular_violations, rest_inline_violations
         | 
| @@ -224,11 +224,11 @@ module Danger | |
| 224 224 |  | 
| 225 225 | 
             
                    # If there are still violations to show
         | 
| 226 226 | 
             
                    if main_violations_sum.any?
         | 
| 227 | 
            -
                      body = generate_comment({
         | 
| 227 | 
            +
                      body = generate_comment(**{
         | 
| 228 228 | 
             
                        template: "gitlab",
         | 
| 229 229 | 
             
                        danger_id: danger_id,
         | 
| 230 230 | 
             
                        previous_violations: previous_violations
         | 
| 231 | 
            -
                      }.merge( | 
| 231 | 
            +
                      }.merge(main_violations))
         | 
| 232 232 |  | 
| 233 233 | 
             
                      comment_result =
         | 
| 234 234 | 
             
                        if should_create_new_comment
         | 
| @@ -359,7 +359,7 @@ module Danger | |
| 359 359 | 
             
                  def submit_inline_comments!(warnings: [], errors: [], messages: [], markdowns: [], previous_violations: [], danger_id: "danger")
         | 
| 360 360 | 
             
                    comments = mr_discussions
         | 
| 361 361 | 
             
                      .auto_paginate
         | 
| 362 | 
            -
                      .flat_map { |discussion| discussion.notes.map { |note| note.merge({"discussion_id" => discussion.id}) } }
         | 
| 362 | 
            +
                      .flat_map { |discussion| discussion.notes.map { |note| note.to_h.merge({"discussion_id" => discussion.id}) } }
         | 
| 363 363 | 
             
                      .select { |comment| Comment.from_gitlab(comment).inline? }
         | 
| 364 364 |  | 
| 365 365 | 
             
                    danger_comments = comments.select { |comment| Comment.from_gitlab(comment).generated_by_danger?(danger_id) }
         | 
| @@ -410,7 +410,7 @@ module Danger | |
| 410 410 | 
             
                      next false unless m.file && m.line
         | 
| 411 411 | 
             
                      # Reject if it's out of range and in dismiss mode
         | 
| 412 412 | 
             
                      next true if dismiss_out_of_range_messages_for(kind) && is_out_of_range(mr_changes.changes, m)
         | 
| 413 | 
            -
             | 
| 413 | 
            +
             | 
| 414 414 | 
             
                      # Once we know we're gonna submit it, we format it
         | 
| 415 415 | 
             
                      if is_markdown_content
         | 
| 416 416 | 
             
                        body = generate_inline_markdown_body(m, danger_id: danger_id, template: "gitlab")
         | 
| @@ -531,10 +531,10 @@ module Danger | |
| 531 531 | 
             
                  end
         | 
| 532 532 |  | 
| 533 533 | 
             
                  def is_out_of_range(changes, message)
         | 
| 534 | 
            -
                    change = changes.find { |c| c["new_path"] == message.file } | 
| 534 | 
            +
                    change = changes.find { |c| c["new_path"] == message.file }
         | 
| 535 535 | 
             
                    # If there is no changes or rename only or deleted, return out of range.
         | 
| 536 536 | 
             
                    return true if change.nil? || change["diff"].empty? || change["deleted_file"]
         | 
| 537 | 
            -
             | 
| 537 | 
            +
             | 
| 538 538 | 
             
                    # If new file then return in range
         | 
| 539 539 | 
             
                    return false if change["new_file"]
         | 
| 540 540 |  | 
| @@ -544,7 +544,7 @@ module Danger | |
| 544 544 | 
             
                    return true
         | 
| 545 545 | 
             
                  end
         | 
| 546 546 |  | 
| 547 | 
            -
                  def generate_addition_lines(diff) | 
| 547 | 
            +
                  def generate_addition_lines(diff)
         | 
| 548 548 | 
             
                    range_header_regexp = /@@ -(?<old>[0-9]+)(,([0-9]+))? \+(?<new>[0-9]+)(,([0-9]+))? @@.*/
         | 
| 549 549 | 
             
                    addition_lines = []
         | 
| 550 550 | 
             
                    line_number = 0
         | 
    
        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: 8.1 | 
| 4 | 
            +
              version: 8.3.1
         | 
| 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: 2021-07-01 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: claide
         | 
| @@ -147,16 +147,22 @@ dependencies: | |
| 147 147 | 
             
              name: terminal-table
         | 
| 148 148 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 149 149 | 
             
                requirements:
         | 
| 150 | 
            -
                - - " | 
| 150 | 
            +
                - - ">="
         | 
| 151 151 | 
             
                  - !ruby/object:Gem::Version
         | 
| 152 152 | 
             
                    version: '1'
         | 
| 153 | 
            +
                - - "<"
         | 
| 154 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 155 | 
            +
                    version: '4'
         | 
| 153 156 | 
             
              type: :runtime
         | 
| 154 157 | 
             
              prerelease: false
         | 
| 155 158 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 156 159 | 
             
                requirements:
         | 
| 157 | 
            -
                - - " | 
| 160 | 
            +
                - - ">="
         | 
| 158 161 | 
             
                  - !ruby/object:Gem::Version
         | 
| 159 162 | 
             
                    version: '1'
         | 
| 163 | 
            +
                - - "<"
         | 
| 164 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 165 | 
            +
                    version: '4'
         | 
| 160 166 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 161 167 | 
             
              name: cork
         | 
| 162 168 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -213,7 +219,9 @@ files: | |
| 213 219 | 
             
            - lib/danger/ci_source/cirrus.rb
         | 
| 214 220 | 
             
            - lib/danger/ci_source/code_build.rb
         | 
| 215 221 | 
             
            - lib/danger/ci_source/codefresh.rb
         | 
| 222 | 
            +
            - lib/danger/ci_source/codemagic.rb
         | 
| 216 223 | 
             
            - lib/danger/ci_source/codeship.rb
         | 
| 224 | 
            +
            - lib/danger/ci_source/concourse.rb
         | 
| 217 225 | 
             
            - lib/danger/ci_source/dotci.rb
         | 
| 218 226 | 
             
            - lib/danger/ci_source/drone.rb
         | 
| 219 227 | 
             
            - lib/danger/ci_source/github_actions.rb
         |