Module: Laborantin::Commands::Git

Defined in:
lib/laborantin/extra/commands/git.rb,
lib/laborantin/extra/commands/git/run.rb,
lib/laborantin/extra/commands/git/check.rb

Overview

A Git set of Commands, to enable it, pass to true the :extra :git flag.

Defined Under Namespace

Classes: Check, Run

Constant Summary collapse

HERE =
'.'

Class Method Summary collapse

Class Method Details

.branchObject

Get the current working directory branch.



19
20
21
# File 'lib/laborantin/extra/commands/git.rb', line 19

def self.branch
  self.git.current_branch
end

.commit_idObject

Get the commit-id (long sha1) where current branch is pointing to.



24
25
26
# File 'lib/laborantin/extra/commands/git.rb', line 24

def self.commit_id
  self.git.revparse(branch)
end

.diffObject

Returns the Diff between current directory and the HEAD of current branch.



35
36
37
# File 'lib/laborantin/extra/commands/git.rb', line 35

def self.diff
  git.diff(commit_id, HERE)
end

.gitObject

Just get a git object for current working dir (implementation is crappy, but will be refined later)



14
15
16
# File 'lib/laborantin/extra/commands/git.rb', line 14

def self.git
  @g ||= Object::Git.open(HERE)
end

.master_branch?Boolean

Returns true if current working dir is master.

Returns:

  • (Boolean)


29
30
31
# File 'lib/laborantin/extra/commands/git.rb', line 29

def self.master_branch?
  'master' == branch
end