have composer update get latest version from git repo

I am trying to move away from git submodules for the development in my team. The most important reason for this is that when a team member commits changes in a submodule, but forgets to push to origin, but does push the reference to this new commit in the “root” project, origin is broken, and the other developers get the reference is not a tree error. This can be problematic if the developer in question pushed before going home, and that reference that is not a tree points to a commit on the developers laptop, which is in his bag, in a train somewhere.

I am trying to replace git submodules with composer. My reasoning is that if git doesn’t know about my dependencies, these dependencies can’t break the repo. I know how to add packages from packagist, and I also managed to add our own git repositories to composer, mainly with the help from this blog post.

The problem, and the last piece of the puzzle, is that our dependencies are git repositories that we are actively working on. If I push an update to one of our dependencies, I would like the local copies of the developers to update to this latest version when they do a composer update. The closest I got is to create a tag for each change to a dependency, and then update my composer.json with the id of this new tag.

What I would like to know, is if there is a way to have composer always check out the latest commit of a certain branch, or, if this is not possible, to always get the latest tag when I do a composer update. I don’t really mind the tagging, I just don’t want to keep updating composer.json during development.

The composer file I have for testing:

{
    "config": {
        "vendor-dir": "app/vendor"
    },
    "repositories":
    [
        {
            "type": "package",
            "package": {
                "name": "wkjagt/seagull",
                "version": "1.0",
                "source": {
                    "url": "git@github.com:wkjagt/Seagull.git",
                    "type": "git",
                    "reference": "master"
                }
            }
        }
    ],
    "require": {
        "wkjagt/seagull": "1.0.*"
    }
}

I was expecting the 1.0.* to take the latest tag starting with 1.0, but once composer already has 1.0.1, it won’t get 1.0.2 if I create it. Any help with this would be very much appreciated.

  • Laravel 5.0 - Error by running composer install
  • Composer diagnose and install error
  • Best workflow using PHP and MySQL --> GitHub --> deplayment server/live server
  • Continuous Integration using GIT / BitBucket on a GIT controlled Intranet
  • asking account password when pull in bitbucket?
  • Confused about deplyoing application on openshift server using git
  • WP CLI install list of plugins from YML file wp-cli.local.yml
  • Deploying when push to git
  • One Solution collect form web for “have composer update get latest version from git repo”

    If you won’t have to specify each version separately in your repositories section, you’ll need to add a composer.json file to wkjagt/Seagull and include the package like this:

    {
       "type": "vcs",
       "url": "https://github.com/wkjagt/Seagull"
    },
    

    Composer can then read through your tags and treat them as versions. If you always want the get the latest version require your package with the dev flag:

    "require": {
        "wkjagt/seagull": "@dev"
    }
    
    Git Baby is a git and github fan, let's start git clone.