Sha256: 7d8b2222512b4cf44e37266da18fa8bb0efecab3361f49a19126d39ae3380255

Contents?: true

Size: 1.8 KB

Versions: 2

Compression:

Stored size: 1.8 KB

Contents

#!/usr/bin/env ruby

require 'simple_shell'
require 'heidi'

cmd   = ARGV.shift
for_a = ARGV.shift

shell = SimpleShell.new

def check_heidi_root()
  if !File.exists?("./projects")  && File.directory?("./projects")
    $stderr.puts "You're not inside Heidi"
    exit 1
  end
end

case cmd
when "new"
  puts "creating #{for_a}"
  puts "creating #{for_a}/projects"
  shell.mkdir %W(-p #{for_a}/projects)
  puts "creating #{for_a}/bin"
  shell.mkdir %W(-p #{for_a}/bin)

when "project"
  check_heidi_root

  # create a logs dir
  puts "creating projects/#{for_a}"
  puts "creating projects/#{for_a}/logs"
  shell.mkdir %W(-p projects/#{for_a}/logs)

  %w(build tests failure success before).each do |hook|
    puts "creating projects/#{for_a}/hooks/#{hook}"
    shell.mkdir %W(-p projects/#{for_a}/hooks/#{hook})
  end

  # make a clone
  shell.in("projects/#{for_a}") do |sh|
    puts "filling #{for_a} cache"
    repo = ARGV.shift
    puts "git clone #{repo}"
    sh.git %W(clone #{repo} cached)

    sh.in("cached") do |cached|
      puts "setting the name of the project to: #{for_a}"
      cached.git %W(config heidi.name #{for_a})
    end
  end
  puts "\n"
  puts "Now define some hooks in projects/#{for_a}/hooks/tests"

when "drop"
  check_heidi_root

  # remove build and cache dir, expose logs directly
  puts "removing build dir"
  shell.rm %W(-r projects/#{for_a}/build)
  puts "removing cache (preserving project config)"
  shell.cp %W(-pr projects/#{for_a}/cached/.git/config projects/#{for_a})
  shell.rm %W(-r projects/#{for_a}/cached)
  puts "exposing builds"
  shell.mv %W(projects/#{for_a}/logs/* projects/#{for_a}/)
  shell.rm %W(-r projects/#{for_a}/logs)

when "integrate"
  heidi = Heidi.new
  heidi.projects.each do |project|
    next if !for_a.nil? && project.name != for_a
    project.fetch && project.integrate
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
heidi-0.0.3 bin/heidi
heidi-0.0.2 bin/heidi