Sha256: 9c31685989c417186346a50ed0fe88b92bf8572ebd7c4b0d2f6d92b7defd2f27

Contents?: true

Size: 591 Bytes

Versions: 14

Compression:

Stored size: 591 Bytes

Contents

class MergeConflict

  attr_accessor :staged_files

  def self.call
    check = new
    check.staged_files = Utils.staged_files('.')
    check.run
  end

  def run
    if detected_bad_code?
      $stderr.puts 'pre-commit: detected a merge conflict'
      $stderr.puts errors
      $stderr.puts
      $stderr.puts 'pre-commit: You can bypass this check using `git commit -n`'
      $stderr.puts
      false
    else
      true
    end
  end

  def detected_bad_code?
    system("grep '<<<<<<<' #{staged_files} --quiet")
  end

  def errors
    `grep -nH '<<<<<<<' #{staged_files}`
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pre-commit-0.6.1 lib/pre-commit/checks/merge_conflict.rb
pre-commit-0.6.0 lib/pre-commit/checks/merge_conflict.rb
pre-commit-0.5.0 lib/pre-commit/checks/merge_conflict.rb
pre-commit-0.4.0 lib/pre-commit/checks/merge_conflict.rb
pre-commit-0.3.1 lib/pre-commit/checks/merge_conflict.rb
pre-commit-0.3.0 lib/pre-commit/checks/merge_conflict.rb
pre-commit-0.2.0 lib/pre-commit/checks/merge_conflict.rb
pre-commit-0.1.19 lib/pre-commit/checks/merge_conflict.rb
pre-commit-0.1.18 lib/pre-commit/checks/merge_conflict.rb
pre-commit-0.1.17 lib/pre-commit/checks/merge_conflict.rb
pre-commit-0.1.16 lib/pre-commit/checks/merge_conflict.rb
pre-commit-0.1.15 lib/pre-commit/checks/merge_conflict.rb
pre-commit-0.1.14 lib/pre-commit/checks/merge_conflict.rb
pre-commit-0.1.13 lib/pre-commit/checks/merge_conflict.rb