Class: Moron::Hook

Inherits:
Object
  • Object
show all
Defined in:
lib/moron/hook.rb

Constant Summary collapse

KEY_PREFIX =
%[command="%b %u -r %d",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty]

Instance Method Summary collapse

Constructor Details

#initialize(path, binary_path) ⇒ Hook

Returns a new instance of Hook.



4
5
6
7
# File 'lib/moron/hook.rb', line 4

def initialize(path, binary_path)
  @path = path
  @binary_path = binary_path
end

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/moron/hook.rb', line 9

def run
  if !@path.match(/\.git$/)
  puts "Is this a git repository ?"
  exit 1
  end
  require 'git'
  g = Git.bare(@path)
  t = g.gtree('HEAD^{tree}')
  t = t.subtrees["keydir"]
  File.open File.expand_path("~/.ssh/authorized_keys"), 'w' do |f|
  write_keys(t, f)
  end
end