Sha256: b2ba36b5d2942da0790dad4b87bb1878acfa1014b1a5fb6bef8fcd69d2e3bd59
Contents?: true
Size: 1.14 KB
Versions: 7
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true module RubyCritic module SourceControlSystem class Git < Base register_system def self.supported? `git branch 2>&1` && $?.success? end def self.to_s 'Git' end def revisions_count(path) `git log --follow --format=%h #{path.shellescape}`.count("\n") end def date_of_last_commit(path) `git log -1 --date=iso --format=%ad #{path.shellescape}`.chomp! end def 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 stashes_count_before = stashes_count `git stash` stashes_count_after = stashes_count stashes_count_after > stashes_count_before end def stashes_count `git stash list --format=%h`.count("\n") end def travel_to_original_state `git stash pop` end end end end
Version data entries
7 entries across 7 versions & 1 rubygems