示例#1
0
 /**
  * [checkOutMethod 导出/更新包库中的文件]
  * @param  [type] $product [产品]
  * @param  [type] $name    [包名]
  * @param  [type] $version [版本]
  * @return [array]          [code:0成功 1失败 error:失败信息 2找不到失败]
  */
 public function checkOutMethod($product, $name, $version)
 {
     $result = array('code' => 0, 'error' => '');
     $packageItem = new Package();
     $packageInfo = $packageItem->getInfo($product, $name, $version);
     if (empty($packageInfo)) {
         $result['code'] = 2;
         $result['error'] = "找不到包记录";
         return $result;
     }
     $path = $packageInfo['path'];
     $packagePath = $this->pkgHome . "/" . $path;
     $packageSvnPath = $packagePath . "/.svn";
     //跑脚本导出
     if (!is_dir($packagePath) || !is_dir($packageSvnPath)) {
         //use pkgsvn script
         $shellRun = new PkgSvn();
         $shellRunRes = $shellRun->checkout($path);
         if ($shellRunRes['code'] != 0) {
             $result['code'] = 1;
             $result['error'] = "导出包副本到workplace失败:{$path}" . $shellRunRes['msg'];
             return $result;
         }
     } else {
         $shellRun = new PkgSvn();
         $shellRunRes = $shellRun->update($path);
         if ($shellRunRes['code'] != 0) {
             $result['code'] = 1;
             $result['error'] = "更新包副本到workplace失败:{$path};" . $shellRunRes['msg'];
             return $result;
         }
     }
     return $result;
 }