Class: Lapidarist::GitCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/lapidarist/git_command.rb

Instance Method Summary collapse

Constructor Details

#initializeGitCommand

Returns a new instance of GitCommand.



3
4
5
# File 'lib/lapidarist/git_command.rb', line 3

def initialize
  @shell = Shell.new
end

Instance Method Details

#add(*files) ⇒ Object



11
12
13
# File 'lib/lapidarist/git_command.rb', line 11

def add(*files)
  shell.run("git add #{files.join(' ')}")
end

#bisect(start_sha, test) ⇒ Object



19
20
21
22
23
# File 'lib/lapidarist/git_command.rb', line 19

def bisect(start_sha, test)
  Lapidarist.logger.header('Starting bisect')
  bisect_start(start_sha)
  bisect_run(start_sha, test)
end

#clean?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/lapidarist/git_command.rb', line 33

def clean?
  shell.run('[ -z "$(git status --porcelain=v1 -uno)" ]')[1] == 0
end

#commit(message) ⇒ Object



15
16
17
# File 'lib/lapidarist/git_command.rb', line 15

def commit(message)
  shell.run("git commit -m '#{message}' #{Lapidarist.config.commit_flags}".strip, label: 'git commit')
end

#count_commits(start_sha, end_sha) ⇒ Object



37
38
39
# File 'lib/lapidarist/git_command.rb', line 37

def count_commits(start_sha, end_sha)
  shell.run("git rev-list #{end_sha} ^#{start_sha} --count")[0].to_i
end

#headObject



7
8
9
# File 'lib/lapidarist/git_command.rb', line 7

def head
  shell.run('git rev-parse HEAD')[0].strip
end

#log(sha) ⇒ Object



25
26
27
# File 'lib/lapidarist/git_command.rb', line 25

def log(sha)
  shell.run("git log HEAD...#{sha}^ --no-color --oneline", label: 'git log')
end

#reset_hard(ref) ⇒ Object



29
30
31
# File 'lib/lapidarist/git_command.rb', line 29

def reset_hard(ref)
  shell.run("git reset --hard #{ref}")
end