Class: Space::Models::Repo::Git
- Inherits:
-
Object
- Object
- Space::Models::Repo::Git
show all
- Includes:
- Events, Shell
- Defined in:
- lib/space/models/repo/git.rb
Instance Attribute Summary collapse
Attributes included from Events
#buffer
Attributes included from Shell
#path
Instance Method Summary
collapse
Methods included from Events
#buffering, #buffering?, #notify, #observers, #subscribe
Methods included from Shell
all, #commands, included, refresh, #refresh, #result
suspend, suspended?
Constructor Details
#initialize(repo) ⇒ Git
Returns a new instance of Git.
17
18
19
20
|
# File 'lib/space/models/repo/git.rb', line 17
def initialize(repo)
@repo = repo
super(repo.path)
end
|
Instance Attribute Details
#repo ⇒ Object
Returns the value of attribute repo.
15
16
17
|
# File 'lib/space/models/repo/git.rb', line 15
def repo
@repo
end
|
Instance Method Details
#ahead ⇒ Object
38
39
40
|
# File 'lib/space/models/repo/git.rb', line 38
def ahead
result(:status) =~ /Your branch is ahead of .* by (\d+) commits?\./ ? $1.to_i : 0
end
|
#ahead? ⇒ Boolean
34
35
36
|
# File 'lib/space/models/repo/git.rb', line 34
def ahead?
ahead > 0
end
|
#branch ⇒ Object
22
23
24
|
# File 'lib/space/models/repo/git.rb', line 22
def branch
result(:branch) =~ /^\* (.+)/ && $1.strip
end
|
#clean? ⇒ Boolean
46
47
48
|
# File 'lib/space/models/repo/git.rb', line 46
def clean?
result(:status).include?('nothing to commit (working directory clean)')
end
|
#commit ⇒ Object
26
27
28
|
# File 'lib/space/models/repo/git.rb', line 26
def commit
result(:commit) =~ /^commit (\S{7})/ && $1
end
|
#dirty? ⇒ Boolean
42
43
44
|
# File 'lib/space/models/repo/git.rb', line 42
def dirty?
!clean?
end
|
#status ⇒ Object
30
31
32
|
# File 'lib/space/models/repo/git.rb', line 30
def status
dirty? ? :dirty : (ahead? ? :ahead : :clean)
end
|