diff --git a/src/GitRepository.php b/src/GitRepository.php index 38a7584..f8ec97b 100644 --- a/src/GitRepository.php +++ b/src/GitRepository.php @@ -351,7 +351,7 @@ public function commit($message, $params = NULL) */ public function getLastCommitId() { - $result = $this->run('log', '--pretty=format:"%H"', '-n', '1'); + $result = $this->run('log', '--pretty=format:%H', '-n', '1'); $lastLine = $result->getOutputLastLine(); return new CommitId((string) $lastLine); } @@ -377,23 +377,23 @@ public function getCommit($commitId) } // subject - $result = $this->run('log', '-1', $commitId, '--format="%s"'); + $result = $this->run('log', '-1', $commitId, '--format=%s'); $subject = rtrim($result->getOutputAsString()); // body - $result = $this->run('log', '-1', $commitId, '--format="%b"'); + $result = $this->run('log', '-1', $commitId, '--format=%b'); $body = rtrim($result->getOutputAsString()); // author email - $result = $this->run('log', '-1', $commitId, '--format="%ae"'); + $result = $this->run('log', '-1', $commitId, '--format=%ae'); $authorEmail = rtrim($result->getOutputAsString()); // author name - $result = $this->run('log', '-1', $commitId, '--format="%an"'); + $result = $this->run('log', '-1', $commitId, '--format=%an'); $authorName = rtrim($result->getOutputAsString()); // author date - $result = $this->run('log', '-1', $commitId, '--pretty="format:%ad"', '--date=iso-strict'); + $result = $this->run('log', '-1', $commitId, '--pretty=format:%ad', '--date=iso-strict'); $authorDate = \DateTimeImmutable::createFromFormat(\DateTime::ATOM, (string) $result->getOutputLastLine()); if (!($authorDate instanceof \DateTimeImmutable)) { @@ -401,15 +401,15 @@ public function getCommit($commitId) } // committer email - $result = $this->run('log', '-1', $commitId, '--format="%ce"'); + $result = $this->run('log', '-1', $commitId, '--format=%ce'); $committerEmail = rtrim($result->getOutputAsString()); // committer name - $result = $this->run('log', '-1', $commitId, '--format="%cn"'); + $result = $this->run('log', '-1', $commitId, '--format=%cn'); $committerName = rtrim($result->getOutputAsString()); // committer date - $result = $this->run('log', '-1', $commitId, '--pretty="format:%cd"', '--date=iso-strict'); + $result = $this->run('log', '-1', $commitId, '--pretty=format:%cd', '--date=iso-strict'); $committerDate = \DateTimeImmutable::createFromFormat(\DateTime::ATOM, (string) $result->getOutputLastLine()); if (!($committerDate instanceof \DateTimeImmutable)) { diff --git a/tests/GitPhp/GitRepository.getCommit.phpt b/tests/GitPhp/GitRepository.getCommit.phpt index d3ae111..39b4f9e 100644 --- a/tests/GitPhp/GitRepository.getCommit.phpt +++ b/tests/GitPhp/GitRepository.getCommit.phpt @@ -12,63 +12,63 @@ test(function () { // last commit ID $runner->assert( - ['log', '--pretty=format:"%H"', '-n', '1'], + ['log', '--pretty=format:%H', '-n', '1'], [], ['734713bc047d87bf7eac9674765ae793478c50d3'] ); // commit subject $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%s"'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%s'], [], ['init commit', '', ''] ); // commit body $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%b"'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%b'], [], ['', '', ''] // 3 empty lines ); // author email $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%ae"'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%ae'], [], ['john@example.com'] ); // author name $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%an"'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%an'], [], ['John Example'] ); // author date $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty="format:%ad"', '--date=iso-strict'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty=format:%ad', '--date=iso-strict'], [], ["2021-04-29T15:55:09+00:00"] ); // committer email $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%ce"'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%ce'], [], ["john@committer.com"] ); // committer name $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%cn"'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%cn'], [], ["John Committer"] ); // committter date $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty="format:%cd"', '--date=iso-strict'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty=format:%cd', '--date=iso-strict'], [], ['2021-04-29T17:55:09+02:00'] ); @@ -98,56 +98,56 @@ test(function () { // commit subject $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%s"'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%s'], [], ['init commit', '', ''] ); // commit body $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%b"'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%b'], [], ['first line', 'second line', '', ''] // + 2 empty lines ); // author email $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%ae"'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%ae'], [], ['john@example.com'] ); // author name $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%an"'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%an'], [], ['John Example'] ); // author date $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty="format:%ad"', '--date=iso-strict'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty=format:%ad', '--date=iso-strict'], [], ["2021-04-29T15:55:09+00:00"] ); // committer email $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%ce"'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%ce'], [], ["john@committer.com"] ); // committer name $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format="%cn"'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--format=%cn'], [], ["John Committer"] ); // committter date $runner->assert( - ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty="format:%cd"', '--date=iso-strict'], + ['log', '-1', '734713bc047d87bf7eac9674765ae793478c50d3', '--pretty=format:%cd', '--date=iso-strict'], [], ['2021-04-29T17:55:09+02:00'] ); diff --git a/tests/GitPhp/GitRepository.getLastCommitId.phpt b/tests/GitPhp/GitRepository.getLastCommitId.phpt index 7d2d18b..908edb3 100644 --- a/tests/GitPhp/GitRepository.getLastCommitId.phpt +++ b/tests/GitPhp/GitRepository.getLastCommitId.phpt @@ -10,7 +10,7 @@ $runner = new AssertRunner(__DIR__); $git = new Git($runner); $runner->assert( - ['log', '--pretty=format:"%H"', '-n', '1'], + ['log', '--pretty=format:%H', '-n', '1'], [], ['734713bc047d87bf7eac9674765ae793478c50d3'] );