travis_dedup 0.3.0 → 0.4.0
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/lib/travis_dedup.rb +14 -6
- data/lib/travis_dedup/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04603ba6cc68114fb41abe32e6a7f13d17891d1e
|
4
|
+
data.tar.gz: 7efca7ec8c3752a5ed4db4801c8c0508cfbf740e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5860acfa91d3c46a7e44bf7b5b97fda4a096cfc87991c57e019c51f22c389c0d004df4f0d4484d5ef7026a93bd7ed30bf53c15c1a76470810e069c61ba6a71bb
|
7
|
+
data.tar.gz: efef33df8b0cc3c3ebbd8f00dca972cd9941de7b240210a6e2579e64a504ad2326a469adb38043f4f24fa4013c5a00fd19b0a2628cabb41f642fae7ce76ce529
|
data/lib/travis_dedup.rb
CHANGED
@@ -6,7 +6,7 @@ module TravisDedup
|
|
6
6
|
ACTIVE = %w[created started queued]
|
7
7
|
|
8
8
|
class << self
|
9
|
-
attr_accessor :pro, :verbose
|
9
|
+
attr_accessor :pro, :verbose, :branches
|
10
10
|
|
11
11
|
def cli(argv)
|
12
12
|
parser = OptionParser.new do |opts|
|
@@ -19,6 +19,7 @@ module TravisDedup
|
|
19
19
|
Options:
|
20
20
|
BANNER
|
21
21
|
opts.on("--pro", "travis pro") { self.pro = true }
|
22
|
+
opts.on("--branches", "dedup builds on branches too") { self.branches = true }
|
22
23
|
opts.on("-h", "--help","Show this") { puts opts; exit }
|
23
24
|
opts.on('-v', '--version','Show Version'){ require 'travis_dedup/version'; puts TravisDedup::VERSION; exit}
|
24
25
|
end
|
@@ -63,19 +64,26 @@ module TravisDedup
|
|
63
64
|
def duplicate_builds(builds)
|
64
65
|
seen = []
|
65
66
|
builds.select do |build|
|
66
|
-
|
67
|
-
|
67
|
+
pr = build.fetch "pull_request_number"
|
68
|
+
branch = build.fetch "branch"
|
69
|
+
|
70
|
+
next if !pr && !branches
|
71
|
+
|
72
|
+
id = pr || branch
|
73
|
+
if seen.include?(id)
|
68
74
|
true
|
69
75
|
else
|
70
|
-
seen <<
|
76
|
+
seen << id
|
71
77
|
false
|
72
78
|
end
|
73
79
|
end
|
74
80
|
end
|
75
81
|
|
82
|
+
# see http://docs.travis-ci.com/api/#builds
|
76
83
|
def active_builds(repo, access_token)
|
77
|
-
request(:get, "repos/#{repo}/builds", {}, headers(access_token))
|
78
|
-
|
84
|
+
response = request(:get, "repos/#{repo}/builds", {}, headers(access_token))
|
85
|
+
builds = response.fetch("builds").select { |b| ACTIVE.include?(b.fetch("state")) }
|
86
|
+
builds.each { |build| build["branch"] = response.fetch("commits").detect { |c| c["id"] == build["commit_id"] }.fetch("branch") }
|
79
87
|
end
|
80
88
|
|
81
89
|
def headers(access_token)
|
data/lib/travis_dedup/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travis_dedup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|