Module: GitHelper

Defined in:
lib/git_helper.rb

Overview

TODO spec test for this

Class Method Summary collapse

Class Method Details

.dirty?Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/git_helper.rb', line 13

def self.dirty?
  changes = `git status --porcelain -uno`
  !changes.empty?
end

.sha1(commitish = 'HEAD', opts = [ '--short ']) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/git_helper.rb', line 4

def self.sha1(commitish = 'HEAD', opts = [ '--short '])
  sha = `git rev-parse #{opts.join(' ')} #{commitish}`.chomp

  # add "-dirty" if commitish is 'HEAD' and the workspace has changes
  sha += '-dirty' if commitish == 'HEAD' && self.dirty?

  sha.empty? ? nil : sha
end