Class: MergeConflict
- Inherits:
-
Object
- Object
- MergeConflict
- Defined in:
- lib/pre-commit/checks/merge_conflict.rb
Instance Attribute Summary collapse
-
#staged_files ⇒ Object
Returns the value of attribute staged_files.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#staged_files ⇒ Object
Returns the value of attribute staged_files.
3 4 5 |
# File 'lib/pre-commit/checks/merge_conflict.rb', line 3 def staged_files @staged_files end |
Class Method Details
.call ⇒ Object
5 6 7 8 9 |
# File 'lib/pre-commit/checks/merge_conflict.rb', line 5 def self.call check = new check.staged_files = Utils.staged_files('.') check.run end |
Instance Method Details
#detected_bad_code? ⇒ Boolean
24 25 26 |
# File 'lib/pre-commit/checks/merge_conflict.rb', line 24 def detected_bad_code? system("grep '<<<<<<<' #{staged_files} --quiet") end |
#errors ⇒ Object
28 29 30 |
# File 'lib/pre-commit/checks/merge_conflict.rb', line 28 def errors `grep -nH '<<<<<<<' #{staged_files}` end |
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pre-commit/checks/merge_conflict.rb', line 11 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 |