Sha256: 58476c88425faf36aee359e5534542e179bf418f9d5afaf775b62570a383f3bd

Contents?: true

Size: 655 Bytes

Versions: 2

Compression:

Stored size: 655 Bytes

Contents

# frozen_string_literal: true

module Milestoner
  # Handles publishing of Git tags to remote repository.
  class Pusher
    def initialize git: Git::Kit.new
      @git = git
    end

    def push version
      version = Versionaire::Version version

      fail(Errors::Git, "Remote repository not configured.") unless git.remote?
      fail(Errors::Git, "Remote tag exists: #{version}.") if tag_exists?(version)
      return if git.push_tags.empty?

      fail(Errors::Git, "Tags could not be pushed to remote repository.")
    end

    private

    attr_reader :git, :version

    def tag_exists? version
      git.tag_remote? version
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
milestoner-9.1.0 lib/milestoner/pusher.rb
milestoner-9.0.0 lib/milestoner/pusher.rb