Sha256: 6b8aed5029e9b89f1305b2b8c445afec5422f783b2e9101c4776e21f876a1bfb
Contents?: true
Size: 1018 Bytes
Versions: 2
Compression:
Stored size: 1018 Bytes
Contents
require 'observer' module Space module Models class Repo class Git include Events, Shell 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 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
space-0.0.5 | lib/space/models/repo/git.rb |
space-0.0.4 | lib/space/models/repo/git.rb |