Method: Gitplate.install

Defined in:
lib/gitplate/gitplate.rb

.install(project_name, repository) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/gitplate/gitplate.rb', line 61

def self.install(project_name, repository)
  if (File.directory? project_name)
    fatal_msg_and_fail "Directory already exists"
  end

  info_msg "creating #{project_name} based on #{repository}"

  FileUtils.mkdir_p project_name
  
  source_repository_sha = get_plate_repository(project_name, repository)

  # we've got the repository cloned and cleaned up of existing git history
  Dir.chdir project_name do
    ensure_gitplate_dir
    
    update_config_with({
        :project => { :name => project_name },
        :repository => { :url => repository, :sha => source_repository_sha }
      })

    # pull in the plate file from the cloned repository
    if (File.exists?(plate_file))
      Gitplate::Plate.instance.run(
          plate_file,
          {
            :project_name => project_name,
            :project_dir => Dir.pwd
          })
    else
      debug_msg "no plate file found in repository"
    end

    g = Git.init
    g.add
    g.commit "Initial commit"
  end
end