Class: Sabre::Git
Instance Method Summary collapse
Methods inherited from Command
#indent, #initialize, #method_missing, #on, #on_error, #on_host, #run, #to_s, #unindent
Methods included from Base
#cd, #cp, #echo, #mv, #set, #synchronize
Constructor Details
This class inherits a constructor from Sabre::Command
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Sabre::Command
Instance Method Details
#clone(options) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/sabre/git.rb', line 4 def clone() repository = [:repository] directory = [:directory] branch = [:branch] || "publish" remote = [:remote] || "origin" revision = [:revision] || "#{ remote }/#{ branch }" run "mkdir -p #{ directory }" run "git clone -o #{ remote } -b #{ branch } #{ repository } #{ directory }" end |
#fetch(options) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sabre/git.rb', line 17 def fetch() repository = [:repository] directory = [:directory] branch = [:branch] || "publish" remote = [:remote] || "origin" revision = [:revision] || "#{ remote }/#{ branch }" cd directory run "git config remote.#{ remote }.url #{ repository }" run "git config remote.#{ remote }.fetch +refs/heads/*:refs/remotes/#{ remote }/*" run "git fetch #{ remote }" run "git fetch --tags #{ remote }" run "git checkout -f -q #{ branch }" run "git reset --hard #{ revision }" end |
#update(options) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sabre/git.rb', line 35 def update() directory = [:directory] fetch_command = Sabre::Git.new { fetch() } clone_command = Sabre::Git.new { clone() } run %{ if [ -d "#{ directory }/.git" ]; then #{ indent fetch_command } else #{ indent clone_command } fi } end |