* Fix error and add unit testcase.

This commit is contained in:
liyuchun
2021-12-08 15:09:32 +08:00
parent 0de19226e5
commit 568b618199
2 changed files with 28 additions and 1 deletions
+6 -1
View File
@@ -217,7 +217,10 @@ class gitlab
$count = $count == 0 ? '' : "-n $count";
$list = $this->getCommitsByPath($path, $fromRevision, $toRevision);
foreach($list as $commit) $commit->diffs = $this->getFilesByCommit($commit->id);
foreach($list as $commit)
{
if(isset($commit->id)) $commit->diffs = $this->getFilesByCommit($commit->id);
}
return $this->parseLog($list);
}
@@ -653,6 +656,7 @@ class gitlab
{
$results = $this->fetch($api, $params);
$params->page ++;
if(!is_array($results)) $results = array();
$allResults = $allResults + $results;
if(count($results) < 100) break;
}
@@ -748,6 +752,7 @@ class gitlab
$i = 0;
foreach($logs as $commit)
{
if(!isset($commit->id)) continue;
$parsedLog = new stdclass();
$parsedLog->revision = $commit->id;
$parsedLog->committer = $commit->committer_name;
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
/**
title=测试 gitlabModel::apiCreateBranch();
cid=1
pid=1
通过gitlabID,projectID,分支对象创建GitLab分支 >> test_branch5
*/
$gitlab = $tester->loadModel('gitlab');
$gitlabID = 1;
$projectID = 1555;
$branch = new stdclass();
$branch->branch = 'test_branch5';
$branch->ref = 'master';
r($gitlab->apiCreateBranch($gitlabID, $projectID, $branch)) && p('name') && e($branch->branch); //通过gitlabID,projectID,分支对象创建GitLab分支