예제 #1
0
 /**
  * Downloads source code in the build workspace directory, optionally checking out the given branch/tag
  */
 function run_init($task = null, $args = array(), $cliOpts = array())
 {
     // download the current version into the workspace
     $targetDir = Builder::workspaceDir();
     // check if workspace exists and is not already set to the correct repo
     if (is_dir($targetDir) && pakeGit::isRepository($targetDir)) {
         $repo = new pakeGit($targetDir);
         $remotes = $repo->remotes();
         if (trim($remotes['origin']['fetch']) != Builder::option('repo')) {
             throw new Exception("Directory '{$targetDir}' exists and is not linked to correct git repo");
         }
         /// @todo should we not just fetch instead?
         $repo->pull();
     } else {
         pake_mkdirs(dirname($targetDir));
         $repo = pakeGit::clone_repository(Builder::option('repo'), Builder::workspaceDir());
     }
     $repo->checkout(Builder::option('branch'));
 }