You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting the actual repository object as well as ALL of them
This is due to the remotes/origin/HEAD line not fitting the format in
Branches::getMatches
So, I suck at generating pull requests, adn I'm pretty sure that I don't have privs in this repository anyway...
The fix is threefold:
In Repository->getBranches
if (nameonly)
else
foreach
add
// Don't try to create the remotes origin/HEAD branch
$reducedLine = trim(preg_replace("/\s+/", " ", $branchLine));
$branchParts = explode(" ", $reducedLine);
if ($branchParts[1] === "->") {
continue;
}
then in
Branches::getMatch add these as the first four lines of the function:
// Remotes origin/HEAD causes us problems.
$reducedString = trim(preg_replace("/\s+/", " ", $branchString));
$branchParts = explode(" ", $reducedString);
if ($branchParts[1] === "->") {
return array(null, null, null, null);
}
then in Branches->createFromCommand (private function)
add the first line
$all = true;
and modify the second line to read:
$command = BranchCommand::getInstance()->lists($all);
The other thing that might be nice is to modify Repository->getBranch to be able to take one of these remote names, and that would require it looking like:
public function getBranch($name, $all=false)
{
/** @var Branch $branch */
$nameOnly = false;
foreach ($this->getBranches($nameOnly, $all) as $branch) {
if ($branch->getName() == $name) {
return $branch;
}
}
return null;
}
And as a side note, what I'm really after is being able to merge a branch against origin/master, and it appears that until this is there, I can't even try to do that.
Note: to get a merge of origin the refs/heads/ in the fullRef needs to go away.
What I'm doing for now is a $repo->setFullRef('origin/master');
before the merge, and this gets me the merge command I want (which works). But it's clearly NOT a clean solution. Probably a parameter to the merge command is in order to allow this to work cleanly.
And merges with conflicts result in throwing an exception.
I'd prefer if you changed Repository->merge to lookj like
$git = true;
$cwd = null;
$acceptedExitCodes = array(0, 1);
$this->caller->execute(MergeCommand::getInstance()->merge($branch), $git, $cwd, $acceptedExitCodes);
return $this;
so that I can do a getCaller and take a look to see if there are conflicts. But the status might also get me that.
If you want to get ahold of me, please feel free to email me at [email protected]
The text was updated successfully, but these errors were encountered:
John-Schlick
changed the title
$repo->getBranches(true, true) fails.
$repo->getBranches(true, true) fails. (Includes solution code)
Jun 18, 2014
Getting the actual repository object as well as ALL of them
This is due to the remotes/origin/HEAD line not fitting the format in
Branches::getMatches
So, I suck at generating pull requests, adn I'm pretty sure that I don't have privs in this repository anyway...
The fix is threefold:
In Repository->getBranches
if (nameonly)
else
foreach
add
// Don't try to create the remotes origin/HEAD branch
$reducedLine = trim(preg_replace("/\s+/", " ", $branchLine));
$branchParts = explode(" ", $reducedLine);
if ($branchParts[1] === "->") {
continue;
}
then in
Branches::getMatch add these as the first four lines of the function:
// Remotes origin/HEAD causes us problems.
$reducedString = trim(preg_replace("/\s+/", " ", $branchString));
$branchParts = explode(" ", $reducedString);
if ($branchParts[1] === "->") {
return array(null, null, null, null);
}
then in Branches->createFromCommand (private function)
add the first line
$all = true;
and modify the second line to read:
$command = BranchCommand::getInstance()->lists($all);
The other thing that might be nice is to modify Repository->getBranch to be able to take one of these remote names, and that would require it looking like:
public function getBranch($name, $all=false)
{
/** @var Branch $branch */
$nameOnly = false;
foreach ($this->getBranches($nameOnly, $all) as $branch) {
if ($branch->getName() == $name) {
return $branch;
}
}
And as a side note, what I'm really after is being able to merge a branch against origin/master, and it appears that until this is there, I can't even try to do that.
Note: to get a merge of origin the refs/heads/ in the fullRef needs to go away.
What I'm doing for now is a $repo->setFullRef('origin/master');
before the merge, and this gets me the merge command I want (which works). But it's clearly NOT a clean solution. Probably a parameter to the merge command is in order to allow this to work cleanly.
And merges with conflicts result in throwing an exception.
I'd prefer if you changed Repository->merge to lookj like
$git = true;
$cwd = null;
$acceptedExitCodes = array(0, 1);
$this->caller->execute(MergeCommand::getInstance()->merge($branch), $git, $cwd, $acceptedExitCodes);
so that I can do a getCaller and take a look to see if there are conflicts. But the status might also get me that.
If you want to get ahold of me, please feel free to email me at [email protected]
The text was updated successfully, but these errors were encountered: