concourse-github-status 0.2.4 → 0.3.0

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
  SHA1:
3
- metadata.gz: 892aa1f4770c7ad1279e6cd534f9027c8990cb9a
4
- data.tar.gz: fee96e8be52180a4ced6a83f10ac0b1b6f86eb0f
3
+ metadata.gz: 41979e18c541ff109e68893578deb65002b4e517
4
+ data.tar.gz: a0ddd866017a4149133ae550bcbff0debc28a77f
5
5
  SHA512:
6
- metadata.gz: c39f6ea2fe317075f688928cfcc12e4aee79a58908dc3cbd8c9c4d458fd7072ebbfbee471811f9f3f6f8c3dfa585f2ccb9a0f4c40433e333b67aa789cdb3ce4d
7
- data.tar.gz: 25380ea07127d3331921431c1ff27400045bf54d5d5128e53b11d50e23443e4654f3f64571d776c78c539e5486d97025223c274adf19756b3540a7d8f55d00a7
6
+ metadata.gz: b18a21c6b3982cca268cbb42a074946145300841e1d9fc21b6b406b3a3d59ecb96091153b15babb46d142d141466f0111b19b84f2df6eead2cdca636589b0e61
7
+ data.tar.gz: 79c64de2b16e7d3678c884cc6bbb6b045109d467b67208432f88715ff70598f0b168d567bcf8531c79c1894f63518af40491609b09faee7f1392e97594244b2f
data/README.org CHANGED
@@ -42,7 +42,12 @@ Add the resource to your pipeline's ~resource_types~ (requires Concourse 0.74.0+
42
42
  | description | No | | A description of the context. |
43
43
  |-------------+----------+-----------+--------------------------------------------|
44
44
 
45
- ** ~check~ Not Implemented
45
+ ** ~check~ Get a list of available statuses
46
+
47
+ *** Parameters
48
+
49
+ - None
50
+
46
51
  ** ~in~ Not Implemented
47
52
 
48
53
  * License
data/bin/check CHANGED
@@ -1,3 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- STDERR.puts 'Not Implemented'
3
+ require 'github-status/check'
4
+
5
+ check = GitHubStatus::Check.new
6
+
7
+ unless check.run
8
+ STDERR.puts "Failed to fetch status"
9
+ abort
10
+ end
data/lib/github-status.rb CHANGED
@@ -1,4 +1,5 @@
1
1
 
2
+ require_relative 'github-status/check'
2
3
  require_relative 'github-status/in'
3
4
  require_relative 'github-status/out'
4
5
  require_relative 'github-status/version'
@@ -0,0 +1,37 @@
1
+ require 'concourse-fuselage'
2
+ require_relative 'core'
3
+ require_relative 'support/github'
4
+
5
+ module GitHubStatus
6
+ class Check < Fuselage::Check
7
+ include Core
8
+ include Support::GitHub
9
+
10
+ Contract HashOf[String, String] => String
11
+ def to_sha(version)
12
+ @sha ||= version.fetch('context@sha') { commit }.split('@').last
13
+ end
14
+
15
+ Contract None => Time
16
+ def date(sha)
17
+ @date ||= github.commit(repo, sha).commit.author.date
18
+ end
19
+
20
+ Contract None => String
21
+ def commit
22
+ @commit ||= github.branch(repo, branch).commit.sha
23
+ end
24
+
25
+ Contract None => HashOf[String, String]
26
+ def latest
27
+ { 'context@sha' => "concourseci@#{sha}" }
28
+ end
29
+
30
+ Contract HashOf[String, String] => ArrayOf[HashOf[String, String]]
31
+ def since(version)
32
+ github
33
+ .commits_since(repo, date(to_sha(version)))
34
+ .map { |commit| { 'context@sha' => "concourseci@#{commit[:sha]}" } }
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module GitHubStatus
2
- VERSION = '0.2.4'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concourse-github-status
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Olstrom
@@ -90,6 +90,7 @@ files:
90
90
  - bin/out
91
91
  - concourse-github-status.gemspec
92
92
  - lib/github-status.rb
93
+ - lib/github-status/check.rb
93
94
  - lib/github-status/core.rb
94
95
  - lib/github-status/in.rb
95
96
  - lib/github-status/out.rb