danger 5.4.2 → 5.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d04283da3fa8e50e227373054bb223aecaaff4bc
4
- data.tar.gz: d049f4c7a0cf5c6084ea21fa2fe4dcb7984af51e
3
+ metadata.gz: 46b84e6217c921dda10765acbe116a3da6ee00cd
4
+ data.tar.gz: 558617a4e1e01d226d08e9f6170641ddcd0cedb8
5
5
  SHA512:
6
- metadata.gz: fd5ad732b063a7c0ccf1bd91cb81bc13c01c280704d6014cf8f94059c9b21c4aa4d5404432f76e1b2adcd2cd716f979527439981008e4b87e110063fc8895023
7
- data.tar.gz: 889bcd7426555538a4f146f1c89714b08ee10dfbc43ae1e63da8ee94bf317effb71356b2964e55c471e06582121300c6d720b23be96e2525b63cd758e4aebf5e
6
+ metadata.gz: 3bd2d6c49555450e934aa5ac675b4db0eb658ce7571dda6699564ff479fd1e7e360339a441ad6da45850869c7871d38ebfa8febcd118944381d852f1f302a8c0
7
+ data.tar.gz: dc2616251d6a850d51387a6d18111a8ba23e49f7cbdaeec631d5669acde68397cf3a11c97efea57db4ebf3476d73ce5d2b3f307c6330356f5a2637dafd74e2fe
@@ -0,0 +1,44 @@
1
+ # https://semaphoreci.com/docs/available-environment-variables.html
2
+ require "danger/request_sources/github/github"
3
+
4
+ module Danger
5
+ # ### CI Setup
6
+ #
7
+ # In Codeship, go to your "Project Settings", then add `bundle exec danger` as a test step inside
8
+ # one of your pipelines.
9
+ #
10
+ # ### Token Setup
11
+ #
12
+ # Add your `DANGER_GITHUB_API_TOKEN` to "Environment" section in "Project Settings".
13
+ #
14
+ class Codeship < CI
15
+ def self.validates_as_ci?(env)
16
+ env["CI_NAME"] == "codeship"
17
+ end
18
+
19
+ def self.validates_as_pr?(env)
20
+ return false unless env["CI_BRANCH"] && !env["CI_BRANCH"].empty?
21
+
22
+ !pr_from_env(env).nil?
23
+ end
24
+
25
+ def self.owner_for_github(env)
26
+ env["CI_REPO_NAME"].split("/").first
27
+ end
28
+
29
+ # this is fairly hacky, see https://github.com/danger/danger/pull/892#issuecomment-329030616 for why
30
+ def self.pr_from_env(env)
31
+ Danger::RequestSources::GitHub.new(nil, env).get_pr_from_branch(env["CI_REPO_NAME"], env["CI_BRANCH"], owner_for_github(env))
32
+ end
33
+
34
+ def supported_request_sources
35
+ @supported_request_sources ||= [Danger::RequestSources::GitHub]
36
+ end
37
+
38
+ def initialize(env)
39
+ self.repo_slug = env["CI_REPO_NAME"]
40
+ self.pull_request_id = self.class.pr_from_env(env)
41
+ self.repo_url = GitRepo.new.origins
42
+ end
43
+ end
44
+ end
@@ -4,7 +4,7 @@ require "danger/request_sources/github/github"
4
4
  module Danger
5
5
  # ### CI Setup
6
6
  #
7
- # For Semaphor you will want to go to the settings page of the project. Inside "Build Settings"
7
+ # For Semaphore you will want to go to the settings page of the project. Inside "Build Settings"
8
8
  # you should add `bundle exec danger` to the Setup thread. Note that Semaphore only provides
9
9
  # the build environment variables necessary for Danger on PRs across forks.
10
10
  #
@@ -33,6 +33,13 @@ module Danger
33
33
  @token = @environment["DANGER_GITHUB_API_TOKEN"]
34
34
  end
35
35
 
36
+ def get_pr_from_branch(repo_name, branch_name, owner)
37
+ prs = client.pull_requests(repo_name, head: "#{owner}:#{branch_name}")
38
+ unless prs.empty?
39
+ prs.first.number
40
+ end
41
+ end
42
+
36
43
  def validates_as_api_source?
37
44
  (@token && !@token.empty?) || self.environment["DANGER_USE_LOCAL_GIT"]
38
45
  end
@@ -1,4 +1,4 @@
1
1
  module Danger
2
- VERSION = "5.4.2".freeze
2
+ VERSION = "5.4.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: 5.4.2
4
+ version: 5.4.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: 2017-09-13 00:00:00.000000000 Z
12
+ date: 2017-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: claide
@@ -381,6 +381,7 @@ files:
381
381
  - lib/danger/ci_source/ci_source.rb
382
382
  - lib/danger/ci_source/circle.rb
383
383
  - lib/danger/ci_source/circle_api.rb
384
+ - lib/danger/ci_source/codeship.rb
384
385
  - lib/danger/ci_source/dotci.rb
385
386
  - lib/danger/ci_source/drone.rb
386
387
  - lib/danger/ci_source/gitlab_ci.rb
@@ -486,7 +487,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
486
487
  version: '0'
487
488
  requirements: []
488
489
  rubyforge_project:
489
- rubygems_version: 2.6.8
490
+ rubygems_version: 2.6.13
490
491
  signing_key:
491
492
  specification_version: 4
492
493
  summary: Like Unit Tests, but for your Team Culture.