Search code examples
githubcomposer-phpforkbranch

Composer requiring github repository fork branch still checks all tags


Short question: How can I make composer require my branch from my fork without checking all tags?

Long question: I want composer to require a specific branch that I created of a fork I created from twig. My assumption was, that, when defined correctly, composer directly requires the branch. Instead first it checks all the tags and after that it loads the branch. I don't want composer to check the tags, I just want to use the branch.

Is this the correct behaviour or am I requiring the branch incorreclty?

  • My fork would be github.com/myfork/Twig
  • My branch would be mybranchname

This is my composer.json

{
    "require": {
    "twig/twig": "dev-mybranchname"
    },
    "repositories": [
      {
        "type": "vcs",
        "url": "https://github.com/myfork/Twig"
      }
    ]
...
...

Solution

  • This is the correct behavior. Composer checks for all tags first before it could get to your branch name.

    You can check if your code is fetched from the right repository by checking your composer.lock

    Your composer.lock should be like this.

    {
        "name": "twig/twig",
        "version": "dev-mybranchname",
        "source": {
            "type": "git",
            "url": "https://github.com/myfork/Twig",
            "reference": <your_revision_number>
        },
        ...
    }