Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Configuration/LifterConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ final class LifterConfig

private bool $commitResults = true;

private ?string $commitAuthor = null;
private ?string $commitEMail = null;

public function __construct(public readonly ?string $configurationFile)
{
$this->workingDirectory = \Safe\getcwd();
Expand Down Expand Up @@ -49,6 +52,21 @@ public function getCommitMessagePrefix(): string
return $this->commitMessagePrefix;
}

public function withCommitAuthor(string $name, string $email): void
{
$this->commitAuthor = $name;
$this->commitEMail = $email;
}

public function getCommitAuthor(): ?string
{
if ($this->commitAuthor === null || $this->commitEMail === null) {
return null;
}

return sprintf('%s <%s>', $this->commitAuthor, $this->commitEMail);
}

/**
* @var list<UpgradeStep>
*/
Expand Down
13 changes: 10 additions & 3 deletions src/Upgrade/GitService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,23 @@ public function doGitCommitForStep(UpgradeStep $step): void
if ($this->config->getCommitMessagePrefix() !== '') {
$commitMessage = sprintf('%s %s', $this->config->getCommitMessagePrefix(), $commitMessage);
}
$authorParams = [];
$commitAuthor = $this->config->getCommitAuthor();
if ($commitAuthor !== null) {
$authorParams[] = '--author';
$authorParams[] = $commitAuthor;
}

$process = $this->processFactory->createProcess(
$process = $this->processFactory->createProcess(...[
'/usr/bin/env',
'git',
'commit',
...$authorParams,
'-a',
'--allow-empty',
'-m',
$commitMessage
);
$commitMessage,
]);
$process->run();

if ($process->getExitCode() > 0) {
Expand Down
Loading