Sha256: 5e8e12fac5dcee28c2422923a2bf2b999b8f22fa06793d1b3e5dd963ba721dbe

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 KB

Contents

module Orly
  module Installation

    HOOK_PATH = File.join ".git", "hooks", "post-merge"
    HOOK_DIR  = File.join ".git", "hooks"
    HOOK_CONTENT = <<END
#!/bin/sh
orly --run
END

    def self.install
        if not File.directory?(".git")
          puts "You don't appear to be in the base directory of a git project.".red
          exit 1
        end

        Dir.mkdir(HOOK_DIR) unless File.directory?(HOOK_DIR)

        if File.exists? HOOK_PATH
          puts "A post-merge hook already exists for this project.".red
          exit 1
        end

        File.open(HOOK_PATH, 'w') {|f| f.write(HOOK_CONTENT) }
        FileUtils.chmod 0755, HOOK_PATH
        puts "installed O RLY hook as:".green
        puts "  -> #{File.expand_path(HOOK_PATH)}".green
        puts "(to remove later, you can use: orly --uninstall)"
    end

    def self.uninstall
      if File.exists? HOOK_PATH
        FileUtils.rm HOOK_PATH
        puts "uninstalled #{HOOK_PATH}".green
      else
        puts "O RLY is not enabled for this directory, so there is nothing to uninstall.".yellow
      end
    end


  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
orly-0.0.15 lib/orly/installation.rb
orly-0.0.14 lib/orly/installation.rb
orly-0.0.13 lib/orly/installation.rb
orly-0.0.12 lib/orly/installation.rb
orly-0.0.11 lib/orly/installation.rb
orly-0.0.10 lib/orly/installation.rb
orly-0.0.9 lib/orly/installation.rb
orly-0.0.8 lib/orly/installation.rb
orly-0.0.7 lib/orly/installation.rb
orly-0.0.6 lib/orly/installation.rb
orly-0.0.5 lib/orly/installation.rb
orly-0.0.4 lib/orly/installation.rb