+ Add unit test case for gogs->apiGetSingleBranch.

This commit is contained in:
caoyanyi
2023-12-22 10:37:12 +08:00
parent e216d8a2ae
commit 02ef7a5d8e
2 changed files with 48 additions and 3 deletions
+5 -3
View File
@@ -278,13 +278,15 @@ class gogsModel extends model
* @param string $project
* @param string $branchName
* @access public
* @return object
* @return object|null
*/
public function apiGetSingleBranch(int $gogsID, string $project, string $branchName): object
public function apiGetSingleBranch(int $gogsID, string $project, string $branchName): object|null
{
if(empty($branchName)) return null;
$url = sprintf($this->getApiRoot($gogsID), "/repos/$project/branches/$branchName");
$branch = json_decode(commonModel::http($url));
if($branch)
if(isset($branch->name))
{
$gogs = $this->fetchByID($gogsID);
$branch->web_url = "{$gogs->url}/$project/src/$branchName";