Sha256: d0bf437cd72cdf8e5d730f8fcb30550e1c633bd7264e80fba89a7dc530e0c2d1

Contents?: true

Size: 1.2 KB

Versions: 7

Compression:

Stored size: 1.2 KB

Contents

module Hatchet
  # used for deploying a test app to heroku via git
  class GitApp < App
    def git_repo
      "https://git.heroku.com/#{name}.git"
    end

    def push_without_retry!
      output = ""

      ShellThrottle.new(platform_api: @platform_api).call do
        begin
          output = git_push_heroku_yall
        rescue FailedDeploy => e
          case e.output
          when /reached the API rate limit/, /429 Too Many Requests/, /HTTP 429/, /HTTP code = 429/
            throw(:throttle)
          else
            raise e unless @allow_failure
            output = e.output
          end
        end
      end

      return output
    end

    def releases
      platform_api.release.list(name)
    end

    private def git_push_heroku_yall
      output = `git push #{git_repo} HEAD:main 2>&1`

      if !$?.success?
        raise FailedDeployError.new(self, "Buildpack: #{@buildpack.inspect}\nRepo: #{git_repo}", output: output)
      end

      if releases.last["status"] == "failed"
        commit! # An empty commit allows us to deploy again
        raise FailedReleaseError.new(self, "Buildpack: #{@buildpack.inspect}\nRepo: #{git_repo}", output: output)
      end

      return output
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
heroku_hatchet-8.0.4 lib/hatchet/git_app.rb
heroku_hatchet-8.0.3 lib/hatchet/git_app.rb
heroku_hatchet-8.0.2 lib/hatchet/git_app.rb
heroku_hatchet-8.0.1 lib/hatchet/git_app.rb
heroku_hatchet-8.0.0 lib/hatchet/git_app.rb
heroku_hatchet-7.4.0 lib/hatchet/git_app.rb
heroku_hatchet-7.3.4 lib/hatchet/git_app.rb