Sha256: 7572cb5f6627285e1da67aeb08ceebecec7ab7cd4a957c549aa51191544f8e06
Contents?: true
Size: 936 Bytes
Versions: 6
Compression:
Stored size: 936 Bytes
Contents
module Rubycritic class Git < SourceControlSystem register_system def self.supported? `git branch 2>&1` && $?.success? end def self.to_s "Git" end def has_revision? head_reference && $?.success? end def head_reference `git rev-parse --verify HEAD`.chomp end def travel_to_head stash_successful = stash_changes yield ensure travel_to_original_state if stash_successful end private def stash_changes return false if everything_commmited? stashes_count_before = stashes_count `git stash` stashes_count_after = stashes_count stashes_count_after > stashes_count_before end def everything_commmited? `git status --porcelain`.empty? end def stashes_count `git stash list`.split("\n").length end def travel_to_original_state `git stash pop` end end end
Version data entries
6 entries across 6 versions & 1 rubygems