Sha256: ba22f06b058a5a8a9456427e575e2331bb3b895215bfd8b6837037fb950a2f04

Contents?: true

Size: 783 Bytes

Versions: 15

Compression:

Stored size: 783 Bytes

Contents

# frozen_string_literal: true

require 'active_support/core_ext/object'

module EacLauncher
  module Git
    class Base < ::EacLauncher::Paths::Real
      module DirtyFiles
        def dirty?
          dirty_files.any?
        end

        def dirty_files
          execute!('status', '--porcelain', '--untracked-files').each_line.map do |line|
            parse_status_line(line.gsub(/\n\z/, ''))
          end
        end

        private

        def parse_status_line(line)
          m = /\A(.)(.)\s(.+)\z/.match(line)
          ::Kernel.raise "Status pattern does not match \"#{line}\"" unless m
          ::OpenStruct.new(index: m[1], worktree: m[2], path: m[3],
                           absolute_path: ::File.expand_path(m[3], self))
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
avm-tools-0.59.0 lib/eac_launcher/git/base/dirty_files.rb
avm-tools-0.58.1 lib/eac_launcher/git/base/dirty_files.rb
avm-tools-0.58.0 lib/eac_launcher/git/base/dirty_files.rb
avm-tools-0.57.0 lib/eac_launcher/git/base/dirty_files.rb
avm-tools-0.56.0 lib/eac_launcher/git/base/dirty_files.rb
avm-tools-0.55.0 lib/eac_launcher/git/base/dirty_files.rb
avm-tools-0.54.2 lib/eac_launcher/git/base/dirty_files.rb
avm-tools-0.54.1 lib/eac_launcher/git/base/dirty_files.rb
avm-tools-0.54.0 lib/eac_launcher/git/base/dirty_files.rb
avm-tools-0.53.0 lib/eac_launcher/git/base/dirty_files.rb
avm-tools-0.52.0 lib/eac_launcher/git/base/dirty_files.rb
avm-tools-0.51.0 lib/eac_launcher/git/base/dirty_files.rb
avm-tools-0.50.0 lib/eac_launcher/git/base/dirty_files.rb
avm-tools-0.49.0 lib/eac_launcher/git/base/dirty_files.rb
avm-tools-0.48.0 lib/eac_launcher/git/base/dirty_files.rb