Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$repo->getBranches(true, true) fails. (Includes solution code) #42

Open
John-Schlick opened this issue Jun 17, 2014 · 0 comments
Open

Comments

@John-Schlick
Copy link
Contributor

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]

@John-Schlick John-Schlick changed the title $repo->getBranches(true, true) fails. $repo->getBranches(true, true) fails. (Includes solution code) Jun 18, 2014
@John-Schlick John-Schlick mentioned this issue Jun 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant