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:
Klaus Silveira
2012-12-27 05:25:58 -08:00

View File

@@ -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);