Sha256: 519dde4e31ace0a0f4d3046443300912fbd18aba116b9e0d45214423b7b296b1

Contents?: true

Size: 1023 Bytes

Versions: 7

Compression:

Stored size: 1023 Bytes

Contents

# frozen_string_literal: true

require "versionaire"

module Milestoner
  module Tags
    # Handles publishing of tags to a remote repository.
    class Pusher
      using Versionaire::Cast

      def initialize container: Container
        @container = container
      end

      def call configuration = CLI::Configuration::Loader.call
        version = Version configuration.git_tag_version

        fail Error, "Remote repository not configured." unless repository.config_origin?
        fail Error, "Remote tag exists: #{version}." if repository.tag_remote? version
        fail Error, "Tags could not be pushed to remote repository." unless push

        logger.debug "Local tag pushed: #{version}."
      end

      private

      attr_reader :container

      def push
        repository.tag_push.then do |_stdout, stderr, status|
          status.success? && stderr.match?(/[new tag]/)
        end
      end

      def repository = container[__method__]

      def logger = container[__method__]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
milestoner-12.2.0 lib/milestoner/tags/pusher.rb
milestoner-12.1.0 lib/milestoner/tags/pusher.rb
milestoner-12.0.4 lib/milestoner/tags/pusher.rb
milestoner-12.0.3 lib/milestoner/tags/pusher.rb
milestoner-12.0.2 lib/milestoner/tags/pusher.rb
milestoner-12.0.1 lib/milestoner/tags/pusher.rb
milestoner-12.0.0 lib/milestoner/tags/pusher.rb