Class: Startling::GitLocal

Inherits:
Object
  • Object
show all
Defined in:
lib/startling/git_local.rb

Instance Method Summary collapse

Instance Method Details

#checkout_branch(branch) ⇒ Object



9
10
11
# File 'lib/startling/git_local.rb', line 9

def checkout_branch(branch)
  Shell.run "git checkout #{branch}"
end

#create_empty_commit(message) ⇒ Object



25
26
27
# File 'lib/startling/git_local.rb', line 25

def create_empty_commit(message)
  Shell.run "git commit --allow-empty -m #{message}"
end

#create_remote_branch(branch_name, base_branch: 'origin/master') ⇒ Object



29
30
31
32
# File 'lib/startling/git_local.rb', line 29

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_branchObject



5
6
7
# File 'lib/startling/git_local.rb', line 5

def current_branch
  `git symbolic-ref -q --short HEAD`.strip
end

#destroy_branch(branch) ⇒ Object



38
39
40
41
# File 'lib/startling/git_local.rb', line 38

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_branchesObject



21
22
23
# File 'lib/startling/git_local.rb', line 21

def local_branches
  Shell.run "git branch"
end

#project_rootObject



47
48
49
# File 'lib/startling/git_local.rb', line 47

def project_root
 `git rev-parse --show-toplevel`.strip
end

#push_origin_headObject



34
35
36
# File 'lib/startling/git_local.rb', line 34

def push_origin_head
  Shell.run "git push -qu origin HEAD"
end

#remote_branchesObject



17
18
19
# File 'lib/startling/git_local.rb', line 17

def remote_branches
  Shell.run "git branch -r"
end

#repo_nameObject



43
44
45
# File 'lib/startling/git_local.rb', line 43

def repo_name
  remote_url[%r{([^/:]+/[^/]+)\.git}, 1]
end

#statusObject



13
14
15
# File 'lib/startling/git_local.rb', line 13

def status
  Shell.run "git status --porcelain"
end