Sha256: 68040fe78ba8d99488eef68529ef4a4b23ea03c2bbc74aaa45c942cad073dfa9
Contents?: true
Size: 964 Bytes
Versions: 1
Compression:
Stored size: 964 Bytes
Contents
module Space module Model class Repo class Git include Source commands status: 'git status', branch: 'git branch --no-color', commit: 'git log -1 --no-color HEAD' watch '.' attr_reader :repo def initialize(repo) @repo = repo super(repo.path) 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 dirty? !clean? end def clean? result(:status) =~ /working directory clean/m end def ahead? ahead > 0 end def ahead result(:status) =~ /Your branch is ahead of .* by (\d+) commits?\./ ? $1.to_i : 0 end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
space-0.0.9 | lib/space/model/repo/git.rb |