Skip to content

Commit

Permalink
fixes #13: Allow passing current branch to validate commits.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsqd committed Jul 31, 2024
1 parent 73dc19c commit dbfebab
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Robo/Plugin/Commands/ValidateCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ public function validateCommitMessages(
array $opts = [
'project-id' => '',
'target-branch' => 'develop',
'current-branch' => 'HEAD',
'git-remote' => 'origin',
'pattern' => '/^{$project_id}-(\d+): /',
'short-help' => 'Commit messages must start with: \'{$project_id}-x:y\'',
Expand All @@ -417,12 +418,14 @@ public function validateCommitMessages(
] = $this->getOptions(['project-id', 'long-help'], $opts, false);
[
$target_branch,
$current_branch,
$git_remote,
$pattern,
$short_help,
] = $this->getOptions(
[
'target-branch',
'current-branch',
'git-remote',
'pattern',
'short-help',
Expand All @@ -448,8 +451,8 @@ public function validateCommitMessages(
return new ResultData(ResultData::EXITCODE_ERROR);
}
var_dump('CURRENT BRANCH:');
var_dump($this->getGitBranch());
$git_command = "git log $git_remote/$target_branch...HEAD --pretty=format:%s --no-merges";
var_dump($current_branch);
$git_command = "git log $git_remote/$target_branch...$current_branch --pretty=format:%s --no-merges";
exec($git_command, $output, $result_code);
if ($result_code !== 0) {
$this->printError('Unable to git log data.');
Expand Down

0 comments on commit dbfebab

Please sign in to comment.