Skip to content

Commit 3250512

Browse files
committed
GitRepository: fixed parameters in git log commands (closes #70)
1 parent dc084fc commit 3250512

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

src/GitRepository.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ public function commit($message, $params = NULL)
351351
*/
352352
public function getLastCommitId()
353353
{
354-
$result = $this->run('log', '--pretty=format:"%H"', '-n', '1');
354+
$result = $this->run('log', '--pretty=format:%H', '-n', '1');
355355
$lastLine = $result->getOutputLastLine();
356356
return new CommitId((string) $lastLine);
357357
}
@@ -377,39 +377,39 @@ public function getCommit($commitId)
377377
}
378378

379379
// subject
380-
$result = $this->run('log', '-1', $commitId, '--format="%s"');
380+
$result = $this->run('log', '-1', $commitId, '--format=%s');
381381
$subject = rtrim($result->getOutputAsString());
382382

383383
// body
384-
$result = $this->run('log', '-1', $commitId, '--format="%b"');
384+
$result = $this->run('log', '-1', $commitId, '--format=%b');
385385
$body = rtrim($result->getOutputAsString());
386386

387387
// author email
388-
$result = $this->run('log', '-1', $commitId, '--format="%ae"');
388+
$result = $this->run('log', '-1', $commitId, '--format=%ae');
389389
$authorEmail = rtrim($result->getOutputAsString());
390390

391391
// author name
392-
$result = $this->run('log', '-1', $commitId, '--format="%an"');
392+
$result = $this->run('log', '-1', $commitId, '--format=%an');
393393
$authorName = rtrim($result->getOutputAsString());
394394

395395
// author date
396-
$result = $this->run('log', '-1', $commitId, '--pretty="format:%ad"', '--date=iso-strict');
396+
$result = $this->run('log', '-1', $commitId, '--pretty=format:%ad', '--date=iso-strict');
397397
$authorDate = \DateTimeImmutable::createFromFormat(\DateTime::ATOM, (string) $result->getOutputLastLine());
398398

399399
if (!($authorDate instanceof \DateTimeImmutable)) {
400400
throw new GitException('Failed fetching of commit author date.', 0, NULL, $result);
401401
}
402402

403403
// committer email
404-
$result = $this->run('log', '-1', $commitId, '--format="%ce"');
404+
$result = $this->run('log', '-1', $commitId, '--format=%ce');
405405
$committerEmail = rtrim($result->getOutputAsString());
406406

407407
// committer name
408-
$result = $this->run('log', '-1', $commitId, '--format="%cn"');
408+
$result = $this->run('log', '-1', $commitId, '--format=%cn');
409409
$committerName = rtrim($result->getOutputAsString());
410410

411411
// committer date
412-
$result = $this->run('log', '-1', $commitId, '--pretty="format:%cd"', '--date=iso-strict');
412+
$result = $this->run('log', '-1', $commitId, '--pretty=format:%cd', '--date=iso-strict');
413413
$committerDate = \DateTimeImmutable::createFromFormat(\DateTime::ATOM, (string) $result->getOutputLastLine());
414414

415415
if (!($committerDate instanceof \DateTimeImmutable)) {

tests/GitPhp/GitRepository.getCommit.phpt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,63 +12,63 @@ test(function () {
1212

1313
// last commit ID
1414
$runner->assert(
15-
['log', '--pretty=format:"%H"', '-n', '1'],
15+
['log', '--pretty=format:%H', '-n', '1'],
1616
[],
1717
['734713bc047d87bf7eac9674765ae793478c50d3']
1818
);
1919

2020
// commit subject
2121
$runner->assert(
22-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%s"'],
22+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%s'],
2323
[],
2424
['init commit', '', '']
2525
);
2626

2727
// commit body
2828
$runner->assert(
29-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%b"'],
29+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%b'],
3030
[],
3131
['', '', ''] // 3 empty lines
3232
);
3333

3434
// author email
3535
$runner->assert(
36-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%ae"'],
36+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%ae'],
3737
[],
3838
3939
);
4040

4141
// author name
4242
$runner->assert(
43-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%an"'],
43+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%an'],
4444
[],
4545
['John Example']
4646
);
4747

4848
// author date
4949
$runner->assert(
50-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty="format:%ad"', '--date=iso-strict'],
50+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty=format:%ad', '--date=iso-strict'],
5151
[],
5252
["2021-04-29T15:55:09+00:00"]
5353
);
5454

5555
// committer email
5656
$runner->assert(
57-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%ce"'],
57+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%ce'],
5858
[],
5959
6060
);
6161

6262
// committer name
6363
$runner->assert(
64-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%cn"'],
64+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%cn'],
6565
[],
6666
["John Committer"]
6767
);
6868

6969
// committter date
7070
$runner->assert(
71-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty="format:%cd"', '--date=iso-strict'],
71+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty=format:%cd', '--date=iso-strict'],
7272
[],
7373
['2021-04-29T17:55:09+02:00']
7474
);
@@ -98,56 +98,56 @@ test(function () {
9898

9999
// commit subject
100100
$runner->assert(
101-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%s"'],
101+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%s'],
102102
[],
103103
['init commit', '', '']
104104
);
105105

106106
// commit body
107107
$runner->assert(
108-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%b"'],
108+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%b'],
109109
[],
110110
['first line', 'second line', '', ''] // + 2 empty lines
111111
);
112112

113113
// author email
114114
$runner->assert(
115-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%ae"'],
115+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%ae'],
116116
[],
117117
118118
);
119119

120120
// author name
121121
$runner->assert(
122-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%an"'],
122+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%an'],
123123
[],
124124
['John Example']
125125
);
126126

127127
// author date
128128
$runner->assert(
129-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty="format:%ad"', '--date=iso-strict'],
129+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty=format:%ad', '--date=iso-strict'],
130130
[],
131131
["2021-04-29T15:55:09+00:00"]
132132
);
133133

134134
// committer email
135135
$runner->assert(
136-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%ce"'],
136+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%ce'],
137137
[],
138138
139139
);
140140

141141
// committer name
142142
$runner->assert(
143-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%cn"'],
143+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%cn'],
144144
[],
145145
["John Committer"]
146146
);
147147

148148
// committter date
149149
$runner->assert(
150-
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty="format:%cd"', '--date=iso-strict'],
150+
['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty=format:%cd', '--date=iso-strict'],
151151
[],
152152
['2021-04-29T17:55:09+02:00']
153153
);

tests/GitPhp/GitRepository.getLastCommitId.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $runner = new AssertRunner(__DIR__);
1010
$git = new Git($runner);
1111

1212
$runner->assert(
13-
['log', '--pretty=format:"%H"', '-n', '1'],
13+
['log', '--pretty=format:%H', '-n', '1'],
1414
[],
1515
['734713bc047d87bf7eac9674765ae793478c50d3']
1616
);

0 commit comments

Comments
 (0)