Sha256: e9d5d3251244a148a82e9295f6048a65f19050b08c7081990dc95c8992be769a

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

module GitWrapper
  module Commands
    class Git
      attr_reader :location_folder
      attr_reader :output
      attr_reader :error

      def initialize(location_folder)
        @location_folder = location_folder
      end

      def execute
        begin
          @output, @error, status = Shell.execute("git #{command}", :chdir => @location_folder)
          @success = status.success?

          log = {
            :command => command,
            :location_folder => @location_folder,
            :output => @output,
            :error => @error
          }
          GitWrapper.logger.debug "[GitWrapper] #{log}"

          return result
        rescue Exception => e
          GitWrapper.logger.error "[GitWrapper] #{e.message}"
          @error = e.message
          return false
        end
      end

      def success?
        @success
      end

      def result
        @success
      end

      private

      def to_relative_path(file_name)
        base_folder = location_folder.gsub("\\", "/")
        file_name.gsub("\\", "/").gsub(base_folder + "/", "")
      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/git.rb
git_wrapper-1.1.1 lib/git_wrapper/commands/git.rb
git_wrapper-1.1.0 lib/git_wrapper/commands/git.rb