travis_dedup 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/travis-dedup +9 -0
- data/lib/travis_dedup.rb +28 -1
- data/lib/travis_dedup/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5210a0ce08c73a328b8750ea3c3d2a90e08a5faf
|
4
|
+
data.tar.gz: 66730dcf69f6df6c030833d6e25c5e8fd63d9abc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29c4bf6061e0e9645760eb76a7a789ef0243c89564cc6bdfbb0ba042284b56bdc1f3309049a13ab4da5d1dda0a41005d4cf523e9cc208160af116a4473f6dc76
|
7
|
+
data.tar.gz: e3b045c9d68737736c12246e94a946caaa5fe33350823293644b7dbfab13ce832e1e314a0b6345696138ec32f376fffbdcc31ad3f4aea082dcc714f6c87adcce
|
data/bin/travis-dedup
ADDED
data/lib/travis_dedup.rb
CHANGED
@@ -1,10 +1,38 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
require 'json'
|
3
|
+
require 'optparse'
|
3
4
|
|
4
5
|
module TravisDedup
|
5
6
|
class << self
|
6
7
|
attr_accessor :pro
|
7
8
|
|
9
|
+
def cli(argv)
|
10
|
+
parser = OptionParser.new do |opts|
|
11
|
+
opts.banner = <<-BANNER.gsub(/^ /, "")
|
12
|
+
Stop all builds on the same PR when a new job starts.
|
13
|
+
|
14
|
+
Usage:
|
15
|
+
travis-dedup your_org/your_repo $TRAVIS_ACCESS_TOKEN --pro
|
16
|
+
|
17
|
+
Options:
|
18
|
+
BANNER
|
19
|
+
opts.on("--pro", "travis pro") { self.pro = true }
|
20
|
+
opts.on("-h", "--help","Show this") { puts opts; exit }
|
21
|
+
opts.on('-v', '--version','Show Version'){ require 'travis_dedup/version'; puts TravisDedup::VERSION; exit}
|
22
|
+
end
|
23
|
+
parser.parse!(argv)
|
24
|
+
|
25
|
+
unless argv.size == 2
|
26
|
+
puts parser
|
27
|
+
return 1
|
28
|
+
end
|
29
|
+
|
30
|
+
canceled = dedup(*argv)
|
31
|
+
canceled = (canceled.any? ? canceled.map { |b| b.fetch("id") }.join(", ") : "None")
|
32
|
+
puts "Builds canceled: #{canceled}"
|
33
|
+
0
|
34
|
+
end
|
35
|
+
|
8
36
|
def dedup(repo, access_token)
|
9
37
|
headers = {
|
10
38
|
"Authorization" => %{token "#{access_token}"},
|
@@ -18,7 +46,6 @@ module TravisDedup
|
|
18
46
|
pr = build.fetch("pull_request_number")
|
19
47
|
id = build.fetch("id")
|
20
48
|
if seen.include?(pr)
|
21
|
-
puts "Canceling build #{id}"
|
22
49
|
request :post, "builds/#{id}/cancel", {}, headers
|
23
50
|
true
|
24
51
|
else
|
data/lib/travis_dedup/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travis_dedup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
@@ -40,10 +40,12 @@ dependencies:
|
|
40
40
|
version: '0'
|
41
41
|
description:
|
42
42
|
email: michael@grosser.it
|
43
|
-
executables:
|
43
|
+
executables:
|
44
|
+
- travis-dedup
|
44
45
|
extensions: []
|
45
46
|
extra_rdoc_files: []
|
46
47
|
files:
|
48
|
+
- bin/travis-dedup
|
47
49
|
- lib/travis_dedup.rb
|
48
50
|
- lib/travis_dedup/version.rb
|
49
51
|
homepage: https://github.com/grosser/travis_dedup
|