Sha256: 1cdbd2bf75328e0bf284337c296cd3a44952eb8a15ddde4f6ae48ebae8a566cc

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 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 result
        @success
      end

      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.0.2 lib/git_wrapper/commands/git.rb
git_wrapper-1.0.1 lib/git_wrapper/commands/git.rb
git_wrapper-1.0.0 lib/git_wrapper/commands/git.rb