danger 8.0.2 → 8.0.3

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: fbea5f64686dec7d5badd386c112577a626fb35bea77852a15e3b420e846ce89
4
- data.tar.gz: 4e32c0d00be5247ef8c0c33383c49bbb4dcd0d51fe48ea75916d3a61f85d5708
3
+ metadata.gz: f89ff08f152cedf23e9fcb48adc8b256ddb1ef8992c682bb6ad6ef1620ba1f5f
4
+ data.tar.gz: d9f689cd3b403177e3475d364f2aebe5b49a78e72eebfaeab49fad8d6ec3f619
5
5
  SHA512:
6
- metadata.gz: 14aaf58cf077d3e316d17ab73d1b27378ad71d284f87c6c80cfd3b0cb24aeaea7862a8a3ddf0f4a3a8d883ee8225d36f8c242576be18d3c44ce40c6181d2dfbe
7
- data.tar.gz: f832a4990da69caf5c001fdc6b4ee3231fe8a4199924bbff695725f89f29a887e54d449ad51989d80a8e29478a85775acafb0c1031b3d7f515acc519a311e39f
6
+ metadata.gz: 9b1db5d7f0ed5106614a967c5bd45cdb8b896327f29512d259f662c0ad994438bb2c9240c122aab93f228eb21bf2f80029d6cf851d7f315f7559e491aa60cb04
7
+ data.tar.gz: 51413afca0478a350693672cb831e67e5ed92ff5a6d026caa805bdb58ff09bf7b8bfbbdd5cfc16c83878d8164af26088036fbc5aa354d57c990c75dcb15f8f6f
@@ -1,5 +1,6 @@
1
1
  # http://docs.gitlab.com/ce/ci/variables/README.html
2
2
  require "uri"
3
+ require "danger/request_sources/github/github"
3
4
  require "danger/request_sources/gitlab"
4
5
 
5
6
  module Danger
@@ -15,10 +16,13 @@ module Danger
15
16
  # ```
16
17
  # ### Token Setup
17
18
  #
18
- # Add the `DANGER_GITLAB_API_TOKEN` to your pipeline env variables.
19
- class GitLabCI < CI
20
- attr_reader :project_url
19
+ # Add the `DANGER_GITLAB_API_TOKEN` to your pipeline env variables if you
20
+ # are hosting your code on GitLab. If you are using GitLab as a mirror
21
+ # for the purpose of CI/CD, while hosting your repo on GitHub, set the
22
+ # `DANGER_GITHUB_API_TOKEN` as well as the project repo URL to
23
+ # `DANGER_PROJECT_REPO_URL`.
21
24
 
25
+ class GitLabCI < CI
22
26
  def self.validates_as_ci?(env)
23
27
  env.key? "GITLAB_CI"
24
28
  end
@@ -28,11 +32,12 @@ module Danger
28
32
  "GITLAB_CI", "CI_PROJECT_PATH"
29
33
  ].all? { |x| env[x] }
30
34
 
31
- exists && determine_merge_request_id(env).to_i > 0
35
+ exists && determine_pull_or_merge_request_id(env).to_i > 0
32
36
  end
33
37
 
34
- def self.determine_merge_request_id(env)
38
+ def self.determine_pull_or_merge_request_id(env)
35
39
  return env["CI_MERGE_REQUEST_IID"] if env["CI_MERGE_REQUEST_IID"]
40
+ return env["CI_EXTERNAL_PULL_REQUEST_IID"] if env["CI_EXTERNAL_PULL_REQUEST_IID"]
36
41
  return 0 unless env["CI_COMMIT_SHA"]
37
42
 
38
43
  project_path = env["CI_MERGE_REQUEST_PROJECT_PATH"] || env["CI_PROJECT_PATH"]
@@ -54,16 +59,28 @@ module Danger
54
59
 
55
60
  def initialize(env)
56
61
  @env = env
57
- @repo_slug = env["CI_MERGE_REQUEST_PROJECT_PATH"] || env["CI_PROJECT_PATH"]
58
- @project_url = env["CI_MERGE_REQUEST_PROJECT_URL"] || env["CI_PROJECT_URL"]
62
+ @repo_slug = slug_from(env)
59
63
  end
60
64
 
61
65
  def supported_request_sources
62
- @supported_request_sources ||= [Danger::RequestSources::GitLab]
66
+ @supported_request_sources ||= [
67
+ Danger::RequestSources::GitHub,
68
+ Danger::RequestSources::GitLab
69
+ ]
63
70
  end
64
71
 
65
72
  def pull_request_id
66
- @pull_request_id ||= self.class.determine_merge_request_id(@env)
73
+ @pull_request_id ||= self.class.determine_pull_or_merge_request_id(@env)
74
+ end
75
+
76
+ private
77
+
78
+ def slug_from(env)
79
+ if env["DANGER_PROJECT_REPO_URL"]
80
+ env["DANGER_PROJECT_REPO_URL"].split('/').last(2).join('/')
81
+ else
82
+ env["CI_MERGE_REQUEST_PROJECT_PATH"] || env["CI_PROJECT_PATH"]
83
+ end
67
84
  end
68
85
  end
69
86
  end
@@ -40,6 +40,10 @@ module Danger
40
40
  end
41
41
  end
42
42
 
43
+ def validates_as_ci?
44
+ true
45
+ end
46
+
43
47
  def validates_as_api_source?
44
48
  (@token && !@token.empty?) || self.environment["DANGER_USE_LOCAL_GIT"]
45
49
  end
@@ -135,7 +135,7 @@ module Danger
135
135
  git_in_depth_fetch
136
136
  possible_merge_base = possible_merge_base(repo, from, to)
137
137
 
138
- raise "Cannot find a merge base between #{from} and #{to}." unless possible_merge_base
138
+ raise "Cannot find a merge base between #{from} and #{to}. If you are using shallow clone/fetch, try increasing the --depth" unless possible_merge_base
139
139
 
140
140
  possible_merge_base
141
141
  end
@@ -1,4 +1,4 @@
1
1
  module Danger
2
- VERSION = "8.0.2".freeze
2
+ VERSION = "8.0.3".freeze
3
3
  DESCRIPTION = "Like Unit Tests, but for your Team Culture.".freeze
4
4
  end
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.0.2
4
+ version: 8.0.3
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: 2020-06-17 00:00:00.000000000 Z
12
+ date: 2020-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: claide