Class: Gitty::HookCommand::Shell

Inherits:
Runner show all
Includes:
Gitty::Helpers
Defined in:
lib/gitty/commands/shell.rb

Instance Attribute Summary

Attributes inherited from Runner

#args, #stderr, #stdout

Instance Method Summary collapse

Methods included from Gitty::Helpers

#cmd, #existing_directory!, #file_with_existing_directory!, #search_for_file_in_paths, #with_env_var

Methods inherited from Runner

#handle_show_help, #initialize, #options, run

Constructor Details

This class inherits a constructor from Gitty::Runner

Instance Method Details

#create_init_fileObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gitty/commands/shell.rb', line 9

def create_init_file
  "/tmp/gitty-shell-init".tap do |filename|
    File.open(filename, "wb") do |f|
      f.puts("      pushd $HOME > /dev/null\n        [ -f $HOME/.bashrc ] && . $HOME/.bashrc\n        [ -f $HOME/.bash_profile ] && . $HOME/.bash_profile\n      popd > /dev/null\n      export GIT_OBJECT_DIRECTORY=\"$(pwd)/.git/objects\"\n\n      export PS1=\"Shared Hooks [$(basename $(pwd))]$ \"\n      cd .git/hooks/shared\n      rm \"\#{filename}\"\n      EOF\n    end\n  end\nend\n")

#option_parserObject



27
28
29
30
31
# File 'lib/gitty/commands/shell.rb', line 27

def option_parser
  super.tap do |opts|
    opts.banner = "Usage: git hook shell"
  end
end

#runObject



5
6
7
# File 'lib/gitty/commands/shell.rb', line 5

def run
  exec "bash --init-file #{create_init_file}"
end