Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sven Fuchs
committed
Mar 31, 2012
1 parent
4d75ede
commit 368c48e
Showing
7 changed files
with
86 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,44 @@ | ||
# On branch master | ||
# # Your branch is ahead of 'origin/master' by 1 commit. | ||
# # | ||
# nothing to commit (working directory clean) | ||
|
||
module Space | ||
class Git | ||
include Commands | ||
|
||
COMMANDS = { | ||
:status => 'git status -s', | ||
:status => 'git status', | ||
:branch => 'git branch --no-color', | ||
:commit => 'git log -1 head' | ||
} | ||
|
||
def clean? | ||
result(:status).empty? | ||
end | ||
|
||
def branch | ||
result(:branch) =~ /^\* (.+)/ && $1.strip | ||
end | ||
|
||
def commit | ||
result(:commit) =~ /^commit (\S{7})/ && $1 | ||
end | ||
|
||
def status | ||
dirty? ? :dirty : (ahead? ? :ahead : :clean) | ||
end | ||
|
||
def ahead? | ||
ahead > 0 | ||
end | ||
|
||
def ahead | ||
result(:status) =~ /Your branch is ahead of .* by (\d+) commits?\./ ? $1.to_i : 0 | ||
end | ||
|
||
def dirty? | ||
!clean? | ||
end | ||
|
||
def clean? | ||
result(:status).include?('nothing to commit (working directory clean)') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters