Class: Gitty::HookCommand::Publish

Inherits:
Runner show all
Includes:
Gitty::Helpers
Defined in:
lib/gitty/commands/publish.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

#runObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/gitty/commands/publish.rb', line 4

def run
  rev = nil
  puts "Publishing with message #{options[:message].inspect}"
  with_env_var("GIT_OBJECT_DIRECTORY", File.join(Dir.pwd, ".git/objects")) do
    Dir.chdir(".git/hooks/shared") do
      cmd(*%w[git add . -A])
      cmd(*%w[git commit -m].push(options[:message]))
      rev = %x{git rev-parse HEAD}.chomp
    end
  end
  # back on the mother repo...
  cmd(*%w[git push origin -f].push("#{rev}:refs/heads/--hooks--"))
end