Sha256: 98b33369a42a76d294d9030a878b99b6ac71e11a62963dfbe97860aa7a5be24d

Contents?: true

Size: 1015 Bytes

Versions: 6

Compression:

Stored size: 1015 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.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

6 entries across 6 versions & 1 rubygems

Version Path
milestoner-13.3.1 lib/milestoner/tags/pusher.rb
milestoner-13.3.0 lib/milestoner/tags/pusher.rb
milestoner-13.2.0 lib/milestoner/tags/pusher.rb
milestoner-13.1.0 lib/milestoner/tags/pusher.rb
milestoner-13.0.1 lib/milestoner/tags/pusher.rb
milestoner-13.0.0 lib/milestoner/tags/pusher.rb