* Modify gogs repo.

This commit is contained in:
caoyanyi
2022-08-01 15:40:55 +08:00
parent f94aff639d
commit 4b1dde8c7e
23 changed files with 871 additions and 177 deletions
+1 -1
View File
@@ -551,7 +551,7 @@ class Gitea
{
if(!scm::checkRevision($revision)) return array();
if($revision == 'HEAD' and $branch) $revision = $branch;
if($revision == 'HEAD' and $branch) $revision = 'origin/' . $branch;
$revision = is_numeric($revision) ? "--skip=$revision $branch" : $revision;
$count = $count == 0 ? '' : "-n $count";
+1 -1
View File
@@ -540,7 +540,7 @@ class GitRepo
{
if(!scm::checkRevision($revision)) return array();
if($revision == 'HEAD' and $branch) $revision = $branch;
if($revision == 'HEAD' and $branch) $revision = 'origin/' . $branch;
$revision = is_numeric($revision) ? "--skip=$revision $branch" : $revision;
$count = $count == 0 ? '' : "-n $count";
+692
View File
@@ -0,0 +1,692 @@
<?php
class Gogs
{
public $client;
public $root;
/**
* Construct
*
* @param string $client
* @param string $root
* @param string $username
* @param string $password
* @param string $encoding
* @param object $repo
* @access public
* @return void
*/
public function __construct($client, $root, $username, $password, $encoding = 'UTF-8', $repo = null)
{
putenv('LC_CTYPE=en_US.UTF-8');
$this->client = $client;
$this->root = rtrim($root, DIRECTORY_SEPARATOR);
if(!realpath($this->root) and !empty($repo))
{
global $app;
$project = $app->control->loadModel('gogs')->apiGetSingleProject($repo->serviceHost, $repo->serviceProject);
if(isset($project->tokenCloneUrl))
{
$cmd = 'git clone --progress -v "' . $project->tokenCloneUrl . '" "' . $this->root . '"';
exec($cmd);
}
}
$branch = isset($_COOKIE['repoBranch']) ? $_COOKIE['repoBranch'] : '';
if($branch)
{
$branches = $this->branch();
if(isset($branches[$branch])) $branch = "origin/$branch";
}
$this->branch = $branch;
chdir($this->root);
exec("{$this->client} config core.quotepath false");
}
/**
* List files.
*
* @param string $path
* @param string $revision
* @access public
* @return array
*/
public function ls($path, $revision = 'HEAD')
{
if(!scm::checkRevision($revision)) return array();
$path = ltrim($path, DIRECTORY_SEPARATOR);
$sub = '';
chdir($this->root);
if(!empty($path)) $sub = ":$path";
if(!empty($this->branch))$revision = $this->branch;
execCmd(escapeCmd("$this->client pull"));
$cmd = escapeCmd("$this->client ls-tree -l $revision$sub");
$list = execCmd($cmd . ' 2>&1', 'array', $result);
if($result) return array();
$infos = array();
foreach($list as $entry)
{
list($mod, $kind, $revision, $size, $name) = preg_split('/[\t ]+/', $entry);
/* Get commit info. */
$pathName = ltrim($path . DIRECTORY_SEPARATOR . $name, DIRECTORY_SEPARATOR);
$cmd = escapeCmd("$this->client log -1 $this->branch -- $pathName");
$commit = execCmd($cmd, 'array');
$logs = $this->parseLog($commit);
if($size > 1024 * 1024)
{
$size = round($size / (1024 * 1024), 2) . 'MB';
}
else if($size > 1024)
{
$size = round($size / 1024, 2) . 'KB';
}
else
{
$size .= 'Bytes';
}
$info = new stdClass();
$info->name = $name;
$info->kind = $kind == 'tree' ? 'dir' : 'file';
$info->revision = $logs ? $logs[0]->revision : $revision;
$info->size = $size;
$info->account = $logs ? $logs[0]->committer : '';
$info->date = $logs ? $logs[0]->time : '';
$info->comment = $logs ? $logs[0]->comment : '';
$infos[] = $info;
unset($info);
}
/* Sort by kind */
foreach($infos as $key => $info) $kinds[$key] = $info->kind;
if($infos) array_multisort($kinds, SORT_ASC, $infos);
return $infos;
}
/**
* Get tags
*
* @param string $path
* @param string $revision
* @access public
* @return array
*/
public function tags($path, $revision = 'HEAD')
{
if(!scm::checkRevision($revision)) return array();
chdir($this->root);
$cmd = escapeCmd("$this->client tag --sort=taggerdate");
$list = execCmd($cmd . ' 2>&1', 'array', $result);
if($result) return array();
foreach($list as $key => $tag)
{
if(!$tag) unset($list[$key]);
}
return $list;
}
/**
* Get branch.
*
* @access public
* @return array
*/
public function branch()
{
chdir($this->root);
/* Get local branch. */
$cmd = escapeCmd("$this->client branch -a");
$list = execCmd($cmd . ' 2>&1', 'array', $result);
if($result) return array();
/* Get default branch. */
$defaultBranch = execCmd("$this->client symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'");
$defaultBranch = trim($defaultBranch);
$branches = array();
foreach($list as $localBranch)
{
$localBranch = trim($localBranch);
if(substr($localBranch, 0, 19) == 'remotes/origin/HEAD') continue;
if(substr($localBranch, 0, 1) == '*') $localBranch = substr($localBranch, 1);
if(substr($localBranch, 0, 15) == 'remotes/origin/') $localBranch = substr($localBranch, 15);
$localBranch = trim($localBranch);
if(empty($localBranch))continue;
if($localBranch != $defaultBranch) $branches[$localBranch] = $localBranch;
}
asort($branches);
if($defaultBranch) $branches = array($defaultBranch => $defaultBranch) + $branches;
return $branches;
}
/**
* Get last log.
*
* @param string $path
* @param int $count
* @access public
* @return array
*/
public function getLastLog($path, $count = 10)
{
$path = ltrim($path, DIRECTORY_SEPARATOR);
$revision = $this->branch ? $this->branch : 'HEAD';
chdir($this->root);
$list = execCmd(escapeCmd("$this->client log -10 $revision -- $path"), 'array');
$logs = $this->parseLog($list);
return $logs;
}
/**
* Get logs
*
* @param string $path
* @param string $fromRevision
* @param string $toRevision
* @param int $count
* @access public
* @return array
*/
public function log($path, $fromRevision = 0, $toRevision = 'HEAD', $count = 0)
{
if(!scm::checkRevision($fromRevision)) return array();
if(!scm::checkRevision($toRevision)) return array();
$path = ltrim($path, DIRECTORY_SEPARATOR);
$count = $count == 0 ? '' : "-n $count";
/* compatible with svn. */
if($fromRevision == 'HEAD' and $this->branch) $fromRevision = $this->branch;
if($toRevision == 'HEAD' and $this->branch) $toRevision = $this->branch;
if($fromRevision === $toRevision)
{
$logs = array();
chdir($this->root);
$list = execCmd(escapeCmd("$this->client log --stat=1024 --name-status --stat-name-width=1000 -1 $fromRevision -- $path"), 'array');
$logs = $this->parseLog($list);
return $logs;
}
if(!$fromRevision)
{
$revisions = " $toRevision";
}
else
{
$revisions = "$fromRevision..$toRevision";
}
chdir($this->root);
$list = execCmd(escapeCmd("$this->client log --stat=1024 --name-status --stat-name-width=1000 $count $revisions -- $path"), 'array');
$logs = $this->parseLog($list);
return $logs;
}
/**
* Blame file
*
* @param string $path
* @param string $revision
* @access public
* @return array
*/
public function blame($path, $revision)
{
if(!scm::checkRevision($revision)) return array();
$path = ltrim($path, DIRECTORY_SEPARATOR);
chdir($this->root);
$list = execCmd(escapeCmd("$this->client blame -l $revision -- $path"), 'array');
$blames = array();
$revLine = 0;
$revision = '';
foreach($list as $line)
{
if(empty($line)) continue;
if($line[0] == '^') $line = substr($line, 1);
preg_match('/^([0-9a-f]{39,40})\s.*\((\S+)\s+([\d-]+)\s(.*)\s(\d+)\)(.*)$/U', $line, $matches);
if(isset($matches[1]) and $matches[1] != $revision)
{
$blame = array();
$blame['revision'] = $matches[1];
$blame['committer'] = $matches[2];
$blame['time'] = $matches[3];
$blame['line'] = $matches[5];
$blame['lines'] = 1;
$blame['content'] = strpos($matches[6], ' ') === false ? $matches[6] : substr($matches[6], 1);
$revision = $matches[1];
$revLine = $matches[5];
$blames[$revLine] = $blame;
}
elseif(isset($matches[5]))
{
$blame = array();
$blame['line'] = $matches[5];
$blame['content'] = strpos($matches[6], ' ') === false ? $matches[6] : substr($matches[6], 1);
$blames[$matches[5]] = $blame;
$blames[$revLine]['lines'] ++;
}
}
return $blames;
}
/**
* Diff file.
*
* @param string $path
* @param string $fromRevision
* @param string $toRevision
* @param string $extra
* @access public
* @return array
*/
public function diff($path, $fromRevision, $toRevision, $extra = '')
{
if(!scm::checkRevision($fromRevision) and $extra != 'isBranchOrTag') return array();
if(!scm::checkRevision($toRevision) and $extra != 'isBranchOrTag') return array();
$path = ltrim($path, DIRECTORY_SEPARATOR);
chdir($this->root);
if($toRevision == 'HEAD' and $this->branch) $toRevision = $this->branch;
if($fromRevision == '^') $fromRevision = $toRevision . '^';
if(strpos($fromRevision, '^') !== false)
{
$list = execCmd(escapeCmd("$this->client log -2 $toRevision --pretty=format:%H -- $path"), 'array');
if(isset($list[1])) $fromRevision = $list[1];
}
$lines = execCmd(escapeCmd("$this->client diff $fromRevision $toRevision -- $path"), 'array');
return $lines;
}
/**
* Cat file.
*
* @param string $entry
* @param string $revision
* @access public
* @return string
*/
public function cat($entry, $revision = 'HEAD')
{
if(!scm::checkRevision($revision)) return false;
chdir($this->root);
if($revision == 'HEAD' and $this->branch) $revision = $this->branch;
$cmd = escapeCmd("$this->client show $revision:$entry");
$content = execCmd($cmd);
if(is_array($content)) $content = implode("\n", $content);
return $content;
}
/**
* Get info.
*
* @param string $entry
* @param string $revision
* @access public
* @return object
*/
public function info($entry, $revision = 'HEAD')
{
if(!scm::checkRevision($revision)) return false;
chdir($this->root);
if($revision == 'HEAD' and $this->branch) $revision = $this->branch;
$path = ltrim($entry, DIRECTORY_SEPARATOR);
$cmd = escapeCmd("$this->client ls-tree $revision -- $path");
$result = execCmd($cmd);
$kind = '';
if($result)
{
$results = explode("\n", trim($result));
if(count($results) >= 2)
{
$kind = 'dir';
}
else
{
list($mode, $type) = explode(' ', $results[0]);
$kind = $type == 'tree' ? 'dir' : 'file';
}
}
$list = execCmd(escapeCmd("$this->client log -1 $revision --pretty=format:%H -- $path"), 'array');
$revision = $list[0];
$info = new stdclass();
$info->kind = $kind;
$info->path = $entry;
$info->revision = $revision;
$info->root = $this->root;
return $info;
}
/**
* Exec git cmd.
*
* @param string $cmd
* @access public
* @return array
*/
public function exec($cmd)
{
chdir($this->root);
return execCmd(escapeCmd("$this->client $cmd"), 'array');
}
/**
* Parse diff.
*
* @param array $lines
* @access public
* @return array
*/
public function parseDiff($lines)
{
if(empty($lines)) return array();
$diffs = array();
$num = count($lines);
$endLine = end($lines);
if(strpos($endLine, '\ No newline at end of file') === 0) $num -= 1;
$newFile = false;
$allFiles = array();
for($i = 0; $i < $num; $i ++)
{
$diffFile = new stdclass();
if(strpos($lines[$i], "diff --git ") === 0)
{
$fileInfo = explode(' ',$lines[$i]);
$fileName = substr($fileInfo[2], strpos($fileInfo[2], '/') + 1);
/* Prevent duplicate display of files. */
if(in_array($fileName, $allFiles)) continue;
$allFiles[] = $fileName;
$diffFile->fileName = $fileName;
for($i++; $i < $num; $i ++)
{
$diff = new stdclass();
/* Fix bug #1757. */
if($lines[$i] == '+++ /dev/null') $newFile = true;
if(strpos($lines[$i], '+++', 0) !== false) continue;
if(strpos($lines[$i], '---', 0) !== false) continue;
if(strpos($lines[$i], '======', 0) !== false) continue;
if(preg_match('/^@@ -(\\d+)(,(\\d+))?\\s+\\+(\\d+)(,(\\d+))?\\s+@@/A', $lines[$i]))
{
$startLines = trim(str_replace(array('@', '+', '-'), '', $lines[$i]));
list($oldStartLine, $newStartLine) = explode(' ', $startLines);
list($diff->oldStartLine) = explode(',', $oldStartLine);
list($diff->newStartLine) = explode(',', $newStartLine);
$oldCurrentLine = $diff->oldStartLine;
$newCurrentLine = $diff->newStartLine;
if($newFile)
{
$oldCurrentLine = $diff->newStartLine;
$newCurrentLine = $diff->oldStartLine;
}
$newLines = array();
for($i++; $i < $num; $i ++)
{
if(preg_match('/^@@ -(\\d+)(,(\\d+))?\\s+\\+(\\d+)(,(\\d+))?\\s+@@/A', $lines[$i]))
{
$i --;
break;
}
if(strpos($lines[$i], "diff --git ") === 0) break;
$line = $lines[$i];
if(strpos($line, '\ No newline at end of file') === 0)continue;
$sign = empty($line) ? '' : $line[0];
if($sign == '-' and $newFile) $sign = '+';
$type = $sign != '-' ? $sign == '+' ? 'new' : 'all' : 'old';
if($sign == '-' || $sign == '+')
{
$line = substr_replace($line, ' ', 1, 0);
if($newFile) $line = preg_replace('/^\-/', '+', $line);
}
$newLine = new stdclass();
$newLine->type = $type;
$newLine->oldlc = $type != 'new' ? $oldCurrentLine : '';
$newLine->newlc = $type != 'old' ? $newCurrentLine : '';
$newLine->line = htmlSpecialString($line);
if($type != 'new') $oldCurrentLine++;
if($type != 'old') $newCurrentLine++;
$newLines[] = $newLine;
}
$diff->lines = $newLines;
$diffFile->contents[] = $diff;
}
if(isset($lines[$i]) and strpos($lines[$i], "diff --git ") === 0)
{
$i --;
$newFile = false;
break;
}
}
$diffs[] = $diffFile;
}
}
return $diffs;
}
/**
* Get commit count.
*
* @param int $commits
* @param string $lastVersion
* @access public
* @return int
*/
public function getCommitCount($commits = 0, $lastVersion = '')
{
if(!scm::checkRevision($lastVersion)) return false;
chdir($this->root);
$revision = $this->branch ? $this->branch : 'HEAD';
return execCmd(escapeCmd("$this->client rev-list --count $revision -- ./"), 'string');
}
/**
* Get first revision.
*
* @access public
* @return string
*/
public function getFirstRevision()
{
chdir($this->root);
$list = execCmd(escapeCmd("$this->client rev-list --reverse HEAD -- ./"), 'array');
return $list[0];
}
/**
* Get latest revision
*
* @access public
* @return string
*/
public function getLatestRevision()
{
chdir($this->root);
$revision = $this->branch ? $this->branch : 'HEAD';
$list = execCmd(escapeCmd("$this->client rev-list -1 $revision -- ./"), 'array');
return $list[0];
}
/**
* Get commits.
*
* @param string $rversion
* @param int $count
* @param string $branch
* @access public
* @return array
*/
public function getCommits($revision = '', $count = 0, $branch = '')
{
if(!scm::checkRevision($revision)) return array();
if($revision == 'HEAD' and $branch) $revision = $branch;
$count = $count == 0 ? '' : "-n $count";
chdir($this->root);
if($branch)
{
execCmd(escapeCmd("$this->client checkout $branch"));
execCmd(escapeCmd("$this->client pull"));
}
$list = execCmd(escapeCmd("$this->client log $count $revision -- ./"), 'array');
$commits = $this->parseLog($list);
$logs = array();
foreach($commits as $commit)
{
$hash = $commit->revision;
$log = new stdClass();
$log->committer = $commit->committer;
$log->revision = $commit->revision;
$log->comment = $commit->comment;
$log->time = $commit->time;
$logs['commits'][$hash] = $log;
$logs['files'][$hash] = array();
}
if(empty($logs)) return $logs;
$hash = '';
$files = execCmd(escapeCmd("$this->client whatchanged $count $revision --pretty=format:%an@_@%cd@_@%H@_@%s -- ./"), 'array');
foreach($files as $commit)
{
$commit = trim($commit);
if(empty($commit)) continue;
$parsedCommit = explode('@_@', $commit);
if(count($parsedCommit) == 4)
{
list($account, $date, $hash, $comment) = $parsedCommit;
}
else
{
$file = explode(' ', $commit);
$file = explode("\t", end($file));
if(!isset($file[1])) $file[1] = '';
list($action, $path) = $file;
$parsedFile = new stdclass();
$parsedFile->revision = $hash;
$parsedFile->path = '/' . trim($path);
$parsedFile->type = 'file';
$parsedFile->action = $action;
$logs['files'][$hash][] = $parsedFile;
}
}
return $logs;
}
/**
* Get clone url.
*
* @access public
* @return string
*/
public function getCloneUrl()
{
$url = new stdclass();
$remote = execCmd(escapeCmd("$this->client remote -v"), 'array');
$pregHttp = '/http(s)?:\/\/(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/\w+)*\.git/';
$pregSSH = '/ssh:\/\/git@[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/\w+)*\.git/';
if(preg_match($pregHttp, $remote[0], $matches)) $url->http = $matches[0];
if(preg_match($pregSSH, $remote[0], $matches)) $url->ssh = $matches[0];
return $url;
}
/**
* Parse log.
*
* @param array $logs
* @access public
* @return array
*/
public function parseLog($logs)
{
$parsedLogs = array();
$i = 0;
foreach($logs as $line)
{
if(strpos($line, 'commit ') === 0)
{
if(isset($log))
{
$log->comment = trim($comment);
$log->change = $changes;
$parsedLogs[$i] = $log;
$i++;
}
$log = new stdclass();
$comment = '';
$changes = array();
$log->revision = trim(preg_replace('/^commit/', '', $line));
}
elseif(strpos($line, 'Author:') === 0)
{
$account = preg_replace('/^Author:/', '', $line);
$log->committer = trim(preg_replace('/<[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-\.]+>/', '', $account));
}
elseif(strpos($line, 'Date:') === 0)
{
$date = trim(preg_replace('/^Date:/', '', $line));
$log->time = date('Y-m-d H:i:s', strtotime($date));
}
elseif(preg_match('/^\s{2,}/', $line))
{
$comment .= $line;
}
elseif(strpos($line, "\t") !== false)
{
list($action, $entry) = explode("\t", $line);
$entry = '/' . trim($entry);
$pathInfo = array();
$pathInfo['action'] = $action;
$pathInfo['kind'] = 'file';
$changes[$entry] = $pathInfo;
}
}
if(isset($log))
{
$log->comment = trim($comment);
$log->change = $changes;
$parsedLogs[$i] = $log;
}
return $parsedLogs;
}
}
+14 -8
View File
@@ -128,18 +128,24 @@ class gitModel extends model
$branches = $this->repo->getBranches($repo);
$commits = $repo->commits;
$gitlabAccountPairs = array();
$accountPairs = array();
if($repo->SCM == 'Gitlab')
{
$gitlabUserList = $this->loadModel('gitlab')->apiGetUsers($repo->gitService);
$acountIDPairs = $this->gitlab->getUserIdAccountPairs($repo->gitService);
foreach($gitlabUserList as $gitlabUser) $gitlabAccountPairs[$gitlabUser->realname] = zget($acountIDPairs, $gitlabUser->id, '');
$userList = $this->loadModel('gitlab')->apiGetUsers($repo->gitService);
$acountIDPairs = $this->gitlab->getUserIdAccountPairs($repo->gitService);
foreach($userList as $gitlabUser) $accountPairs[$gitlabUser->realname] = zget($acountIDPairs, $gitlabUser->id, '');
}
elseif($repo->SCM == 'Gitea')
{
$gitlabUserList = $this->loadModel('gitea')->apiGetUsers($repo->gitService);
$acountIDPairs = $this->gitea->getUserAccountIdPairs($repo->gitService, 'openID,account');
foreach($gitlabUserList as $gitlabUser) $gitlabAccountPairs[$gitlabUser->realname] = zget($acountIDPairs, $gitlabUser->id, '');
$userList = $this->loadModel('gitea')->apiGetUsers($repo->gitService);
$acountIDPairs = $this->gitea->getUserAccountIdPairs($repo->gitService, 'openID,account');
foreach($userList as $gitlabUser) $accountPairs[$gitlabUser->realname] = zget($acountIDPairs, $gitlabUser->id, '');
}
elseif($repo->SCM == 'Gogs')
{
$userList = $this->loadModel('gogs')->apiGetUsers($repo->gitService);
$acountIDPairs = $this->gogs->getUserAccountIdPairs($repo->gitService, 'openID,account');
foreach($userList as $gitlabUser) $accountPairs[$gitlabUser->realname] = zget($acountIDPairs, $gitlabUser->id, '');
}
/* Update code commit history. */
@@ -180,7 +186,7 @@ class gitModel extends model
' task:' . join(' ', $objects['tasks']) .
' bug:' . join(',', $objects['bugs']));
$this->repo->saveAction2PMS($objects, $log, $this->repoRoot, $repo->encoding, 'git', $gitlabAccountPairs);
$this->repo->saveAction2PMS($objects, $log, $this->repoRoot, $repo->encoding, 'git', $accountPairs);
}
else
{
+34 -118
View File
@@ -12,14 +12,6 @@
class gogsModel extends model
{
const HOOK_PUSH_EVENT = 'Push Hook';
/* Gitlab access level. */
public $noAccess = 0;
public $developerAccess = 30;
public $maintainerAccess = 40;
/**
* Get a gogs by id.
*
@@ -62,23 +54,15 @@ class gogsModel extends model
* Get gogs api base url by gogs id.
*
* @param int $gogsID
* @param bool $sudo
* @access public
* @return string
*/
public function getApiRoot($gogsID, $sudo = true)
public function getApiRoot($gogsID)
{
$gogs = $this->getByID($gogsID);
if(!$gogs) return '';
$sudoParam = '';
if($sudo == true and !$this->app->user->admin)
{
$openID = $this->getUserIDByZentaoAccount($gogsID, $this->app->user->account);
if($openID) $sudoParam = "&sudo={$openID}";
}
return rtrim($gogs->url, '/') . '/api/v1%s' . "?token={$gogs->token}" . $sudoParam;
return rtrim($gogs->url, '/') . '/api/v1%s' . "?token={$gogs->token}";
}
/**
@@ -207,45 +191,6 @@ class gogsModel extends model
return false;
}
/**
* Check user access.
*
* @param int $gogsID
* @param int $projectID
* @param object $project
* @param string $maxRole
* @access public
* @return bool
*/
public function checkUserAccess($gogsID, $projectID = 0, $project = null, $groupIDList = array(), $maxRole = 'maintainer')
{
if($this->app->user->admin) return true;
if($project == null) $project = $this->apiGetSingleProject($gogsID, $projectID);
if(!isset($project->id)) return false;
$accessLevel = $this->config->gogs->accessLevel[$maxRole];
if(isset($project->permissions->project_access->access_level) and $project->permissions->project_access->access_level >= $accessLevel) return true;
if(isset($project->permissions->group_access->access_level) and $project->permissions->group_access->access_level >= $accessLevel) return true;
if(!empty($project->shared_with_groups))
{
if(empty($groupIDList))
{
$groups = $this->apiGetGroups($gogsID, 'name_asc', $maxRole);
foreach($groups as $group) $groupIDList[] = $group->id;
}
foreach($project->shared_with_groups as $group)
{
if($group->group_access_level < $accessLevel) continue;
if(in_array($group->group_id, $groupIDList)) return true;
}
}
return false;
}
/**
* Check token access.
*
@@ -397,28 +342,48 @@ class gogsModel extends model
* Get projects by api.
*
* @param int $gogsID
* @param bool $sudo
* @access public
* @return array
*/
public function apiGetProjects($gogsID, $sudo = true)
public function apiGetProjects($gogsID)
{
$apiRoot = $this->getApiRoot($gogsID, $sudo);
$apiRoot = $this->getApiRoot($gogsID);
if(!$apiRoot) return array();
$url = sprintf($apiRoot, "/repos/search");
$user = $this->apiGetAdminer($gogsID);
if(!$user) return array();
$url = sprintf($apiRoot, "/users/{$user->username}/repos");
$allResults = array();
for($page = 1; true; $page++)
{
$results = json_decode(commonModel::http($url . "&page={$page}&limit=50"));
if(!is_array($results->data)) break;
if(!empty($results->data)) $allResults = array_merge($allResults, $results->data);
if(count($results->data) < 50) break;
if(!is_array($results)) break;
if(!empty($results)) $allResults = array_merge($allResults, $results);
if(count($results) < 50) break;
}
return $allResults;
}
/**
* Api get adminer.
*
* @param int $gogsID
* @access public
* @return void
*/
public function apiGetAdminer($gogsID)
{
$apiRoot = $this->getApiRoot($gogsID);
if(!$apiRoot) return array();
$url = sprintf($apiRoot, "/user");
$user = json_decode(commonModel::http($url));
return isset($user->username) ? $user : null;
}
/**
* Get gogs user list.
*
@@ -491,31 +456,17 @@ class gogsModel extends model
return $allResults;
}
/**
* Get Forks of a project by API.
*
* @param int $gogsID
* @param string $projectID
* @access public
* @return object
*/
public function apiGetForks($gogsID, $projectID)
{
$url = sprintf($this->getApiRoot($gogsID), "/repos/$projectID/forks");
return json_decode(commonModel::http($url));
}
/**
* Get upstream project by API.
*
* @param int $gogsID
* @param string $projectID
* @param int $gogID
* @param string $project
* @access public
* @return void
*/
public function apiGetUpstream($gogsID, $projectID)
public function apiGetUpstream($gogsID, $project)
{
$currentProject = $this->apiGetSingleProject($gogsID, $projectID);
$currentProject = $this->apiGetSingleProject($gogsID, $project);
if(isset($currentProject->parent->full_name)) return $currentProject->parent->full_name;
return array();
}
@@ -556,28 +507,6 @@ class gogsModel extends model
->fetchPairs();
}
/**
* Get single branch by API.
*
* @param int $gogsID
* @param string $project
* @param string $branchName
* @access public
* @return object
*/
public function apiGetSingleBranch($gogsID, $project, $branchName)
{
$url = sprintf($this->getApiRoot($gogsID), "/repos/$project/branches/$branchName");
$branch = json_decode(commonModel::http($url));
if($branch)
{
$gogs = $this->getByID($gogsID);
$branch->web_url = "{$gogs->url}/$project/src/branch/$branchName";
}
return $branch;
}
/**
* Get protect branches of one project.
*
@@ -589,19 +518,6 @@ class gogsModel extends model
*/
public function apiGetBranchPrivs($gogsID, $project, $keyword = '')
{
$keyword = urlencode($keyword);
$url = sprintf($this->getApiRoot($gogsID), "/repos/$project/branch_protections");
$branches = json_decode(commonModel::http($url));
if(!is_array($branches)) return $branches;
$newBranches = array();
foreach($branches as $branch)
{
$branch->name = $branch->branch_name;
if(empty($keyword) || stristr($branch->name, $keyword)) $newBranches[] = $branch;
}
return $newBranches;
return array();
}
}
+1 -1
View File
@@ -33,4 +33,4 @@ $config->mrapproval->create = new stdclass();
$config->mrapproval->create->skippedFields = '';
$config->mrapproval->create->requiredFields = 'mrID,account,date,action';
$config->mr->gitServiceList = array('gitlab', 'gitea');
$config->mr->gitServiceList = array('gitlab', 'gitea', 'gogs');
+9 -1
View File
@@ -109,21 +109,29 @@ class mr extends control
$repo = $this->repo->getRepoByID($repoID);
$this->loadModel('gitea');
$this->loadModel('gogs');
if($repo->SCM == 'Gitea')
{
$project = $this->gitea->apiGetSingleProject($repo->gitService, $repo->project);
if(empty($project) or !$project->allow_merge_commits) $repo = array();
}
elseif($repo->SCM == 'Gogs')
{
$project = $this->gitea->apiGetSingleProject($repo->gitService, $repo->project);
if(empty($project)) $repo = array();
}
$hosts = $this->loadModel('pipeline')->getList(array('gitea', 'gitlab'));
$hosts = $this->loadModel('pipeline')->getList(array('gitea', 'gitlab', 'gogs'));
if(!$this->app->user->admin)
{
$gitlabUsers = $this->loadModel('gitlab')->getGitLabListByAccount();
$giteaUsers = $this->gitea->getGiteaListByAccount();
$gogsUsers = $this->gogs->getGiteaListByAccount();
foreach($hosts as $hostID => $host)
{
if($host->type == 'gitLab' and isset($gitlabUsers[$hostID])) continue;
if($host->type == 'gitea' and isset($giteaUsers[$hostID])) continue;
if($host->type == 'gogs' and isset($gogsUsers[$hostID])) continue;
unset($hosts[$hostID]);
}
+5 -1
View File
@@ -156,10 +156,14 @@ $(function()
{
var url = createLink('repo', 'ajaxGetGitlabProjects', "gitlabID=" + hostID + "&projectIdList=&filter=IS_DEVELOPER");
}
else
else if(hosts[hostID].type == 'gitea')
{
var url = createLink('repo', 'ajaxGetGiteaProjects', "giteaID=" + hostID);
}
else if(hosts[hostID].type == 'gogs')
{
var url = createLink('repo', 'ajaxGetGogsProjects', "gogsID=" + hostID);
}
$.get(url, function(response)
{
if(response == "<option value=''></option>" && confirm(mrLang.addForApp) == true) window.open(hosts[hostID].url);
+22 -1
View File
@@ -126,6 +126,19 @@ class mrModel extends model
return array($hostID => array_column($projects, null, 'full_name'));
}
/**
* Get gogs projects.
*
* @param int $hostID
* @access public
* @return array
*/
public function getGogsProjects($hostID = 0)
{
$projects = $this->loadModel('gogs')->apiGetProjects($hostID);
return array($hostID => array_column($projects, null, 'full_name'));
}
/**
* Get gitlab projects.
*
@@ -657,7 +670,7 @@ class mrModel extends model
}
return json_decode(commonModel::http($url, $MRObject));
}
else
elseif($host->type == 'gitea')
{
$url = sprintf($this->loadModel('gitea')->getApiRoot($hostID), "/repos/$projectID/pulls");
@@ -681,6 +694,14 @@ class mrModel extends model
if(isset($mergeResult->merged) and $mergeResult->merged) $mergeResult->state = 'merged';
return $mergeResult;
}
elseif($host->type == 'gogs')
{
$mergeResult = new stdClass();
$mergeResult->iid = 0;
$mergeResult->merge_status = 'can_be_merged';
$mergeResult->state = 'opened';
return $mergeResult;
}
}
/**
+2 -1
View File
@@ -52,7 +52,8 @@ $config->repo->gitlab->apiPath = "%s/api/v4/projects/%s/repository/";
$config->repo->gitea = new stdclass;
$config->repo->gitea->apiPath = "%s/api/v1/repos/%s/";
$config->repo->gitServiceList = array('gitlab', 'gitea');
$config->repo->gitServiceList = array('gitlab', 'gitea', 'gogs');
$config->repo->gitTypeList = array('Gitlab', 'Gitea', 'Gogs', 'Git');
$config->repo->rules['module']['task'] = 'Task';
$config->repo->rules['module']['bug'] = 'Bug';
+46 -22
View File
@@ -192,6 +192,7 @@ class repo extends control
{
if($scm == 'gitlab') $options[$project->id] = $project->name_with_namespace;
if($scm == 'gitea') $options[$project->full_name] = $project->full_name;
if($scm == 'gogs') $options[$project->full_name] = $project->full_name;
}
$this->view->projects = $options;
@@ -308,13 +309,13 @@ class repo extends control
foreach($revisions as $log)
{
if($revision == 'HEAD' and $i == 0) $revision = $log->revision;
if($revision == $log->revision) $revisionName = strpos($repo->SCM, 'Git') !== false ? $this->repo->getGitRevisionName($log->revision, $log->commit) : $log->revision;
if($revision == $log->revision) $revisionName = in_array($repo->SCM, $this->config->repo->gitTypeList) ? $this->repo->getGitRevisionName($log->revision, $log->commit) : $log->revision;
$i++;
}
if(!isset($revisionName))
{
if(strpos($repo->SCM, 'Git') !== false) $gitCommit = $this->dao->select('*')->from(TABLE_REPOHISTORY)->where('revision')->eq($revision)->andWhere('repo')->eq($repo->id)->fetch('commit');
$revisionName = (strpos($repo->SCM, 'Git') !== false and isset($gitCommit)) ? $this->repo->getGitRevisionName($revision, $gitCommit) : $revision;
if(in_array($repo->SCM, $this->config->repo->gitTypeList)) $gitCommit = $this->dao->select('*')->from(TABLE_REPOHISTORY)->where('revision')->eq($revision)->andWhere('repo')->eq($repo->id)->fetch('commit');
$revisionName = (in_array($repo->SCM, $this->config->repo->gitTypeList) and isset($gitCommit)) ? $this->repo->getGitRevisionName($revision, $gitCommit) : $revision;
}
$this->view->revisions = $revisions;
@@ -386,7 +387,7 @@ class repo extends control
/* Set branch or tag for git. */
$branches = $tags = $branchesAndTags = array();
if(strpos($repo->SCM, 'Git') !== false)
if(in_array($repo->SCM, $this->config->repo->gitTypeList))
{
$scm = $this->app->loadClass('scm');
$scm->setEngine($repo);
@@ -436,7 +437,7 @@ class repo extends control
/* Update code commit history. */
$commentGroup = $this->loadModel('job')->getTriggerGroup('commit', array($repo->id));
if($refresh and strpos($repo->SCM, 'Git') !== false)
if($refresh and in_array($repo->SCM, $this->config->repo->gitTypeList))
{
$branch = $this->cookie->repoBranch;
$this->loadModel('git')->updateCommit($repo, $commentGroup, false);
@@ -479,7 +480,7 @@ class repo extends control
$revisions = $this->repo->getCommits($repo, $path, $revision, $logType, $pager);
/* Synchronous commit only in root path. */
if(strpos($repo->SCM, 'Git') !== false and empty($path) and $infos and empty($revisions)) $this->locate($this->repo->createLink('showSyncCommit', "repoID=$repoID&objectID=$objectID&branch=" . base64_encode($this->cookie->repoBranch)));
if(in_array($repo->SCM, $this->config->repo->gitTypeList) and empty($path) and $infos and empty($revisions)) $this->locate($this->repo->createLink('showSyncCommit', "repoID=$repoID&objectID=$objectID&branch=" . base64_encode($this->cookie->repoBranch)));
$this->view->title = $this->lang->repo->common;
$this->view->repo = $repo;
@@ -590,7 +591,7 @@ class repo extends control
$history = $this->dao->select('*')->from(TABLE_REPOHISTORY)->where('revision')->eq($log[0]->revision)->andWhere('repo')->eq($repoID)->fetch();
if($history)
{
if(strpos($repo->SCM, 'Git') !== false)
if(in_array($repo->SCM, $this->config->repo->gitTypeList))
{
$thisAndPrevRevisions = $this->scm->exec("rev-list -n 2 {$history->revision} --");
@@ -608,7 +609,7 @@ class repo extends control
if(empty($oldRevision))
{
$oldRevision = '^';
if($history and strpos($repo->SCM, 'Git') !== false) $oldRevision = "{$history->revision}^";
if($history and in_array($repo->SCM, $this->config->repo->gitTypeList)) $oldRevision = "{$history->revision}^";
}
$changes = array();
@@ -694,7 +695,7 @@ class repo extends control
if($encoding != 'utf-8') $blames[$i]['content'] = helper::convertEncoding($blame['content'], $encoding);
}
$log = strpos($repo->SCM, 'Git') !== false ? $this->dao->select('revision,commit')->from(TABLE_REPOHISTORY)->where('revision')->eq($revision)->andWhere('repo')->eq($repo->id)->fetch() : '';
$log = in_array($repo->SCM, $this->config->repo->gitTypeList) ? $this->dao->select('revision,commit')->from(TABLE_REPOHISTORY)->where('revision')->eq($revision)->andWhere('repo')->eq($repo->id)->fetch() : '';
$this->view->title = $this->lang->repo->common;
$this->view->repoID = $repoID;
@@ -705,8 +706,8 @@ class repo extends control
$this->view->entry = $entry;
$this->view->file = $file;
$this->view->encoding = str_replace('-', '_', $encoding);
$this->view->historys = strpos($repo->SCM, 'Git') !== false ? $this->dao->select('revision,commit')->from(TABLE_REPOHISTORY)->where('revision')->in($revisions)->andWhere('repo')->eq($repo->id)->fetchPairs() : '';
$this->view->revisionName = ($log and strpos($repo->SCM, 'Git') !== false) ? $this->repo->getGitRevisionName($log->revision, $log->commit) : $revision;
$this->view->historys = in_array($repo->SCM, $this->config->repo->gitTypeList) ? $this->dao->select('revision,commit')->from(TABLE_REPOHISTORY)->where('revision')->in($revisions)->andWhere('repo')->eq($repo->id)->fetchPairs() : '';
$this->view->revisionName = ($log and in_array($repo->SCM, $this->config->repo->gitTypeList)) ? $this->repo->getGitRevisionName($log->revision, $log->commit) : $revision;
$this->view->blames = $blames;
$this->display();
}
@@ -822,7 +823,7 @@ class repo extends control
$this->view->newRevision = $newRevision;
$this->view->oldRevision = $oldRevision;
$this->view->revision = $newRevision;
$this->view->historys = strpos($repo->SCM, 'Git') !== false ? $this->dao->select('revision,commit')->from(TABLE_REPOHISTORY)->where('revision')->in("$oldRevision,$newRevision")->andWhere('repo')->eq($repo->id)->fetchPairs() : '';
$this->view->historys = in_array($repo->SCM, $this->config->repo->gitTypeList) ? $this->dao->select('revision,commit')->from(TABLE_REPOHISTORY)->where('revision')->in("$oldRevision,$newRevision")->andWhere('repo')->eq($repo->id)->fetchPairs() : '';
$this->view->info = $info;
$this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->diff;
@@ -942,7 +943,7 @@ class repo extends control
$this->scm->setEngine($repo);
$branchID = '';
if(strpos($repo->SCM, 'Git') !== false and empty($branchID))
if(in_array($repo->SCM, $this->config->repo->gitTypeList) and empty($branchID))
{
$branches = $this->scm->branch();
if($branches)
@@ -979,7 +980,7 @@ class repo extends control
$version = empty($latestInDB) ? 1 : $latestInDB->commit + 1;
$logs = array();
$revision = $version == 1 ? 'HEAD' : ($repo->SCM == 'Git' ? $latestInDB->commit : $latestInDB->revision);
$revision = $version == 1 ? 'HEAD' : (in_array($repo->SCM, array('Git', 'Gitea', 'Gogs')) ? $latestInDB->commit : $latestInDB->revision);
if($type == 'batch')
{
$logs = $this->scm->getCommits($revision, $this->config->repo->batchNum, $branchID);
@@ -994,7 +995,7 @@ class repo extends control
{
if(!$repo->synced)
{
if(strpos($repo->SCM, 'Git') !== false)
if(in_array($repo->SCM, $this->config->repo->gitTypeList))
{
if($branchID) $this->repo->saveExistCommits4Branch($repo->id, $branchID);
@@ -1029,7 +1030,7 @@ class repo extends control
set_time_limit(0);
$repo = $this->repo->getRepoByID($repoID);
if(empty($repo)) return;
if(strpos($repo->SCM, 'Git') === false) return print('finish');
if(!in_array($repo->SCM, $this->config->repo->gitTypeList)) return print('finish');
if($branch) $branch = base64_decode($branch);
$this->scm->setEngine($repo);
@@ -1040,7 +1041,7 @@ class repo extends control
$latestInDB = $this->dao->select('DISTINCT t1.*')->from(TABLE_REPOHISTORY)->alias('t1')
->leftJoin(TABLE_REPOBRANCH)->alias('t2')->on('t1.id=t2.revision')
->where('t1.repo')->eq($repoID)
->beginIF(strpos($repo->SCM, 'Git') !== false and $this->cookie->repoBranch)->andWhere('t2.branch')->eq($this->cookie->repoBranch)->fi()
->beginIF(in_array($repo->SCM, $this->config->repo->gitTypeList) and $this->cookie->repoBranch)->andWhere('t2.branch')->eq($this->cookie->repoBranch)->fi()
->orderBy('t1.time')
->limit(1)
->fetch();
@@ -1198,8 +1199,8 @@ class repo extends control
/**
* Ajax get gitea projects.
*
* @param string $gitlabID
* @param string $projectIdList
* @param string $gitlabID
* @param string $projectIdList
* @access public
* @return void
*/
@@ -1214,11 +1215,30 @@ class repo extends control
return print($options);
}
/**
* Ajax get gogs projects.
*
* @param string $gitlabID
* @param string $projectIdList
* @access public
* @return void
*/
public function ajaxGetGogsProjects($gogsID)
{
$projects = $this->loadModel('gogs')->apiGetProjects($gogsID);
if(!$projects) $this->send(array('message' => array()));
$options = "<option value=''></option>";
foreach($projects as $project) $options .= "<option value='{$project->full_name}' data-name='{$project->name}'>{$project->full_name}</option>";
return print($options);
}
/**
* Ajax get gitlab projects.
*
* @param string $gitlabID
* @param string $token
* @param string $gitlabID
* @param string $token
* @access public
* @return void
*/
@@ -1364,12 +1384,16 @@ class repo extends control
}
$repo = $this->repo->getRepoByID($repoID);
if(in_array(strtolower($repo->SCM), $this->config->repo->gitServiceList))
if($repo->SCM == 'Gitlab')
{
$this->scm = $this->app->loadClass('scm');
$this->scm->setEngine($repo);
$url = $this->scm->getDownloadUrl($branch);
}
elseif(in_array($repo->SCM, array('Gitea', 'Gogs')))
{
$url = "$repo->codePath/archive/{$branch}.zip";
}
elseif($repo->SCM == 'Git')
{
$gitDir = scandir($repo->path);
+5 -4
View File
@@ -54,7 +54,7 @@ $(function()
*/
function scmChanged(scm)
{
if(scm == 'Git' || scm == 'Gitea')
if(scm == 'Git' || scm == 'Gitea' || scm == 'Gogs')
{
$('.account-fields').addClass('hidden');
@@ -76,11 +76,12 @@ function scmChanged(scm)
}
else
{
$('.tips').addClass('hidden');
$('tr.service').toggle(true);
if(scm == 'Gitea')
if(scm == 'Gitea' || scm == 'Gogs')
{
$('tr.hide-service:not(".hide-gitea")').toggle(true);
$('tr.hide-gitea').toggle(false);
$('tr.hide-service:not(".hide-git")').toggle(true);
$('tr.hide-git').toggle(false);
}
else
{
+5 -4
View File
@@ -38,7 +38,7 @@ $(function()
*/
function scmChanged(scm, isFirstRequest = false)
{
if(scm == 'Git' || scm == 'Gitea')
if(scm == 'Git' || scm == 'Gitea' || scm == 'Gogs')
{
$('.account-fields').addClass('hidden');
@@ -60,11 +60,12 @@ function scmChanged(scm, isFirstRequest = false)
}
else
{
$('.tips').addClass('hidden');
$('tr.service').toggle(true);
if(scm == 'Gitea')
if(scm == 'Gitea' || scm == 'Gogs')
{
$('tr.hide-service:not(".hide-gitea")').toggle(true);
$('tr.hide-gitea').toggle(false);
$('tr.hide-service:not(".hide-git")').toggle(true);
$('tr.hide-git').toggle(false);
}
else
{
+1
View File
@@ -142,6 +142,7 @@ $lang->repo->encodingList['utf_8'] = 'UTF-8';
$lang->repo->encodingList['gbk'] = 'GBK';
$lang->repo->scmList['Gitlab'] = 'GitLab';
$lang->repo->scmList['Gogs'] = 'Gogs';
$lang->repo->scmList['Gitea'] = 'Gitea';
$lang->repo->scmList['Git'] = 'Git';
$lang->repo->scmList['Subversion'] = 'SVN';
+1
View File
@@ -142,6 +142,7 @@ $lang->repo->encodingList['utf_8'] = 'UTF-8';
$lang->repo->encodingList['gbk'] = 'GBK';
$lang->repo->scmList['Gitlab'] = 'GitLab';
$lang->repo->scmList['Gogs'] = 'Gogs';
$lang->repo->scmList['Gitea'] = 'Gitea';
$lang->repo->scmList['Git'] = 'Git';
$lang->repo->scmList['Subversion'] = 'SVN';
+1
View File
@@ -142,6 +142,7 @@ $lang->repo->encodingList['utf_8'] = 'UTF-8';
$lang->repo->encodingList['gbk'] = 'GBK';
$lang->repo->scmList['Gitlab'] = 'GitLab';
$lang->repo->scmList['Gogs'] = 'Gogs';
$lang->repo->scmList['Gitea'] = 'Gitea';
$lang->repo->scmList['Git'] = 'Git';
$lang->repo->scmList['Subversion'] = 'Subversion';
+1
View File
@@ -142,6 +142,7 @@ $lang->repo->encodingList['utf_8'] = 'UTF-8';
$lang->repo->encodingList['gbk'] = 'GBK';
$lang->repo->scmList['Gitlab'] = 'GitLab';
$lang->repo->scmList['Gogs'] = 'Gogs';
$lang->repo->scmList['Gitea'] = 'Gitea';
$lang->repo->scmList['Git'] = 'Git';
$lang->repo->scmList['Subversion'] = 'SVN';
+1
View File
@@ -142,6 +142,7 @@ $lang->repo->encodingList['utf_8'] = 'UTF-8';
$lang->repo->encodingList['gbk'] = 'GBK';
$lang->repo->scmList['Gitlab'] = 'GitLab';
$lang->repo->scmList['Gogs'] = 'Gogs';
$lang->repo->scmList['Gitea'] = 'Gitea';
$lang->repo->scmList['Git'] = '本地 Git';
$lang->repo->scmList['Subversion'] = 'Subversion';
+22 -7
View File
@@ -436,17 +436,22 @@ class repoModel extends model
$repo = str_replace('[gitlab]', '', $repo);
$repos['Gitlab'][$id] = $repo;
}
if(strpos($repo, '[gitea]') !== false)
elseif(strpos($repo, '[gogs]') !== false)
{
$repo = str_replace('[gogs]', '', $repo);
$repos['Gogs'][$id] = $repo;
}
elseif(strpos($repo, '[gitea]') !== false)
{
$repo = str_replace('[gitea]', '', $repo);
$repos['Gitea'][$id] = $repo;
}
if(strpos($repo, '[svn]') !== false)
elseif(strpos($repo, '[svn]') !== false)
{
$repo = str_replace('[svn]', '', $repo);
$repos['SVN'][$id] = $repo;
}
if(strpos($repo, '[git]') !== false)
elseif(strpos($repo, '[git]') !== false)
{
$repo = str_replace('[git]', '', $repo);
$repos['Git'][$id] = $repo;
@@ -1415,14 +1420,15 @@ class repoModel extends model
return false;
}
}
elseif($scm == 'Gitea')
elseif(in_array($scm, array('Gitea', 'Gogs')))
{
if($this->post->name != '' and $this->post->serviceProject != '')
{
$project = $this->loadModel('gitea')->apiGetSingleProject($this->post->serviceHost, $this->post->serviceProject);
$module = strtolower($scm);
$project = $this->loadModel($module)->apiGetSingleProject($this->post->serviceHost, $this->post->serviceProject);
if(isset($project->tokenCloneUrl))
{
$path = dirname(dirname(dirname(__FILE__))) . '/tmp/repo/' . $this->post->name . '_gitea';
$path = $this->app->getAppRoot() . 'www/data/repo/' . $this->post->name . '_' . $module;
if(!realpath($path))
{
$cmd = 'git clone --progress -v "' . $project->tokenCloneUrl . '" "' . $path . '"';
@@ -2073,7 +2079,7 @@ class repoModel extends model
$repo->password = $service ? $service->token : '';
$repo->codePath = $project ? $project->web_url : $repo->path;
}
elseif($repo->SCM == 'Gitea')
elseif(in_array($repo->SCM, array('Gitea', 'Gogs')))
{
$repo->codePath = $service ? "{$service->url}/{$repo->serviceProject}" : $repo->path;
}
@@ -2214,6 +2220,15 @@ class repoModel extends model
$url->ssh = $project->ssh_url;
}
}
elseif($repo->SCM == 'Gogs')
{
$project = $this->loadModel('gogs')->apiGetSingleProject($repo->gitService, $repo->project);
if(isset($project->id))
{
$url->http = $project->clone_url;
$url->ssh = $project->ssh_url;
}
}
else
{
$this->scm = $this->app->loadClass('scm');
+2 -2
View File
@@ -30,7 +30,7 @@
<tr>
<th class='thWidth'><?php echo $lang->repo->type; ?></th>
<td style="width:550px"><?php echo html::select('SCM', $lang->repo->scmList, 'Gitlab', "onchange='scmChanged(this.value)' class='form-control chosen'"); ?></td>
<td class="tips-git"><?php echo $lang->repo->syncTips; ?></td>
<td class="tips-git tips"><?php echo $lang->repo->syncTips; ?></td>
</tr>
<tr class='service hide'>
<th><?php echo $lang->repo->serviceHost;?></th>
@@ -45,7 +45,7 @@
<td class='required'><?php echo html::input('name', '', "class='form-control'"); ?></td>
<td></td>
</tr>
<tr class='hide-service hide-gitea'>
<tr class='hide-service hide-git'>
<th><?php echo $lang->repo->path; ?></th>
<td class='required'><?php echo html::input('path', '', "class='form-control'"); ?></td>
<td class='muted'>
+2 -2
View File
@@ -34,7 +34,7 @@
<tr>
<th class='thWidth'><?php echo $lang->repo->type; ?></th>
<td style="width:550px"><?php echo html::select('SCM', $lang->repo->scmList, $repo->SCM, "onchange='scmChanged(this.value)' class='form-control chosen'"); ?></td>
<td><span class="tips-git"><?php echo $lang->repo->syncTips; ?></span></td>
<td><span class="tips-git tips"><?php echo $lang->repo->syncTips; ?></span></td>
</tr>
<tr class='service hide'>
<th><?php echo $lang->repo->serviceHost;?></th>
@@ -49,7 +49,7 @@
<td class='required'><?php echo html::input('name', $repo->name, "class='form-control'"); ?></td>
<td></td>
</tr>
<tr class='hide-service hide-gitea'>
<tr class='hide-service hide-git'>
<th><?php echo $lang->repo->path; ?></th>
<td class='required'><?php echo html::input('path', $repo->path, "class='form-control'"); ?></td>
<td class='muted'>
+1 -1
View File
@@ -30,7 +30,7 @@
<th class='c-name text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->repo->name); ?></th>
<th class='c-product text-left'><?php common::printOrderLink('product', $orderBy, $vars, $lang->repo->product); ?></th>
<th class='text-left'><?php echo $lang->repo->path; ?></th>
<th class='c-actions-3'><?php echo $lang->actions; ?></th>
<th class='c-actions-4'><?php echo $lang->actions; ?></th>
</tr>
</thead>
<tbody>
+2 -2
View File
@@ -367,6 +367,6 @@ $config->delete['17_2'][] = 'extension/lite/workflowrelation/ext/view/admin.flow
$config->delete['17_2'][] = 'extension/lite/extension/lite/workflowrule/ext/view/browse.flow.html.hook.php';
$config->delete['17_2'][] = 'extension/lite/extension/lite/workflowrule/ext/view/view.flow.html.hook.php';
$config->upgrade->openModules = array('action', 'admin', 'api', 'automation', 'backup', 'block', 'branch', 'budget', 'bug', 'build', 'caselib', 'ci', 'client', 'common', 'company', 'compile', 'convert', 'cron', 'custom', 'datatable', 'dept', 'design', 'dev', 'doc', 'durationestimation', 'entry', 'execution', 'extension', 'file', 'git', 'gitlab', 'group', 'holiday', 'im', 'index', 'index.html', 'install', 'issue', 'jenkins', 'job', 'kanban', 'license', 'mail', 'message', 'misc', 'mr', 'my', 'personnel', 'pipeline', 'product', 'productplan', 'productset', 'program', 'programplan', 'project', 'projectbuild', 'projectrelease', 'projectstory', 'qa', 'release', 'repo', 'report', 'risk', 'score', 'search', 'setting', 'sonarqube', 'sso', 'stage', 'stakeholder', 'story', 'subject', 'svn', 'task', 'testcase', 'testreport', 'testsuite', 'testtask', 'todo', 'tree', 'tutorial', 'upgrade', 'user', 'webhook', 'weekly', 'workestimation', 'gitea');
$config->upgrade->openModules = array('action', 'admin', 'api', 'automation', 'backup', 'block', 'branch', 'budget', 'bug', 'build', 'caselib', 'ci', 'client', 'common', 'company', 'compile', 'convert', 'cron', 'custom', 'datatable', 'dept', 'design', 'dev', 'doc', 'durationestimation', 'entry', 'execution', 'extension', 'file', 'git', 'gitlab', 'group', 'holiday', 'im', 'index', 'index.html', 'install', 'issue', 'jenkins', 'job', 'kanban', 'license', 'mail', 'message', 'misc', 'mr', 'my', 'personnel', 'pipeline', 'product', 'productplan', 'productset', 'program', 'programplan', 'project', 'projectbuild', 'projectrelease', 'projectstory', 'qa', 'release', 'repo', 'report', 'risk', 'score', 'search', 'setting', 'sonarqube', 'sso', 'stage', 'stakeholder', 'story', 'subject', 'svn', 'task', 'testcase', 'testreport', 'testsuite', 'testtask', 'todo', 'tree', 'tutorial', 'upgrade', 'user', 'webhook', 'weekly', 'workestimation', 'gitea', 'gogs');
$config->upgrade->unsetModules = array('design', 'program', 'programplan', 'projectbuild', 'projectrelease', 'stage', 'stakeholder', 'product', 'branch', 'productplan', 'release', 'build', 'qa', 'bug', 'testcase', 'testtask', 'testreport', 'testsuite', 'caselib', 'automation', 'repo', 'ci', 'compile', 'jenkins', 'job', 'svn', 'gitlab', 'sonarqube', 'mr', 'git', 'report', 'sqlbuilder', 'feedback', 'faq', 'attend', 'holiday', 'leave', 'makeup', 'overtime', 'lieu', 'ops', 'host', 'serverroom', 'account', 'domain', 'service', 'deploy', 'conference', 'traincourse', 'pssp', 'baseline', 'classify', 'cm', 'cmcl', 'auditcl', 'reviewcl', 'process', 'activity', 'zoutput', 'auditplan', 'nc', 'subject', 'weekly', 'workestimation', 'issue', 'durationestimation', 'risk', 'opportunity', 'trainplan', 'gapanalysis', 'researchplan', 'researchreport', 'meeting', 'meetingroom', 'budget', 'reviewissue', 'reviewsetting', 'review', 'milestone', 'measurement', 'measrecord', 'assetlib', 'setting', 'im', 'client', 'ldap', 'dev', 'api', 'gitea');
$config->upgrade->unsetModules = array('design', 'program', 'programplan', 'projectbuild', 'projectrelease', 'stage', 'stakeholder', 'product', 'branch', 'productplan', 'release', 'build', 'qa', 'bug', 'testcase', 'testtask', 'testreport', 'testsuite', 'caselib', 'automation', 'repo', 'ci', 'compile', 'jenkins', 'job', 'svn', 'gitlab', 'sonarqube', 'mr', 'git', 'report', 'sqlbuilder', 'feedback', 'faq', 'attend', 'holiday', 'leave', 'makeup', 'overtime', 'lieu', 'ops', 'host', 'serverroom', 'account', 'domain', 'service', 'deploy', 'conference', 'traincourse', 'pssp', 'baseline', 'classify', 'cm', 'cmcl', 'auditcl', 'reviewcl', 'process', 'activity', 'zoutput', 'auditplan', 'nc', 'subject', 'weekly', 'workestimation', 'issue', 'durationestimation', 'risk', 'opportunity', 'trainplan', 'gapanalysis', 'researchplan', 'researchreport', 'meeting', 'meetingroom', 'budget', 'reviewissue', 'reviewsetting', 'review', 'milestone', 'measurement', 'measrecord', 'assetlib', 'setting', 'im', 'client', 'ldap', 'dev', 'api', 'gitea', 'gogs');