travis_dedup 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddfa4b36cc617cc7d75d5d12fe29c40c41505dca
4
- data.tar.gz: 4e76c33380702e5c8957fc90bea2b53c4b96a7d7
3
+ metadata.gz: 5210a0ce08c73a328b8750ea3c3d2a90e08a5faf
4
+ data.tar.gz: 66730dcf69f6df6c030833d6e25c5e8fd63d9abc
5
5
  SHA512:
6
- metadata.gz: bf536a18ab05bf5415784f8806ce664de30b559a798cff3220cfab8ecf11b27065756626fdbe5a1a36c99e2f06a6bae3cebde28989801ec7a56135773925dcc2
7
- data.tar.gz: 9542850c39a406e3bff9e728c7c9c354b3abae493f0b9d80572552b18980eb0f7f21c13300e17db5ec0960dc2f5859237af831f835b413e67a4319610582050e
6
+ metadata.gz: 29c4bf6061e0e9645760eb76a7a789ef0243c89564cc6bdfbb0ba042284b56bdc1f3309049a13ab4da5d1dda0a41005d4cf523e9cc208160af116a4473f6dc76
7
+ data.tar.gz: e3b045c9d68737736c12246e94a946caaa5fe33350823293644b7dbfab13ce832e1e314a0b6345696138ec32f376fffbdcc31ad3f4aea082dcc714f6c87adcce
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # enable local usage from cloned repo
4
+ root = File.expand_path("../..", __FILE__)
5
+ $LOAD_PATH << "#{root}/lib" if File.exist?("#{root}/Gemfile")
6
+
7
+ require "travis_dedup"
8
+
9
+ exit TravisDedup.cli(ARGV)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module TravisDedup
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.1
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