Sha256: b7fc7eeedfbde03846beab193164a96d2ae7d69e025638d7b4c018d6414d46a8

Contents?: true

Size: 816 Bytes

Versions: 20

Compression:

Stored size: 816 Bytes

Contents

# frozen_string_literal: true

module BoxtRubyStyleGuide
  # Returns a list of files that have changed, as detected by `git-diff`
  #
  # TODO: Write tests for this to ensure we're pulling the desired diff files
  # see: https://github.com/ruby-git/ruby-git
  class GitDiff
    require "git"

    ##
    # List of Git statuses we should test
    # See: https://git-scm.com/docs/git-status#_short_format
    TEST_STATUSES = %w[M A U].freeze

    attr_reader :base

    def initialize(base:)
      @base = base
    end

    ##
    # A list of the local file paths of Ruby files with committed changes.
    #
    # Returns Array
    def all
      @all ||= git.diff(base).name_status.select { |_, stat| TEST_STATUSES.include?(stat) }.keys
    end

    private

    def git
      @git ||= Git.open(".")
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
boxt_ruby_style_guide-8.6.0 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.5.1 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.5.0 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.4.1 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.4.0 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.3.6 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.3.5 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.3.4 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.3.3 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.3.2 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.3.1 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.3.0 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.2.3 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.2.2 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.2.1 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.2.0 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.1.1 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.1.0 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-8.0.0 lib/boxt_ruby_style_guide/git_diff.rb
boxt_ruby_style_guide-7.10.0 lib/boxt_ruby_style_guide/git_diff.rb