Sha256: 30bf6f667037a2a65ab662a9d5c5ffd7e3b75d9118636c4d63bb2b253d52f289

Contents?: true

Size: 940 Bytes

Versions: 3

Compression:

Stored size: 940 Bytes

Contents

module GitWrapper
  module Commands
    class Tag < Git

      def create(name)
        @mode = :create
        @name = name
        self
      end

      def from(commit)
        @commit = commit
        self
      end

      def remove(name)
        @mode = :remove
        @name = name
        self
      end

      def list
        @mode = :list
        self
      end

      def command
        command = 'tag '

        if @mode == :create
          command += "#{@name} #{@commit.nil? ? '' : @commit}"
        elsif @mode == :remove
          command += "-d #{@name}"
        elsif @mode == :list
          #Nothing to add
        else
          raise 'Unespecified tag mode'
        end

        command
      end

      def result
        return result_list if @mode == :list
        super
      end

      def result_list
        output.split("\n")
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git_wrapper-1.0.2 lib/git_wrapper/commands/tag.rb
git_wrapper-1.0.1 lib/git_wrapper/commands/tag.rb
git_wrapper-1.0.0 lib/git_wrapper/commands/tag.rb