homebrew_automation 0.1.10 → 0.1.17

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
  SHA256:
3
- metadata.gz: 0a7e329d80eca725cc1e67b8b6adc44be6abcc8188a1667bf68d03221f7132d3
4
- data.tar.gz: be1c89833487aea65a54fc4b87c5dfd2299469fd9cecc2739c5d44c4e0513c9f
3
+ metadata.gz: 631a391dc1b239b9195b9dd9ae7dfe554a9d622afd3437b672716e27d599b70a
4
+ data.tar.gz: 0c40e8267deb8365212d2b60d976fadbf52c81c685fdba2d1404f473b8564405
5
5
  SHA512:
6
- metadata.gz: 30421bf2d3dfd26da1cbdbaedae7b37793533a587677aea855e6c7c01c5d3d0a522cd86703dc2d1abe02d02b14ff3213e7e01887ea6ee20f849d9f34be11768c
7
- data.tar.gz: 4eb44efc9e0bcc0bb16bdc6c1c44a9804602a376e533e49bd2060aa75ba236142a00b726fa2c519f6a04d1d9d714da02e943fae618f541441da49da1f7e800bd
6
+ metadata.gz: 302c739c1028ac4255fb2bd9e15e9f2979cc0df5dd67704795d6fcb3a58f391c790763813b83bc2242a40e9fb5eedf2f5bb8e3fab60a73523ab895130117a10c
7
+ data.tar.gz: f9f41c0cee062f606391ac04e28739754c027c6b6cb6eb9643dca876b7b1dc26c2fb9a593debaebb54215bc3b1c855414cecaeff07148b884a81dc89a70809c9
@@ -86,7 +86,7 @@ module HomebrewAutomation::Bintray
86
86
  safe_pkg = URI.escape(package_name)
87
87
  safe_ver = URI.escape(version_name)
88
88
  @http.get(
89
- rel("/packages/#{safe_username}/#{safe_repo}/#{safe_pkg}/versions/#{safe_ver}/files"),
89
+ rel("/packages/#{safe_username}/#{safe_repo}/#{safe_pkg}/versions/#{safe_ver}/files?include_unpublished=1"),
90
90
  auth_headers)
91
91
  end
92
92
 
@@ -16,11 +16,13 @@ module HomebrewAutomation::Bintray
16
16
  end
17
17
 
18
18
  # @param client [Client] Connection to Bintray servers
19
+ # @param logger [HomebrewAutomation::Logger]
19
20
  # @param repo_name [String]
20
21
  # @param package_name [String]
21
22
  # @param version_name [String]
22
- def initialize(client, repo_name, package_name, version_name)
23
+ def initialize(client, logger, repo_name, package_name, version_name)
23
24
  @client = client
25
+ @logger = logger
24
26
  @repo_name = repo_name
25
27
  @package_name = package_name
26
28
  @version_name = version_name
@@ -67,12 +69,13 @@ module HomebrewAutomation::Bintray
67
69
  resp = @client.get_all_files_in_version(@repo_name, @package_name, @version_name)
68
70
  _assert_match((200..207), resp.code)
69
71
  json = JSON.parse(resp.body)
72
+ @logger.info!("All files in Bintray Version: #{json}")
70
73
  _assert_match(Array, json)
71
74
  pairs = json.map do |f|
72
75
  os = _parse_for_os(f['name'])
73
76
  checksum = f['sha256']
74
77
  [os, checksum]
75
- end
78
+ end.select { |o, _| not o.empty? }
76
79
  Hash[pairs]
77
80
  end
78
81
 
@@ -81,7 +81,9 @@ module HomebrewAutomation
81
81
  begin
82
82
  @brew.tap!(@tap_name, @tap_url)
83
83
  tapped = true
84
+ # TODO: @brew.list! may print a worrying "Error" message if Formula wasn't installed:
84
85
  if @brew.list!([], fully_qualified_formula_name)
86
+ # TODO: This doesn't seem to work. Carefully test.
85
87
  # passing `--force` to uninstall all versions
86
88
  @brew.uninstall!(['--force'], fully_qualified_formula_name)
87
89
  end
@@ -52,7 +52,9 @@ class HomebrewAutomation::CLI::WorkflowCommands < Thor
52
52
  sdist,
53
53
  tap,
54
54
  formula_name,
55
- bintray_version)
55
+ bintray_version,
56
+ git,
57
+ logger)
56
58
  end
57
59
 
58
60
  private
@@ -90,6 +92,7 @@ class HomebrewAutomation::CLI::WorkflowCommands < Thor
90
92
  def bintray_version
91
93
  HomebrewAutomation::Bintray::Version.new(
92
94
  bintray_client,
95
+ logger,
93
96
  options[:bintray_repo] || "homebrew-bottles",
94
97
  options[:bintray_package] || sdist.repo,
95
98
  options[:bintray_version] || sdist.tag.sub(/^v/, ''))
@@ -49,7 +49,7 @@ module HomebrewAutomation
49
49
  # @param keep_dir [Boolean]
50
50
  # @yieldparam dir [String] name of freshly cloned dir
51
51
  # @yieldreturn [a] anything
52
- # @return [a]
52
+ # @return [NilClass]
53
53
  def with_clone!(url, dir, keep_dir: false, &block)
54
54
  begin
55
55
  clone! url, dir: dir
@@ -31,7 +31,9 @@ module HomebrewAutomation
31
31
  /^10.10/ => 'yosemite',
32
32
  /^10.11/ => 'el_capitan',
33
33
  /^10.12/ => 'sierra',
34
- /^10.13/ => 'high_sierra'
34
+ /^10.13/ => 'high_sierra',
35
+ /^10.14/ => 'mojave',
36
+ /^10.15/ => 'catalina'
35
37
  }
36
38
  end
37
39
 
@@ -6,6 +6,9 @@ module HomebrewAutomation
6
6
  # A representation of a source distribution tarball file
7
7
  class SourceDist
8
8
 
9
+ class Error < StandardError
10
+ end
11
+
9
12
  # Assign args to attributes {#user}, {#repo}, {#tag}
10
13
  def initialize user, repo, tag, http: RestClient
11
14
  @user = user
@@ -38,6 +41,9 @@ module HomebrewAutomation
38
41
  @sha256 ||= Digest::SHA256.hexdigest contents
39
42
  end
40
43
 
44
+ class SdistDoesNotExist < StandardError
45
+ end
46
+
41
47
  # Download and return the file contents.
42
48
  #
43
49
  # Lazy and memoized.
@@ -51,9 +57,10 @@ module HomebrewAutomation
51
57
  when 200
52
58
  resp.body.to_s
53
59
  else
54
- puts resp
55
- raise StandardError.new resp.code
60
+ raise Error.new "Other error: HTTP #{resp.code}"
56
61
  end
62
+ rescue RestClient::NotFound
63
+ raise SdistDoesNotExist.new
57
64
  end
58
65
  end
59
66
 
@@ -2,6 +2,6 @@
2
2
  module HomebrewAutomation
3
3
 
4
4
  # Yep.
5
- VERSION = '0.1.10'
5
+ VERSION = '0.1.17'
6
6
 
7
7
  end
@@ -1,6 +1,9 @@
1
1
 
2
2
  require_relative './mac_os.rb'
3
3
  require_relative './bottle.rb'
4
+ require_relative './brew.rb'
5
+ require_relative './git.rb'
6
+ require_relative './source_dist.rb'
4
7
 
5
8
  module HomebrewAutomation
6
9
 
@@ -40,6 +43,7 @@ module HomebrewAutomation
40
43
  "bottles to Bintray.")
41
44
  os_name = mac_os.identify_version!
42
45
  logger.info!("First let's clone your Tap repo to see the Formula.")
46
+ # TODO: What if repo already exists?
43
47
  git.with_clone!(tap.url, tap.repo, keep_dir: keep_tap_repo) do |cloned_dir|
44
48
  tap.on_formula! formula_name do |formula|
45
49
  formula.put_sdist(sdist.url, sdist.sha256)
@@ -77,6 +81,7 @@ module HomebrewAutomation
77
81
  "Backtrace:",
78
82
  e.backtrace.join("\n")
79
83
  ].join("\n"))
84
+ raise
80
85
  rescue HomebrewAutomation::Brew::OlderVersionAlreadyInstalled => e
81
86
  logger.error!([
82
87
  "An older version of the Formula is already installed on your system. " \
@@ -85,16 +90,23 @@ module HomebrewAutomation
85
90
  "Caused by: #{e.cause}",
86
91
  (e.cause ? e.cause.backtrace.join("\n") : '')
87
92
  ].join("\n"))
93
+ raise
88
94
  rescue HomebrewAutomation::Brew::UninstallFailed => e
89
95
  logger.error!("brew uninstall failed:\n" + e.backtrace.join("\n"))
96
+ raise
90
97
  rescue HomebrewAutomation::Brew::Error => e
91
98
  logger.error!(
92
99
  "Something went wrong in this Homebrew command: " +
93
100
  e.message + "\n" + e.backtrace.join("\n"))
101
+ raise
94
102
  rescue HomebrewAutomation::Git::Error => e
95
103
  logger.error!(
96
104
  "Something went wrong in this Git command: " +
97
105
  e.message + "\n" + e.backtrace.join("\n"))
106
+ raise
107
+ rescue HomebrewAutomation::SourceDist::SdistDoesNotExist => e
108
+ logger.error!("The tar file from Github you named doesn't exist. Is it because you haven't pushed that tag to Github yet?")
109
+ raise
98
110
  end
99
111
 
100
112
  # Gather and publish bottles.
@@ -108,9 +120,10 @@ module HomebrewAutomation
108
120
  # @param tap [Tap]
109
121
  # @param formula_name [String] the name of the formula in the Tap
110
122
  # @param bversion [Bintray::Version]
123
+ # @param git [HomebrewAutomation::Git]
111
124
  # @param logger [HomebrewAutomation::Logger]
112
125
  # @return [NilClass]
113
- def gather_and_publish_bottles!(sdist, tap, formula_name, bversion, logger)
126
+ def gather_and_publish_bottles!(sdist, tap, formula_name, bversion, git, logger)
114
127
  logger.info!(
115
128
  "Hello, this is HomebrewAutomation! I will browse through your Bintray to " \
116
129
  "see if there may be Bottles built earlier for your Formula, and update your " \
@@ -122,6 +135,7 @@ module HomebrewAutomation
122
135
  tap.on_formula! formula_name do |formula|
123
136
  logger.info!("Let's see if any files on your Bintray look like Bottles.")
124
137
  bottles = bversion.gather_bottles
138
+ logger.info!("Found bottles: #{bottles}")
125
139
  bottles.reduce(
126
140
  formula.
127
141
  put_sdist(sdist.url, sdist.sha256).
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: homebrew_automation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - easoncxz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-06 00:00:00.000000000 Z
11
+ date: 2020-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec