class BigKeeper::GitOperator
Operator for got
Public Instance Methods
checkout(path, branch_name)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 42 def checkout(path, branch_name) Dir.chdir(path) do IO.popen("git checkout #{branch_name}") do |io| io.each do |line| Logger.error("Checkout #{branch_name} failed.") if line.include? 'error' end end end end
clone(path, git_base)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 64 def clone(path, git_base) Dir.chdir(path) do `git clone #{git_base}` end end
commit(path, message)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 70 def commit(path, message) Dir.chdir(path) do `git add .` `git commit -m "#{message}"` end end
current_branch(path)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 6 def current_branch(path) Dir.chdir(path) do `git rev-parse --abbrev-ref HEAD`.chop end end
del_local(path, branch_name)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 116 def del_local(path, branch_name) Dir.chdir(path) do p `git branch -D #{branch_name}` end end
del_remote(path, branch_name)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 122 def del_remote(path, branch_name) Dir.chdir(path) do p `git push origin --delete #{branch_name}` end end
dicard(path)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 110 def dicard(path) Dir.chdir(path) do `git checkout . && git clean -xdf` end end
fetch(path)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 52 def fetch(path) Dir.chdir(path) do `git fetch origin` end end
has_branch(path, branch_name)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 32 def has_branch(path, branch_name) has_branch = false IO.popen("cd #{path}; git branch -a") do |io| io.each do |line| has_branch = true if line.include? branch_name end end has_branch end
has_changes(path)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 99 def has_changes(path) has_changes = true clear_flag = 'nothing to commit, working tree clean' IO.popen("cd #{path}; git status") do |io| io.each do |line| has_changes = false if line.include? clear_flag end end has_changes end
has_commits(path, branch_name)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 89 def has_commits(path, branch_name) has_commits = false IO.popen("cd #{path}; git log --branches --not --remotes") do |io| io.each do |line| has_commits = true if line.include? branch_name end end has_commits end
has_local_branch(path, branch_name)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 22 def has_local_branch(path, branch_name) has_branch = false IO.popen("cd #{path}; git branch") do |io| io.each do |line| has_branch = true if line.include? branch_name end end has_branch end
has_remote_branch(path, branch_name)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 12 def has_remote_branch(path, branch_name) has_branch = false IO.popen("cd #{path}; git branch -r") do |io| io.each do |line| has_branch = true if line.include? branch_name end end has_branch end
pull(path)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 83 def pull(path) Dir.chdir(path) do p `git pull` end end
push_to_remote(path, branch_name)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 77 def push_to_remote(path, branch_name) Dir.chdir(path) do `git push -u origin #{branch_name}` end end
rebase(path, branch_name)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 58 def rebase(path, branch_name) Dir.chdir(path) do `git rebase origin/#{branch_name}` end end
tag(path, version)
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 132 def tag(path, version) Dir.chdir(path) do p `git tag -a #{version} -m "release: V #{version}" master` p `git push --tags` end end
user()
click to toggle source
# File lib/big_keeper/util/git_operator.rb, line 128 def user `git config user.name`.chop end