class GitPc

Constants

VERSION

Attributes

argv[RW]

Public Instance Methods

run(argv) click to toggle source
# File lib/git-pc.rb, line 8
def run(argv)
  @argv = argv

  status_command
  add_command
  commit_command
  push_command
end

Private Instance Methods

add_command() click to toggle source
# File lib/git-pc.rb, line 26
def add_command
  puts "Executing add command".green
  puts "git add .".yellow
  puts
  %x(git add .)
end
commit_command() click to toggle source
# File lib/git-pc.rb, line 33
def commit_command
  puts "Executing commit command".green
  puts "git commit -S -am #{ message }".yellow
  puts
  %x(git commit -S -am "#{ message }")
end
current_branch() click to toggle source
# File lib/git-pc.rb, line 48
def current_branch
  @current_branch ||= repo.head.name
end
get_repo() click to toggle source
# File lib/git-pc.rb, line 60
def get_repo
  repo_dir = `git rev-parse --show-toplevel`.chomp
  begin
    @repo = Grit::Repo.new(repo_dir)
  rescue
    raise "We don't seem to be in a git repository."
  end
end
message() click to toggle source
# File lib/git-pc.rb, line 56
def message
  @argv[0] || 'no message commit'
end
push_command() click to toggle source
# File lib/git-pc.rb, line 40
def push_command
  puts "Executing push command".green
  puts "git push origin #{ current_branch }".yellow
  puts
  %x(git push origin #{ current_branch })
end
repo() click to toggle source
# File lib/git-pc.rb, line 52
def repo
  @repo ||= get_repo
end
status_command() click to toggle source
# File lib/git-pc.rb, line 19
def status_command
  puts "Executing status command".green
  puts "git status".yellow
  puts
  %x(git status)
end