Sha256: 15c2f75777465c0ba3f40396808b3eb69c760b5ee629b62c4115a23164c2fff9

Contents?: true

Size: 887 Bytes

Versions: 4

Compression:

Stored size: 887 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

4 entries across 4 versions & 1 rubygems

Version Path
git_wrapper-1.1.2 lib/git_wrapper/commands/tag.rb
git_wrapper-1.1.1 lib/git_wrapper/commands/tag.rb
git_wrapper-1.1.0 lib/git_wrapper/commands/tag.rb
git_wrapper-1.0.3 lib/git_wrapper/commands/tag.rb