Class: Gitty::HookCommand::Share
- Includes:
- FileUtils
- Defined in:
- lib/gitty/commands/share.rb
Instance Attribute Summary
Attributes inherited from Runner
Instance Method Summary collapse
-
#initialize(args, stdout = STDOUT, stderr = STDERR) ⇒ Share
constructor
A new instance of Share.
- #option_parser ⇒ Object
- #options ⇒ Object
- #run ⇒ Object
Methods inherited from Runner
Constructor Details
#initialize(args, stdout = STDOUT, stderr = STDERR) ⇒ Share
Returns a new instance of Share.
3 4 5 6 |
# File 'lib/gitty/commands/share.rb', line 3 def initialize(args, stdout = STDOUT, stderr = STDERR) super @hookname = args.shift end |
Instance Method Details
#option_parser ⇒ Object
29 30 31 32 33 |
# File 'lib/gitty/commands/share.rb', line 29 def option_parser @option_parser ||= super.tap do |opts| opts. = "Usage: git hook install [opts] hook-name" end end |
#options ⇒ Object
25 26 27 |
# File 'lib/gitty/commands/share.rb', line 25 def @options ||= super.update(:kind => :local) end |
#run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gitty/commands/share.rb', line 8 def run hook = Gitty::Hook.find(@hookname, :install_kind => :local) || Gitty::Hook.find(@hookname, :installed => false) if hook.nil? stderr.puts "no hook named '#{@hookname}' is available" exit 1 end if hook.install_kind == :shared stderr.puts "hook #{@hookname} is already installed" exit 1 end unless Gitty.sharing_enabled? stderr.puts "WARNING: sharing is disabled on your repository. Run git hook init --enable-sharing to turn it on." end hook.share! stdout.puts "To propagate this change other developers, run 'git hook publish -m \"added #{hook.name}...\"" end |