Module: VagrantPlugins::VagrantGit::Git
- Defined in:
- lib/vagrant-git/git.rb
Class Method Summary collapse
- .clone(target, path, opts = {}) ⇒ Object
- .fetch(path) ⇒ Object
- .pull(path, opts = {}) ⇒ Object
-
.run(cmd) ⇒ Object
Run the command, wait for exit and return the Process object.
- .set_upstream(path, target) ⇒ Object
- .submodule(path) ⇒ Object
Class Method Details
.clone(target, path, opts = {}) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/vagrant-git/git.rb', line 12 def clone(target, path, opts = {}) branch = opts[:branch] if branch.nil? return run("git clone '#{target}' '#{path}'") else return run("git clone -b '#{branch}' '#{target}' '#{path}'") end end |
.fetch(path) ⇒ Object
20 21 22 |
# File 'lib/vagrant-git/git.rb', line 20 def fetch(path) return run("cd '#{path}'; git fetch") end |
.pull(path, opts = {}) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/vagrant-git/git.rb', line 24 def pull(path, opts = {}) branch = opts[:branch] if branch.nil? return run("cd '#{path}'; git fetch; git pull;") else return run("cd '#{path}'; git pull origin '#{branch}';") end end |
.run(cmd) ⇒ Object
Run the command, wait for exit and return the Process object.
6 7 8 9 10 |
# File 'lib/vagrant-git/git.rb', line 6 def run(cmd) pid = spawn(cmd) Process.waitpid(pid) return $? end |
.set_upstream(path, target) ⇒ Object
37 38 39 |
# File 'lib/vagrant-git/git.rb', line 37 def set_upstream(path, target) return run("cd '#{path}'; git remote set-url origin '#{target}';") end |
.submodule(path) ⇒ Object
33 34 35 |
# File 'lib/vagrant-git/git.rb', line 33 def submodule(path) return run("cd '#{path}' && git submodule update --init --recursive") end |