Class: Dolphin::Git

Inherits:
Base
  • Object
show all
Defined in:
lib/dolphin/git.rb

Overview

Git related commands

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Dolphin::Base

Instance Method Details

#checkout(tag = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dolphin/git.rb', line 24

def checkout(tag=nil)
  if tag
    command = "git checkout #{tag}"
  else
    command = "git checkout `cat #{@head_file}`"
  end
  menu = [
    "
      cd #{@deploy_dir}
      #{command}
    ",
  ]

  execute menu
end

#updateObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dolphin/git.rb', line 5

def update
  menu = [
    "
      cd #{@deploy_dir}
      # Save git head info
      git rev-parse HEAD > #{@head_file}
      git fetch
      git stash
      git checkout #{@branch}
      git rebase origin/#{@branch}
      git stash apply
      git stash clear
    ",
  ]

  execute menu
end