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->merge can't merge against a tag. (Solution code included) #60

Open
John-Schlick opened this issue Aug 5, 2014 · 0 comments
Open
Labels

Comments

@John-Schlick
Copy link
Contributor

In general git can merge against a branch or a tag as long as it can translate that to a commit sha.
The current codebase insists that what it passed to merge be a branch.
I NEED to be able to merge against tags for the release process that we have.

So, the following code will allow you to pass a branch OR a tag to repository->merge
First remove the branch specifier from merge in repository.php:
public function merge($branch)

and then recode MergeCommand.php merge to look like:
public function merge($with)
{
$this->clearAll();
$this->addCommandName(static::MERGE_COMMAND);
// $with may not always be a branch. It can be a tag.
if (method_exists($with, 'setFullRef')) {
$ref = $with->getFullRef();
} else {
$ref = $with->getName();
}
$this->addCommandSubject($ref);

    return $this->getCommand();
}

This removes the Branch specifier from the calling parameters, and also checks to make sure that the getFullRef is there (when it's a branch, if not it assumes it's a tag and uses getName)

This is not a perfect implementation as we should also be able to pass in a commit, but since I haven't had to deal with that yet, I've done what I need, and this is healthier than it was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants