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
connected_system_names, create, register_system, systems
Class Method Details
.supported? ⇒ Boolean
8
9
10
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 8
def self.supported?
`git branch 2>&1` && $?.success?
end
|
.to_s ⇒ Object
12
13
14
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 12
def self.to_s
'Git'
end
|
Instance Method Details
#date_of_last_commit(path) ⇒ Object
20
21
22
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 20
def date_of_last_commit(path)
`git log -1 --date=iso --format=%ad #{path.shellescape}`.chomp!
end
|
#head_reference ⇒ Object
28
29
30
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 28
def head_reference
`git rev-parse --verify HEAD`.chomp!
end
|
#revision? ⇒ Boolean
24
25
26
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 24
def revision?
head_reference && $?.success?
end
|
#revisions_count(path) ⇒ Object
16
17
18
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 16
def revisions_count(path)
`git log --follow --format=%h #{path.shellescape}`.count("\n")
end
|
#travel_to_head ⇒ Object
32
33
34
35
36
37
|
# File 'lib/rubycritic/source_control_systems/git.rb', line 32
def travel_to_head
stash_successful = stash_changes
yield
ensure
travel_to_original_state if stash_successful
end
|