Skip to content

Commit a686db8

Browse files
committed
fix: fix branch info line parse error
1 parent fcc182f commit a686db8

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/GitUtil.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public static function parseRemoteUrl(string $url): array
128128
/**
129129
* '/(?<current>\*| ) (?<name>[^\s]+) +((?:->) (?<alias>[^\s]+)|(?<hash>[0-9a-z]{7}) (?<message>.*))/'
130130
*/
131-
public const PATTERN_BR_LINE = '/(?<current>\*| ) (?<name>[^\s]+) +((?:->) (?<alias>[^\s]+)|(?<hash>[0-9a-z]{4,41}) (?<message>.*))/';
131+
public const PATTERN_BR_LINE = '/(?<current>\*| ) (?<name>\S+) +((?:->) (?<alias>\S+)|(?<hash>[0-9a-z]{4,41}) (?<message>.*))/';
132132

133133
/**
134134
* @param string $line
@@ -146,11 +146,11 @@ public static function parseBranchLine(string $line, bool $verbose = true): arra
146146
'alias' => '',
147147
];
148148

149-
$line = trim($line);
150149
if (!$verbose) {
151150
// eg:
152151
// * current_branch
153152
// another_branch
153+
$line = trim($line);
154154
if (str_starts_with($line, '*')) {
155155
$branch['current'] = true;
156156
// clear starts

src/Info/BranchInfos.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ public static function fromStrings(array $lines, bool $parse = true): self
7373
return $parse ? $self->parse() : $self;
7474
}
7575

76+
/**
77+
* @return $this
78+
*/
7679
public function parse(): self
7780
{
7881
if ($this->parsed) {

0 commit comments

Comments
 (0)