Class: DebtCeiling::SourceControlSystem::Git
- Inherits:
-
Base
- Object
- Base
- DebtCeiling::SourceControlSystem::Git
show all
- Defined in:
- lib/debt_ceiling/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
7
8
9
|
# File 'lib/debt_ceiling/source_control_systems/git.rb', line 7
def self.supported?
`git branch 2>&1` && $?.success?
end
|
.to_s ⇒ Object
11
12
13
|
# File 'lib/debt_ceiling/source_control_systems/git.rb', line 11
def self.to_s
"Git"
end
|
Instance Method Details
#add_note_to(ref, message) ⇒ Object
35
36
37
|
# File 'lib/debt_ceiling/source_control_systems/git.rb', line 35
def add_note_to(ref, message)
popen3(%Q(git notes append #{ref} -m "#{message}"))
end
|
#date_of_last_commit(path) ⇒ Object
23
24
25
|
# File 'lib/debt_ceiling/source_control_systems/git.rb', line 23
def date_of_last_commit(path)
popen3("git log -1 --date=iso --format=%ad #{path.shellescape}").chomp!
end
|
#head_reference ⇒ Object
31
32
33
|
# File 'lib/debt_ceiling/source_control_systems/git.rb', line 31
def head_reference
popen3("git rev-parse --verify HEAD").chomp
end
|
#read_note_on(ref) ⇒ Object
39
40
41
|
# File 'lib/debt_ceiling/source_control_systems/git.rb', line 39
def read_note_on(ref)
popen3("git notes show #{ref}")
end
|
#revision? ⇒ Boolean
27
28
29
|
# File 'lib/debt_ceiling/source_control_systems/git.rb', line 27
def revision?
head_reference && $?.success?
end
|
#revisions_count(path) ⇒ Object
15
16
17
|
# File 'lib/debt_ceiling/source_control_systems/git.rb', line 15
def revisions_count(path)
revisions_refs(path).count
end
|
#revisions_refs(path) ⇒ Object
19
20
21
|
# File 'lib/debt_ceiling/source_control_systems/git.rb', line 19
def revisions_refs(path)
popen3("git log --follow --format=%h #{path.shellescape}").split("\n")
end
|
#travel_to_commit(ref) ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/debt_ceiling/source_control_systems/git.rb', line 43
def travel_to_commit(ref)
stash_successful = stash_changes
current_branch = popen3("git symbolic-ref HEAD").chomp.split('/').last
popen3("git checkout #{ref}")
yield
ensure
popen3("git checkout #{current_branch}")
travel_to_original_state if stash_successful
end
|
#travel_to_head ⇒ Object
53
54
55
56
57
58
|
# File 'lib/debt_ceiling/source_control_systems/git.rb', line 53
def travel_to_head
stash_successful = stash_changes
yield
ensure
travel_to_original_state if stash_successful
end
|