def extract_modified_lines(file_path, options)
      lines = Set.new

      flags = '--cached' if options[:staged]
      refs = options[:refs]
      subcmd = options[:subcmd] || 'diff'

      `git #{subcmd} --no-color --no-ext-diff -U0 #{flags} #{refs} -- "#{file_path}"`.
        scan(DIFF_HUNK_REGEX) do |start_line, lines_added|
        lines_added = (lines_added || 1).to_i # When blank, one line was added
        cur_line = start_line.to_i

        lines_added.times do
          lines.add cur_line
          cur_line += 1
        end
      end

      lines
    end
def extract_modified_lines(file_path, options)
      lines = Set.new

      flags = '--cached' if options[:staged]
      refs = options[:refs]
      subcmd = options[:subcmd] || 'diff'

      `git #{subcmd} --no-color --no-ext-diff -U0 #{flags} #{refs} -- "#{file_path}"`.
        scan(DIFF_HUNK_REGEX) do |start_line, lines_added|
        lines_added = (lines_added || 1).to_i # When blank, one line was added
        cur_line = start_line.to_i

        lines_added.times do
          lines.add cur_line
          cur_line += 1
        end
      end

      lines
    end
Extract the set of modified lines from a given file.

 @param file_path [String]
 @param options [Hash]
 @return [Set] line numbers that have been modified in file