lib/danger/ci_source/gitlab_ci.rb in danger-5.11.1 vs lib/danger/ci_source/gitlab_ci.rb in danger-5.12.0
- old
+ new
@@ -30,14 +30,14 @@
exists && determine_merge_request_id(env).to_i > 0
end
def self.determine_merge_request_id(env)
- return env["CI_MERGE_REQUEST_ID"] if env["CI_MERGE_REQUEST_ID"]
+ return env["CI_MERGE_REQUEST_IID"] if env["CI_MERGE_REQUEST_IID"]
return 0 unless env["CI_COMMIT_SHA"]
- project_path = env["CI_PROJECT_PATH"]
+ project_path = env["CI_MERGE_REQUEST_PROJECT_PATH"] || env["CI_PROJECT_PATH"]
base_commit = env["CI_COMMIT_SHA"]
client = RequestSources::GitLab.new(nil, env).client
merge_requests = client.merge_requests(project_path, state: :opened)
merge_request = merge_requests.auto_paginate.find do |mr|
@@ -47,11 +47,11 @@
merge_request.nil? ? 0 : merge_request.iid
end
def initialize(env)
@env = env
- @repo_slug = env["CI_PROJECT_PATH"]
- @project_url = env["CI_PROJECT_URL"]
+ @repo_slug = env["CI_MERGE_REQUEST_PROJECT_PATH"] || env["CI_PROJECT_PATH"]
+ @project_url = env["CI_MERGE_REQUEST_PROJECT_URL"] || env["CI_PROJECT_URL"]
end
def supported_request_sources
@supported_request_sources ||= [Danger::RequestSources::GitLab]
end