Class: Vlad::Git

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.setup_rake_tasksObject



44
45
46
47
48
49
50
51
# File 'lib/vlad/git.rb', line 44

def self.setup_rake_tasks
  desc "Sets up a Git clone to deploy from on the remote host"
  remote_task 'vlad:setup:git', :roles => :app do
    run source.setup
  end
  
  task('vlad:setup') { Rake::Task['vlad:setup:git'].invoke }
end

Instance Method Details

#checkout(revision, whatever) ⇒ Object

Returns the command that will check out revision from the repository. revision can be any SHA1 or equivalent (e.g. branch, tag, etc…)



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vlad/git.rb', line 20

def checkout(revision, whatever)
  revision = 'HEAD' if revision =~ /head/i
  
  ["cd #{scm_path}/repo",
   "#{git_cmd} fetch",
   "#{git_cmd} fetch --tags",
   "#{git_cmd} checkout -f #{revision}",
   "#{git_cmd} submodule init",
   "#{git_cmd} submodule update"
  ].join(" && ")
end

#export(revision, destination) ⇒ Object

Returns the command that will export revision from the repository into the directory destination.



36
37
38
39
40
41
42
# File 'lib/vlad/git.rb', line 36

def export(revision, destination)
  revision = 'HEAD' if revision == "."

  ["mkdir -p #{destination}",
   "cd #{scm_path}/repo && find . | grep -v '/.git' | cpio -p --make-directories #{destination}"
  ].join(" && ")
end

#setupObject

Sets up a repository on the remote server to fetch changes to and to deploy new releases from



10
11
12
13
# File 'lib/vlad/git.rb', line 10

def setup
  ["cd #{scm_path}",
   "#{git_cmd} clone #{repository} repo"].join(" && ")
end