Skip to content

Commit b8bfcab

Browse files
Fix api repositories compare method (#597)
Co-authored-by: Paulius Petronis <[email protected]>
1 parent 0c7de45 commit b8bfcab

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/Api/Repositories.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,13 @@ public function postCommitBuildStatus($project_id, string $sha, string $state, a
386386
*/
387387
public function compare($project_id, string $fromShaOrMaster, string $toShaOrMaster, bool $straight = false)
388388
{
389-
return $this->get($this->getProjectPath(
390-
$project_id,
391-
'repository/compare?from='.self::encodePath($fromShaOrMaster).'&to='.self::encodePath($toShaOrMaster).'&straight='.self::encodePath($straight ? 'true' : 'false')
392-
));
389+
$params = [
390+
'from' => self::encodePath($fromShaOrMaster),
391+
'to' => self::encodePath($toShaOrMaster),
392+
'straight' => self::encodePath($straight ? 'true' : 'false'),
393+
];
394+
395+
return $this->get($this->getProjectPath($project_id, 'repository/compare'), $params);
393396
}
394397

395398
/**

tests/Api/RepositoriesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ public function shouldCompareStraight(): void
490490
$api = $this->getApiMock();
491491
$api->expects($this->once())
492492
->method('get')
493-
->with('projects/1/repository/compare?from=master&to=feature&straight=true')
493+
->with('projects/1/repository/compare', ['from' => 'master', 'to' => 'feature', 'straight' => 'true'])
494494
->will($this->returnValue($expectedArray))
495495
;
496496

@@ -507,7 +507,7 @@ public function shouldNotCompareStraight(): void
507507
$api = $this->getApiMock();
508508
$api->expects($this->once())
509509
->method('get')
510-
->with('projects/1/repository/compare?from=master&to=feature&straight=false')
510+
->with('projects/1/repository/compare', ['from' => 'master', 'to' => 'feature', 'straight' => 'false'])
511511
->will($this->returnValue($expectedArray))
512512
;
513513

0 commit comments

Comments
 (0)