Class: Rubycritic::SourceControlSystem::Git
- Inherits:
-
Base
- Object
- Base
- Rubycritic::SourceControlSystem::Git
show all
- Defined in:
- lib/rubycritic/source_control_systems/git.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
create, register_system, system_names, systems
Class Method Details
.supported? ⇒ Boolean
7
8
9
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 7
def self.supported?
`git branch 2>&1` && $?.success?
end
|
.to_s ⇒ Object
11
12
13
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 11
def self.to_s
"Git"
end
|
Instance Method Details
#date_of_last_commit(path) ⇒ Object
34
35
36
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 34
def date_of_last_commit(path)
`git log -1 --date=iso --format=%ad #{path.shellescape}`.chomp!
end
|
#has_revision? ⇒ Boolean
15
16
17
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 15
def has_revision?
head_reference && $?.success?
end
|
#head_reference ⇒ Object
19
20
21
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 19
def head_reference
`git rev-parse --verify HEAD`.chomp!
end
|
#revisions_count(path) ⇒ Object
30
31
32
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 30
def revisions_count(path)
`git log --follow --format=oneline #{path.shellescape}`.count("\n")
end
|
#travel_to_head ⇒ Object
23
24
25
26
27
28
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 23
def travel_to_head
stash_successful = stash_changes
yield
ensure
travel_to_original_state if stash_successful
end
|