* add api for integrate svn/git.
This commit is contained in:
@@ -107,4 +107,56 @@ class git extends control
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax save log.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxSaveLog()
|
||||
{
|
||||
$repoUrl = trim($this->post->repoUrl);
|
||||
$repoRoot = str_replace('\\', '/', trim($this->post->repoRoot));
|
||||
$message = trim($this->post->message);
|
||||
$revision = trim($this->post->revision);
|
||||
$files = $this->post->files;
|
||||
|
||||
/* Ignore git. */
|
||||
if(strpos($repoUrl, '://') === false) die();
|
||||
|
||||
$parsedFiles = array();
|
||||
foreach($files as $file)
|
||||
{
|
||||
$file = trim($file);
|
||||
if(empty($file)) continue;
|
||||
$path = str_replace($repoRoot, '', $file);
|
||||
$parsedFiles[''][] = $path;
|
||||
}
|
||||
|
||||
$objects = $this->git->parseComment($message);
|
||||
if($objects)
|
||||
{
|
||||
$log = new stdclass();
|
||||
$log->author = $this->app->user->account;
|
||||
$log->date = helper::now();
|
||||
$log->msg = $message;
|
||||
$log->revision = $revision;
|
||||
$log->files = $parsedFiles;
|
||||
$this->git->saveAction2PMS($objects, $log, $repoUrl);
|
||||
}
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get repos.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetRepos()
|
||||
{
|
||||
$repos = $this->git->getRepos();
|
||||
die(json_encode($repos));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,6 +187,25 @@ class gitModel extends model
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get repos.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getRepos()
|
||||
{
|
||||
$repos = array();
|
||||
if(!$this->config->git->repos) return $repos;
|
||||
|
||||
foreach($this->config->git->repos as $repo)
|
||||
{
|
||||
if(empty($repo['path'])) continue;
|
||||
$repos[] = $repo['path'];
|
||||
}
|
||||
return $repos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set repo.
|
||||
*
|
||||
|
||||
@@ -135,4 +135,16 @@ class svn extends control
|
||||
}
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get repos.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetRepos()
|
||||
{
|
||||
$repos = $this->svn->getRepos();
|
||||
die(json_encode($repos));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,6 +186,25 @@ class svnModel extends model
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get repos.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getRepos()
|
||||
{
|
||||
$repos = array();
|
||||
if(!$this->config->svn->repos) return $repos;
|
||||
|
||||
foreach($this->config->svn->repos as $repo)
|
||||
{
|
||||
if(empty($repo['path'])) continue;
|
||||
$repos[] = $repo['path'];
|
||||
}
|
||||
return $repos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set repo.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user