mirror of
https://github.com/klaussilveira/gitlist.git
synced 2026-05-07 08:57:00 +02:00
Merge pull request #230 from vognev/fix-ref-name-in-path
fix situation when valid ref is a part of path
This commit is contained in:
@@ -199,7 +199,7 @@ class Repository
|
||||
// Otherwise, attempt to detect the ref using a list of the project's branches and tags
|
||||
$valid_refs = array_merge((array) $repository->getBranches(), (array) $repository->getTags());
|
||||
foreach ($valid_refs as $k => $v) {
|
||||
if (!preg_match("#{$v}/#", $input)) {
|
||||
if (!preg_match(sprintf("#^%s/#", preg_quote($v, '#')), $input)) {
|
||||
unset($valid_refs[$k]);
|
||||
}
|
||||
}
|
||||
@@ -207,7 +207,7 @@ class Repository
|
||||
// No exact ref match, so just try our best
|
||||
if (count($valid_refs) > 1) {
|
||||
preg_match('/([^\/]+)(.*)/', $input, $matches);
|
||||
$branch = preg_replace('/^\/|\/$/', '', $matches[0]);
|
||||
$branch = preg_replace('/^\/|\/$/', '', $matches[1]);
|
||||
} else {
|
||||
// Extract branch name
|
||||
$branch = array_shift($valid_refs);
|
||||
|
||||
Reference in New Issue
Block a user