Class: PrePushHook

Inherits:
Object
  • Object
show all
Defined in:
lib/sfb_scripts/hooks/pre_push_hook.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, env) ⇒ PrePushHook

Returns a new instance of PrePushHook.



8
9
10
11
12
# File 'lib/sfb_scripts/hooks/pre_push_hook.rb', line 8

def initialize(command, env)
  @shell = env[:shell]
  @repo = env[:repo]
  @push_command = command
end

Instance Attribute Details

#push_commandObject (readonly)

Returns the value of attribute push_command.



7
8
9
# File 'lib/sfb_scripts/hooks/pre_push_hook.rb', line 7

def push_command
  @push_command
end

#repoObject (readonly)

Returns the value of attribute repo.



7
8
9
# File 'lib/sfb_scripts/hooks/pre_push_hook.rb', line 7

def repo
  @repo
end

#shellObject (readonly)

Returns the value of attribute shell.



7
8
9
# File 'lib/sfb_scripts/hooks/pre_push_hook.rb', line 7

def shell
  @shell
end

Class Method Details

.check(command, env) ⇒ Object



3
4
5
# File 'lib/sfb_scripts/hooks/pre_push_hook.rb', line 3

def self.check(command, env)
  new(command, env).check
end

Instance Method Details

#checkObject



14
15
16
17
18
19
# File 'lib/sfb_scripts/hooks/pre_push_hook.rb', line 14

def check
  if affects_master? && is_destructive?
    shell.warn "[Policy] Don't force push or delete master.  (Denied by pre-push hook)"
    exit 1
  end
end