Sha256: e22d5eb30baa3efdccaebe741a66f47e8d1452ed3714e66cf52a8d66c64fe4fd

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module GitWrapper
  module Commands
    class RevList < Git

      def author(author)
        @author = author
        self
      end

      def grep(grep)
        @grep = grep
        self
      end

      def since(date)
        @since = date
        self
      end

      def until(date)
        @until = date
        self
      end

      def count
        @count = true
        self
      end

      def files(files)
        @files = files.map { |f| to_relative_path(f) }
        self
      end

      def command
        command = "rev-list HEAD -i #{@count ? ' --count ' : ''}"
        command += " --author \"#{@author}\"" if @author
        command += " --since \"#{@since}\"" if @since
        command += " --until \"#{@until}\"" if @until
        command += " --grep \"#{@grep}\"" if @grep
        command += " #{@files.map{|f| "\"#{f}\"" }.join(' ')}" if @files
        command
      end

      def result
        return nil unless success?
        @count ? output.to_i : output.split(/\n/)
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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