class Startling::GitLocal

Public Instance Methods

checkout_branch(branch) click to toggle source
# File lib/startling/git_local.rb, line 10
def checkout_branch(branch)
  Shell.run "git checkout #{branch}"
end
create_empty_commit(message) click to toggle source
# File lib/startling/git_local.rb, line 26
def create_empty_commit(message)
  Shell.run "git commit --allow-empty -m #{Shellwords.escape(message)}"
end
create_remote_branch(branch_name, base_branch: 'origin/master') click to toggle source
# File lib/startling/git_local.rb, line 30
def create_remote_branch(branch_name, base_branch: 'origin/master')
  Shell.run "git fetch -q"
  Shell.run "git checkout -q #{branch_name} 2>/dev/null || git checkout -q -b #{branch_name} #{base_branch}"
end
current_branch() click to toggle source
# File lib/startling/git_local.rb, line 6
def current_branch
  `git symbolic-ref -q --short HEAD`.strip
end
current_branch_has_no_commits?(base_branch: 'origin/master') click to toggle source
# File lib/startling/git_local.rb, line 52
def current_branch_has_no_commits?(base_branch: 'origin/master')
  revision_sha(base_branch) == revision_sha('HEAD')
end
destroy_branch(branch) click to toggle source
# File lib/startling/git_local.rb, line 39
def destroy_branch(branch)
  Shell.run "git push origin :#{branch}" if remote_branches.include? branch
  Shell.run "git branch -D #{branch}" if local_branches.include? branch
end
local_branches() click to toggle source
# File lib/startling/git_local.rb, line 22
def local_branches
  Shell.run "git branch"
end
project_root() click to toggle source
# File lib/startling/git_local.rb, line 48
def project_root
 `git rev-parse --show-toplevel`.strip
end
push_origin_head() click to toggle source
# File lib/startling/git_local.rb, line 35
def push_origin_head
  Shell.run "git push -qu origin HEAD"
end
remote_branches() click to toggle source
# File lib/startling/git_local.rb, line 18
def remote_branches
  Shell.run "git branch -r"
end
repo_name() click to toggle source
# File lib/startling/git_local.rb, line 44
def repo_name
  remote_url[%r{([^/:]+/[^/]+)\.git}, 1]
end
status() click to toggle source
# File lib/startling/git_local.rb, line 14
def status
  Shell.run "git status --porcelain"
end

Private Instance Methods

remote_url() click to toggle source
# File lib/startling/git_local.rb, line 58
def remote_url
  `git config --get remote.origin.url`.strip
end
revision_sha(revision) click to toggle source
# File lib/startling/git_local.rb, line 62
def revision_sha(revision)
  Shell.run "git rev-parse #{revision}"
end