Skip to content

Commit 6abbfb9

Browse files
committed
Add Client::fetchLog()
1 parent 03e3fa5 commit 6abbfb9

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/Client.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ public function fetchPatch($path, $r1, $r2)
9191
return $this->fetch($url);
9292
}
9393

94+
public function fetchLog($path, $revision = null)
95+
{
96+
$url = $path . '?view=log';
97+
98+
// TODO: invalid revision shows error page, but HTTP 200 OK
99+
100+
if ($revision !== null) {
101+
$url .= (strpos($url, '?') === false) ? '?' : '&';
102+
$url .= 'pathrev=' . $revision;
103+
}
104+
105+
return $this->fetchXml($url)->then(array($this->parser, 'parseLogEntries'));
106+
}
107+
94108
public function fetchRevisionPrevious($path, $revision)
95109
{
96110
return $this->fetchAllPreviousRevisions($path)->then(function ($revisions) use ($revision) {

tests/ClientTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ public function testFetchDirectoryRevisionAttic()
8585
$this->expectPromiseReject($promise);
8686
}
8787

88+
public function testFetchLogRevision()
89+
{
90+
$this->browser->expects($this->once())->method('get')->with($this->equalTo('http://viewvc.example.org/README.md?view=log&pathrev=1.0'))->will($this->returnValue($this->createPromiseRejected()));
91+
92+
$promise = $this->client->fetchLog('/README.md', '1.0');
93+
94+
$this->expectPromiseReject($promise);
95+
}
96+
8897
public function testFetchPatch()
8998
{
9099
$this->browser->expects($this->once())->method('get')->with($this->equalTo('http://viewvc.example.org/README.md?view=patch&r1=1.0&r2=1.1'))->will($this->returnValue($this->createPromiseRejected()));

0 commit comments

Comments
 (0)