Class: Rubycritic::Git
Class Method Summary
collapse
Instance Method Summary
collapse
create, register_system, system_names, systems
Class Method Details
.supported? ⇒ Boolean
6
7
8
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 6
def self.supported?
`git branch 2>&1` && $?.success?
end
|
.to_s ⇒ Object
10
11
12
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 10
def self.to_s
"Git"
end
|
Instance Method Details
#has_revision? ⇒ Boolean
14
15
16
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 14
def has_revision?
head_reference && $?.success?
end
|
#head_reference ⇒ Object
18
19
20
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 18
def head_reference
`git rev-parse --verify HEAD`.chomp
end
|
#revisions_count(file) ⇒ Object
29
30
31
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 29
def revisions_count(file)
`git log --follow --format=oneline #{file}`.count("\n")
end
|
#travel_to_head ⇒ Object
22
23
24
25
26
27
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 22
def travel_to_head
stash_successful = stash_changes
yield
ensure
travel_to_original_state if stash_successful
end
|