class Shipit::Cli::Git
Constants
- COMMANDS
- GIT
- ORIGIN
- VERBOSE
Public Class Methods
exec_cmd(str, dry_run = false)
click to toggle source
# File lib/shipit/cli/git.rb, line 48 def self.exec_cmd(str, dry_run = false) return true unless str if dry_run puts " - #{str}" else system("#{str}") end end
get_current_branch()
click to toggle source
# File lib/shipit/cli/git.rb, line 44 def self.get_current_branch (`#{GIT} branch 2> /dev/null | grep '^\*'`).gsub(/[\*\s]/, "") end
run(opt)
click to toggle source
Ex: Shipit::Cli::Git.run
(command: :new, target_branch: “master”, branch: “my-new-branch”, message: “empty commit”)
# File lib/shipit/cli/git.rb, line 23 def self.run(opt) if COMMANDS.keys.include?(opt[:command].to_sym) current_branch = opt[:target_branch] branch = opt[:branch] origin = ORIGIN message = opt.fetch(:message, "").gsub("`", "'") dry_run = opt.fetch(:dry_run, false) grepped_protected_branches = Array(Shipit::Cli.config.protected_branches) .push("master") .push("develop") .push(get_current_branch) .uniq.map{ |b| "| grep -v #{b} " }.join COMMANDS[opt[:command].to_sym][:commands].map do |x| command = exec_cmd(eval(x), dry_run) exit_now!("There was an error running the last Git command. See the trace for more info.") if dry_run == false && command == false end else false end end