|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of CaptainHook. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Sebastian Feldmann <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace SebastianFeldmann\Git\Operator; |
|
13
|
|
|
|
|
14
|
|
|
use SebastianFeldmann\Git\Command\Log\ChangedFiles; |
|
15
|
|
|
use SebastianFeldmann\Git\Command\Log\Commits; |
|
16
|
|
|
use SebastianFeldmann\Git\Command\Log\Commits\Xml; |
|
17
|
|
|
use SebastianFeldmann\Git\Repository; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Class Log |
|
21
|
|
|
* |
|
22
|
|
|
* @package SebastianFeldmann\Git |
|
23
|
|
|
* @author Sebastian Feldmann <[email protected]> |
|
24
|
|
|
* @link https://github.com/sebastianfeldmann/git |
|
25
|
|
|
* @since Class available since Release 0.9.0 |
|
26
|
|
|
*/ |
|
27
|
|
|
class Log extends Base |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* Get the list of files that changed since a given revision. |
|
31
|
|
|
* |
|
32
|
|
|
* @param string $revision |
|
33
|
1 |
|
* @return array<string> |
|
34
|
|
|
*/ |
|
35
|
1 |
|
public function getChangedFilesSince(string $revision): array |
|
36
|
1 |
|
{ |
|
37
|
|
|
$cmd = (new ChangedFiles($this->repo->getRoot()))->byRevision($revision); |
|
38
|
1 |
|
$result = $this->runner->run($cmd); |
|
39
|
|
|
|
|
40
|
|
|
return $result->getBufferedOutput(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Get list of commits since given revision. |
|
45
|
|
|
* |
|
46
|
|
|
* @param string $revision |
|
47
|
|
|
* @return array<\SebastianFeldmann\Git\Log\Commit> |
|
48
|
1 |
|
* @throws \Exception |
|
49
|
|
|
*/ |
|
50
|
1 |
|
public function getCommitsSince(string $revision): array |
|
51
|
1 |
|
{ |
|
52
|
|
|
$cmd = (new Commits($this->repo->getRoot()))->byRevision($revision) |
|
53
|
1 |
|
->prettyFormat(Commits\Xml::FORMAT); |
|
54
|
1 |
|
|
|
55
|
|
|
$result = $this->runner->run($cmd); |
|
56
|
|
|
return Xml::parseLogOutput($result->getStdOut()); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Get list of commits between to given revisions |
|
61
|
|
|
* |
|
62
|
|
|
* @param string $from |
|
63
|
|
|
* @param string $to |
|
64
|
|
|
* @return array<\SebastianFeldmann\Git\Log\Commit> |
|
65
|
1 |
|
* @throws \Exception |
|
66
|
|
|
*/ |
|
67
|
1 |
|
public function getCommitsBetween(string $from, string $to): array |
|
68
|
1 |
|
{ |
|
69
|
|
|
$cmd = (new Commits($this->repo->getRoot()))->byRevision($from, $to) |
|
70
|
1 |
|
->prettyFormat(Commits\Xml::FORMAT); |
|
71
|
1 |
|
|
|
72
|
|
|
$result = $this->runner->run($cmd); |
|
73
|
|
|
return Xml::parseLogOutput($result->getStdOut()); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|