Class: Deployku::GitPlugin

Inherits:
Plugin
  • Object
show all
Defined in:
lib/deployku/plugins/git.rb

Instance Method Summary collapse

Methods inherited from Plugin

<<, command_description, filter_plugins, find_plugin, help, inherited, instance, #packages, run

Instance Method Details

#hook(app_name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/deployku/plugins/git.rb', line 17

def hook(app_name)
  exit 1 unless app_name
  app_dir = Deployku::AppPlugin.instance.dir(app_name)
  app_name = File.basename(app_dir)
  unless Dir.exists?(app_dir)
    puts "Application directory '#{app_dir}' does not exist."
    exit 1
  end

  while line = $stdin.gets
    old_rev, new_rev, branch = line.chomp.split(' ')
    if branch != 'refs/heads/master'
      puts 'Only master branch is supported now.'
      exit 1
    end
  end
  unless new_rev
    puts 'Missing new revision number'
    exit 1
  end
  Deployku::AppPlugin.instance.rebuild(app_name, new_rev)
end

#receive_pack(app_name) ⇒ Object

describe :receive_pack, ‘<APP>’, ‘receives new commit’



6
7
8
9
10
11
12
13
14
# File 'lib/deployku/plugins/git.rb', line 6

def receive_pack app_name
  unless app_name
    exit 1
  end
  app_name = app_name.gsub(%r{'([^']+)'}, '\1')
  app_dir = Deployku::AppPlugin.instance.create(app_name)
  create_receive_hook(app_dir, File.basename(app_dir))
  system "git-shell -c \"git-receive-pack '#{app_dir}'\""
end